Repository navigation
fix(web): preserve Unicode footnotes across Markdown file chunks #48250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
45a1b56
d60e0ca
657de6d
9ca15bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,6 +363,11 @@ function linkDestinationEnd(text: string, start: number): number { | |
| return -1; | ||
| } | ||
|
|
||
| // Mirrors micromark's normalizeIdentifier so chunks match footnotes exactly as one render would. | ||
| function footnoteLabelKey(label: string): string { | ||
| return label.toLowerCase().toUpperCase(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep dotless
This violates the stated requirement to preserve two distinct notes, which the Words transcript also shows. (gist.github.com) Use a renderer-compatible key that preserves this distinction while retaining sigma and sharp-S matching. Update the dotless test row to assert distinct notes rather than equivalence.
|
||
| } | ||
|
|
||
| const TABLE_URI_AUTOLINK = /<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\x00-\x20<>]*>/y; | ||
| const TABLE_EMAIL_AUTOLINK = | ||
| /<[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*>/y; | ||
|
|
@@ -804,7 +809,7 @@ function extractFootnoteRefs( | |
| const isDefAtLineStart = !tableCell && text[j + 1] === ":" && isAtLineStart(i); | ||
| if (!isDefAtLineStart) { | ||
| const label = text.slice(i + 2, j); | ||
| if (definedKeys.has(label.toLowerCase())) { | ||
| if (definedKeys.has(footnoteLabelKey(label))) { | ||
| refs.push(label); | ||
| } | ||
| } | ||
|
|
@@ -895,7 +900,7 @@ function splitMarkdownBlocks( | |
| if (activeFootnoteLabel !== null && activeFootnoteLines !== null) { | ||
| const block = activeFootnoteLines.join("\n").trimEnd(); | ||
| if (footnoteChars + block.length < SHARED_FOOTNOTES_MAX_CHARS) { | ||
| capturedFootnoteKeys.add(activeFootnoteLabel.toLowerCase()); | ||
| capturedFootnoteKeys.add(footnoteLabelKey(activeFootnoteLabel)); | ||
| capturedFootnoteLabels.push(activeFootnoteLabel); | ||
| footnoteDefs.push(block); | ||
| footnoteDefSpans.push([activeFootnoteOffset, block.length]); | ||
|
|
@@ -1057,7 +1062,7 @@ function splitMarkdownBlocks( | |
| mayHaveFootnotes && line.includes("[^") ? FOOTNOTE_DEFINITION_START.exec(line) : null; | ||
| if (fnMatch) { | ||
| const label = fnMatch[1]!; | ||
| const key = label.toLowerCase(); | ||
| const key = footnoteLabelKey(label); | ||
| inFootnoteDef = true; | ||
| if (!seenFootnoteKeys.has(key)) { | ||
| seenFootnoteKeys.add(key); | ||
|
|
@@ -1548,7 +1553,7 @@ export function findFootnoteRefChunkIndex( | |
| const refs = footnotes.chunkRefs[chunkIndex]; | ||
| if (!refs) continue; | ||
| for (const label of refs) { | ||
| const key = label.toLowerCase(); | ||
| const key = footnoteLabelKey(label); | ||
| let num = numberByKey.get(key); | ||
| if (num === undefined) { | ||
| num = nextNumber++; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
src/markdownChunks.ts:368When a label contains dotless
ı,footnoteLabelKeyfolds it toI, so distinct[^ı]and[^i]definitions collapse; split documents then drop one note and route both references to the same footnote number. The final uppercasing merges U+0131 withi; preserveıwhile folding the other characters.🤖 Copy this AI Prompt to have your agent fix this: