Skip to content

Exclude symbols from auto-generated heading identifiers#181

Merged
dereuromark merged 1 commit into
masterfrom
fix/heading-id-exclude-symbols
May 19, 2026
Merged

Exclude symbols from auto-generated heading identifiers#181
dereuromark merged 1 commit into
masterfrom
fix/heading-id-exclude-symbols

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

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:

Heading Before After (spec)
# Release notes :tada: Release-notes-tada Release-notes
# Build :rocket: Status Build-rocket-Status BuildStatus
# :tada: (symbol only) tada s-1 (fallback)

Changes

  • HeadingIdTracker::extractPlainText() gains a forId mode that skips Symbol and FootnoteRef nodes.
  • 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.
  • 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 h- prefix) are unchanged; the docs/reference/enhancements.md spec-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.

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.
@dereuromark dereuromark added bug Something isn't working documentation Improvements or additions to documentation labels May 19, 2026
@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.10%. Comparing base (f5482be) to head (54c38a7).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit 6b90dfe into master May 19, 2026
6 checks passed
@dereuromark dereuromark deleted the fix/heading-id-exclude-symbols branch May 19, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant