Heading ids: lowercase (GitHub-style) default + opt-in ASCII fold - #68
Merged
Conversation
Aligns the heading-id slug with carve spec #73. normalizeId now applies the jgm/djot#393 run rule (each maximal run of non-alphanumeric ASCII -> single '-', trimmed) and then lowercases (Unicode-aware), keeping non-ASCII characters verbatim. Empty-text and digit-leading slugs use the s / s- fallback. This makes ids and </#id> / [Heading][] cross-references case-insensitive with no special lookup logic. ASCII transliteration is no longer the default. It moves behind a new AsciiHeadingIdsExtension, which sets a slug transformer on both the render-time tracker and the parse-time tracker (so implicit [Heading][] references resolve to the folded ids). Also fixes renderHeadingRef: an unresolved </#id> now renders as its literal source text instead of a dangling self-link, matching the spec and carve-js. This surfaced once ASCII refs stopped matching non-ASCII ids. Bumps the spec submodule to the #73 lowercase corpus and promotes the new 81-list-lazy-continuation category (already produced byte-identically).
…rcase # Conflicts: # tests/CarveCorpusTest.php
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.
Implements the carve spec #73 lowercase heading-id decision in carve-php.
What changes
HeadingIdTracker::normalizeIdnow:-, trimmed),s/s-for empty-text and digit-leading slugs,ASCII transliteration was the baked default; it is now opt-in via a new
AsciiHeadingIdsExtension. The extension installs a slug transformer on both therender-time tracker and the parse-time tracker, so implicit
[Heading][]referencesalso resolve to the folded ids.
Bonus fix
renderHeadingRefrendered an unresolved</#id>as a dangling self-link(
<a href="#id">id</a>). It now renders the literal source text, matching the specand carve-js. This was masked before: ASCII-by-default ids meant ASCII refs usually
resolved; once ids keep non-ASCII, the divergence showed in corpus 19.
Scope
src/Renderer/HeadingIdTracker.php,src/Parser/BlockParser.php,src/Renderer/HtmlRenderer.phpsrc/Extension/AsciiHeadingIdsExtension.php(+ test)81-list-lazy-continuationpromoted to IMPLEMENTED (already byte-identical)Gates green locally: phpunit (2194), phpstan (0), phpcs (0). Part of carve#71.