Repository navigation
fix(markdown): preserve first-reference order for Unicode footnotes - #38
Conversation
PR HealthPublish ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with Breaking changes ✔️
This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with Unused Dependencies ✔️
For details on how to fix these, see dependency_validator. This check can be disabled by tagging the PR with License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
This check can be disabled by tagging the PR with
Coverage
|
| File | Coverage |
|---|---|
| pkgs/markdown/lib/src/document.dart | 💔 96 % ⬇️ 0 % |
This check for test coverage is informational (issues shown here will not fail the PR).
This check can be disabled by tagging the PR with skip-coverage-check.
272c653 to
dfb0714
Compare
Bug
Document._filterFootnotes()builds its ordinal map from the raw (lower-cased) reference labels, keyed asfn-<label>, but looks each definition up by its lower-cased, URI-encoded HTMLid. For any label containing a character thatUri.encodeComponentescapes (Hebrew and other non-ASCII text,\[,%,&, emoji, ...) the keys never match, every such definition gets ordinal 0, and the footnote list falls back to definition order, so its numbering no longer matches the reference numbers in the text.Fix
Look definitions up by
Element.footnoteLabel, lower-cased the same wayFootnoteRefSyntaxnormalizes reference keys. Every emitted definition now has a unique ordinal, so the order no longer depends on sort stability.Tests
\[) referenced second but defined first.Both fail before the fix and pass after it. Existing ASCII case-folding tests are unchanged.
Verification
Output is byte-identical to main for all CommonMark/GFM spec inputs and for every README/CHANGELOG in a local pub cache. In 20,000 fuzzed footnote documents every difference from main is a corrected order (definition N in the list is the one whose reference shows N).