Has anyone investigated autogenerating PS libraries from definitions in the HTML spec?
I like how Halogen provides typed attributes and properties for HTML elements. And it would be great to further improve type safety by avoiding strings when selecting from a finite number of choices? For example:
SandboxAllowScripts
instead of:
HP.sandbox "allow-scripts"
I think the only reasonable way to write this library and keep it up to date is with autogeneration from the latest HTML spec.
It would also be great if there was some way to share these common definitions among frameworks (or at least share the autogeneration code that could be modified to target another framework).
Some possible HTML spec sources are:
- Machine-readable:
- https://github.com/tawesoft/html5spec - Parsed WHATWG webpage to JSON.
- https://github.com/unsoup/validator - Extracted definitions from v.Nu (old and seems incomplete - may need to re-run tools).
- Requires more work:
- Investigate sources of n.Vu checker https://github.com/validator/validator
- Scrape W3C Spec https://www.w3.org/TR/2018/WD-html53-20181018/
- Scrape MDN docs https://developer.mozilla.org/en-US/docs/Web/HTML/Element
- Parse WHATWG source https://github.com/whatwg/html
PS. I often read that there’s technically no “HTML spec” and it’s more of “HTML community trends”, but any widely cited set of trends should be a pretty good foundation for most use cases.