fix: separate raised citation markers with a space, not a comma (#23)

This commit was merged in pull request #23.
This commit is contained in:
2026-10-07 08:24:07 +00:00
parent 0705d5ec2f
commit ade6145425
4 changed files with 12 additions and 9 deletions
+4 -4
View File
@@ -127,10 +127,10 @@ describe("linkCitations", () => {
expect(linkCitations("Rain [^1].", sources).text).toBe("Rain [¹](https://first.example).");
});
it("links a list of markers and keeps the comma", () => {
it("separates markers written as one list", () => {
const result = linkCitations("Both [1, 3] agree.", sources);
expect(result.text).toBe("Both [¹](https://first.example), [³](https://third.example) agree.");
expect(result.text).toBe("Both [¹](https://first.example) [³](https://third.example) agree.");
expect([...result.cited].sort()).toEqual([1, 3]);
});
@@ -148,13 +148,13 @@ describe("linkCitations", () => {
// says it is two sources, or where the first one stops and the second begins.
const result = linkCitations("Both [1][3] agree.", sources);
expect(result.text).toBe("Both [¹](https://first.example), [³](https://third.example) agree.");
expect(result.text).toBe("Both [¹](https://first.example) [³](https://third.example) agree.");
expect([...result.cited].sort()).toEqual([1, 3]);
});
it("treats a space between two markers the same way", () => {
expect(linkCitations("Both [1] [3] agree.", sources).text).toBe(
"Both [¹](https://first.example), [³](https://third.example) agree.",
"Both [¹](https://first.example) [³](https://third.example) agree.",
);
});
+4 -2
View File
@@ -228,9 +228,11 @@ export function linkCitations(text: string, sources: Source[]): CitationResult {
}
for (const index of wanted) cited.add(index);
// Separated even when the model wrote them touching: `¹, ²` is two citations,
// Separated even when the model wrote them touching: `¹ ²` is two citations,
// where `¹²` is a number, and the reader has no way to tell it from a real one.
return links.join(", ");
// A space rather than a comma, which sits at the baseline and so drops away from
// digits that are raised above it.
return links.join(" ");
}),
);