Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): preserve Unicode footnotes across Markdown file chunks #48250

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48250/headopened View on GitHub

Showing 2 changed files with 45 additions and 4 deletions.

x
0 of 2 viewed, 2 left
31 additions and 0 deletionspackages/shared/src/markdownChunks.test.tsModified
View file
@@ -868,6 +868,37 @@
expect(findFootnoteRefChunkIndex(footnotes!, 1, 3)).toBeNull();
});
​
+ it.each([
+ { firstLabel: "ς", secondLabel: "Σ", definitionLabel: "σ" },
+ { firstLabel: "ß", secondLabel: "ẞ", definitionLabel: "ss" },
+ ])(
+ "matches footnote citations $firstLabel and $secondLabel to $definitionLabel across chunks",
+ ({ firstLabel, secondLabel, definitionLabel }) => {
+ const definition = `[^${definitionLabel}]: Shared note`;
+ const source = `First[^${firstLabel}] ${"lead ".repeat(900).trimEnd()}\n\n# Second\n\nAgain[^${secondLabel}].\n\n${definition}\n\n[^${secondLabel}]: Duplicate ignored.`;
+ const { chunks, definitions, footnotes } = splitMarkdown(source);
+ expect(chunks).toHaveLength(2);
+ expect(footnotes?.stubs).toBe(`[^${definitionLabel}]: .`);
+ expect(buildMarkdownFootnotesSection(definitions, footnotes)?.text).toBe(
+ `[^${firstLabel}] [^${secondLabel}]\n\n${definition}`,
+ );
+ expect(findFootnoteRefChunkIndex(footnotes!, 1, 1)).toBe(0);
+ expect(findFootnoteRefChunkIndex(footnotes!, 1, 2)).toBe(1);
+ },
+ );
+​
+ it("keeps dotless ı and ASCII I as distinct footnotes across chunks", () => {
+ const source = `First[^ı] ${"lead ".repeat(900).trimEnd()}\n\n# Second\n\nAgain[^I].\n\n[^ı]: Dotless note\n\n[^i]: ASCII note`;
+ const { definitions, footnotes } = splitMarkdown(source);
+ expect(footnotes?.stubs).toBe("[^ı]: .\n[^i]: .");
+ expect(buildMarkdownFootnotesSection(definitions, footnotes)?.text).toBe(
+ "[^ı] [^I]\n\n[^ı]: Dotless note\n\n[^i]: ASCII note",
+ );