Repository navigation
Number footnotes by reference order, and carry source positions - #4
Merged
Merged
Conversation
A footnote marker was rendering the footnote's internal label (the word after the caret) as its visible text, so a reference to [^scripts] showed up as "scripts" jammed onto the end of the sentence instead of a small superscript number. Readers expect the GFM convention: a number assigned by the order each footnote is first referenced, mirrored on the note at the bottom, with a link back to where it was cited. Numbering is done in the existing pre-pass, the same way citations are already numbered, so the inline marker and the definition list can never disagree. The demo theme gains the matching footnote styling it never had. Folded in alongside it: the renderer can now stamp each top-level block with a data-line attribute giving its 1-based source line, gated behind RenderOptions so default output stays byte-identical. The parser captures those lines through directive segmentation and footnote relocation, and the wasm boundary exposes a positions-on entry point. This is what lets an editor map a rendered block back to its source for scroll-sync.
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.
What
Two changes to the renderer, bundled.
Footnotes render as numbers, not labels. A footnote marker was showing the footnote's internal label (the word after the caret), so a reference to
[^scripts]appeared as the word "scripts" stuck onto the end of the sentence instead of a superscript number. Now each footnote gets a number by the order it's first referenced (the GFM convention), the number is mirrored on the note at the bottom, and the note links back to where it was cited. The numbering runs in the existing pre-pass, the same way citations are already numbered, so the inline marker and the bottom list can't disagree. The demo theme gains the footnote styling it never had.Source positions (
data-line). The renderer can now stamp each top-level block with its 1-based source line, gated behindRenderOptionsso default output stays byte-identical. The parser captures those lines through directive segmentation and footnote relocation; the wasm boundary exposes a positions-on entry point. This is the groundwork the editor extension needs to map a rendered block back to its source for scroll-sync.Verification
cargo test --workspacegreen; new tests cover reference-order numbering, the label-never-shown invariant, and the back-link.cargo clippy --workspace --all-targets -D warningsclean;cargo fmt --checkclean.languages.altnumbers 1, 2;cs-lewis.altnumbers 1 to 4, all in reference order.Merging deploys the playground via the Pages workflow.