pdml-lang / pdml-lang.github.io

PDML website
https://pdml-lang.dev/
GNU General Public License v2.0
1 stars 0 forks source link

Hyphens in Node Names #5

Closed slanden closed 2 years ago

slanden commented 2 years ago

The article Suggestion For a Better XML/HTML Syntax states in the section titled Comments

an element name cannot contain hyphens (-).

Does this mean hyphens aren't allowed in the middle of names either?

[- Comment -]
[custom-element
  some text
]

Today's HTML component authors must use multi-word names separated by hyphens to not conflict with any official HTML single-word element, existing or not.

How does this come into play in PDML, especially if used as an alternative to write Web documents?

pdml-lang commented 2 years ago

an element name cannot contain hyphens (-)

This is actually a mistake in the article. Thanks for pointing this out. I have fixed it. It now states:

"an element name cannot start with a hyphen (-)"

Does this mean hyphens aren't allowed in the middle of names either?

They are allowed in the middle of names. They are just not allowed as a first character of a name.

The official PDML specification states:

"A node name must match the regex [a-zA-Z_][a-zA-Z0-9_\.-]*. This means that a name starts with a letter or an underscore (_), optionally followed by any number of letters, digits, underscores (_), hyphens (-), or dots (.)."

How does this come into play in PDML, especially if used as an alternative to write Web documents?

The PDML/PML rule for names is the same as the rule in XML/HTML (see chapter 'XML Naming Rules'):

XML elements must follow these naming rules:

  • Element names are case-sensitive
  • Element names must start with a letter or underscore
  • Element names cannot start with the letters xml (or XML, or Xml, etc)
  • Element names can contain letters, digits, hyphens, underscores, and periods
  • Element names cannot contain spaces