You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a wiki markdown file is rendered as an HTML page, the view seahub/wiki/views.py cares about translating the markdown to HTML. All headlines are collected and an outline of clickable navigation items is rendered to the right.
The corresponding <h2> or <h3> elements are assigned id attributes prefixed with user-content- and suffixed with the headline itself, so e.g. a markdown headline of
## How to install
will yield HTML like
<h2data-slate-node="element" id="user-content-How to install">...</h2>
When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character. The value must not contain any ASCII whitespace.
So there are three restrictions for id attributes marked as must and must not, resp.:
idmust have at least one character (implicitly true in our case due to the user-content- prefix)
idmust not contain any whitespace (!)
idmust be unique (!)
The second constraint is violated for headlines containing spaces, as can also be seen with w3c validation:
Firefox and Chromium seem to be gracefully ignoring it, I have no other browsers for testing.
The third constraint (uniqueness) is violated: If we have the same headline twice, it generates the same id twice, breaking the navigation:
This breaks the navigation as the duplicate outline items will always jump to the last item with the duplicate id.
Maybe there needs to be some kind of sluggify step that
strips leading and trailing whitespace
removes characters like emojis
replaces all whitespace between words with hyphens
adds a running counter (ensuring uniqueness)
So our headline
How to install?
gets sluggified to
user-content-how-to-install-7
?
The text was updated successfully, but these errors were encountered:
If a wiki markdown file is rendered as an HTML page, the view
seahub/wiki/views.py
cares about translating the markdown to HTML. All headlines are collected and an outline of clickable navigation items is rendered to the right.The corresponding
<h2>
or<h3>
elements are assignedid
attributes prefixed withuser-content-
and suffixed with the headline itself, so e.g. a markdown headline of## How to install
will yield HTML like
Regarding the global
id
attribute, the HTML 5 specification states:So there are three restrictions for
id
attributes marked as must and must not, resp.:id
must have at least one character (implicitly true in our case due to theuser-content-
prefix)id
must not contain any whitespace (!)id
must be unique (!)The second constraint is violated for headlines containing spaces, as can also be seen with w3c validation:
Firefox and Chromium seem to be gracefully ignoring it, I have no other browsers for testing.
The third constraint (uniqueness) is violated: If we have the same headline twice, it generates the same
id
twice, breaking the navigation:This breaks the navigation as the duplicate outline items will always jump to the last item with the duplicate id.
Maybe there needs to be some kind of sluggify step that
So our headline
How to install?
gets sluggified to
user-content-how-to-install-7
?
The text was updated successfully, but these errors were encountered: