Consistent naming scheme for html and svg elements.
Consistency is not W3C's strong point, but it's made worse in tyxml. The main pain point is dashes, since they are not valid in ocaml's identifiers.
So a more formal version of what we are currently loosely applying:
-
We always keep the name in the specification if it's a valid ocaml identifier, be it snake_case, nocase, CamlCase or whatever, even if it's internally inconsistent (I'm looking at you,
fontFace) -
Dashes are transformed in underscores systematically.
-
Underscores are kept.
-
Any other characters that could ever appear are transformed in an underscore too. I don't think I ever saw one, but better be sure.
-
In case of conflict between attributes of incompatible types. We put the element that it's disambiguated for between underscores, after the
a.Example: the attribute
maxforinputis transformed ina_input_max. -
Specific transformation rules:
- When transforming to an element, the first letter become a lowercase.
- When transforming to a polymorphic variant, the first letter is capitalized. This is not mandatory (since polymorphic variant can start with a lowercase), but it's acceptable and is already applied almost consistently, so better keep it.
- When transforming to an attribute, no letter is changed (it's ok, it starts with
a_).
These should also keep the breaking rather minimal. Remarks ? cc @dsheets since you might have an opinion. :)
Seems reasonable. Though W3C's "conventions" are inconsistent, I agree it is better to have a fairly verbatim mapping between them and Tyxml's names, as I reckon most developers rely on resources such as MDN, which of course use W3C's naming.
Apparently, some svg attributes have ':' in the name. so that would become a '_' in this scheme.
I pushed a bunch of functions and a little tool called autoname that does the transformation automatically.
The only things remaining to do is to transform the whole codebase .... sob.
The situation is much better now, but not yet enforced by the ppx. We will get there eventually.