Autogenerate libraries from HTML spec

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:

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.

1 Like

purescript-react-basic-dom automates this using the react-html-attributes npm package:

although I’m not sure how portable this approach is; it seems more closely tied to React specifically than HTML in general. For example, it’s got dangerouslySetInnerHTML in there.

1 Like