Exclude symbols from auto-generated heading identifiers#181
Merged
Conversation
The djot spec forms a heading's auto identifier from its plain text content "excluding non-textual elements such as footnote references and symbols". djot-php already dropped footnote references but emitted symbols as `:name:`, so `# Release notes :tada:` produced the ID `Release-notes-tada` instead of `Release-notes`. extractPlainText() gains a forId mode that skips Symbol and FootnoteRef nodes. generateId() still warms the plain-text cache so display consumers (TOC labels, permalinks) keep the symbol text, but builds the identifier from the symbol/footnote-excluded text. As a result a heading whose only content is a symbol now correctly falls back to a generated s-N identifier. The deliberate CSS-validity deviations (apostrophe/quote/colon replacement, leading-digit prefix) are unchanged and now documented against the settled spec wording.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #181 +/- ##
============================================
+ Coverage 91.08% 91.10% +0.01%
- Complexity 3319 3321 +2
============================================
Files 99 99
Lines 8493 8497 +4
============================================
+ Hits 7736 7741 +5
+ Misses 757 756 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The djot spec forms a heading's auto-generated identifier from its plain text content "excluding non-textual elements such as footnote references and symbols" (wording settled by jgm/djot#393).
djot-php already excluded footnote references but emitted symbols as
:name:into the ID:# Release notes :tada:Release-notes-tadaRelease-notes# Build :rocket: StatusBuild-rocket-StatusBuildStatus# :tada:(symbol only)tadas-1(fallback)Changes
HeadingIdTracker::extractPlainText()gains aforIdmode that skipsSymbolandFootnoteRefnodes.generateId()still warms the plain-text cache so display consumers (TOC labels, heading permalinks) keep the human-readable symbol text — only the identifier excludes symbols.s-Nidentifier.h-prefix) are unchanged; thedocs/reference/enhancements.mdspec-alignment section is rewritten against the settled jgm/djot#393 wording and now distinguishes the djot.js reference implementation from the (broader) #393 prose.Notes
PR #393 only reworded the spec prose; the djot.js reference implementation is unchanged. djot-php tracks the djot.js implementation where prose and implementation disagree (e.g.
_is kept), deviating only where required for valid CSS identifiers — this rationale is now captured in the docs table.