Repository navigation
fix(docs): restore code spans by position in heading slugs (#1361) - #1404
Merged
Merged
Conversation
githubSlug swapped code spans for their index as digits and restored every digit run afterwards, so a heading holding its own digits or entity-decoded characters got the wrong text back (use-undefined for 'Use 0'). The spans are now marked with a character absent from the heading, syntax is stripped, and the text is split on that mark; entities are decoded per piece and each code span is put back by position.
…e decoded heading (#1361) Back to the original code-span markers and restore regex. The two private-use marker characters are now the first pair that appears neither in the heading nor in its entity-decoded form, so a heading written with 0 no longer collides. Emphasis, link and tag handling is unchanged.
…s it consistently (#1361) Each candidate pair is tried against the real rendering and kept only when every marker in the output belongs to a well-formed marker, index pair with a known span used once. The pre-filter on the heading text stays as a cheap first test.
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.
Closes #1361
Summary
githubSlugsets code spans aside with the private-use markers U+E000 and U+E001 and restores them with a regex. A heading that wrote those characters as entities (Use 0) decoded into a fake marker pair, so the slug came out asuse-undefinedinstead ofuse-0.The algorithm is unchanged. The two marker characters are now chosen by trial. Candidates are pairs of private-use characters in U+E000-U+F8FF that pass a cheap pre-filter (absent from the raw heading, its entity-decoded form, and the heading without code spans after
renderPlain). Each pair is tried against the real rendering and accepted only if every marker in the output belongs to a well-formed marker, index, marker match whose index is below the span count and used once, with no stray marker left. The function throws if no pair qualifies. Emphasis, link and HTML handling is byte-identical to before for every heading that does not contain the old markers.Tests
New test in
test/check-doc-refs.test.js: the issue's heading givesuse-0; throughcheckDocRefs,#use-0-barpasses and#use-undefined-barfails. Pinned to the previous outputs:`x`_y_and_x_`y`givexy,Use [link](`target`) `shown`givesuse-link-shown,Use <span title="`hidden`">label</span> `shown`givesuse-label-shown; headings where link or tag stripping reassembles (use-x-labela0for the tag case),0givesuse-x-0; plus literal private-use characters, plain digits and an entity next to a code span.RED on the previous code:
(The reassembly case,
Use [x]() [002](a);0[003](b);expectinguse-x-0, was also RED on the previous commit:use-x-undefined.)GREEN with the fix: check-doc-refs 17/17, check-docs 147/147.
Docs
no docs:
docs/changelog.mddescribes the slug rules (unchanged), not the marker mechanism. No CHANGELOG entry (developer tooling).Residual
A reassembled marker that reuses the index of a span whose own marker was dropped (for example a span inside a removed link destination) would still pass the consistency check. The previous code had the same residual. No heading triggering it was constructed.