From becd7d8d4ed48206d00d05aac3aaab1038893436 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 13:12:57 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=203=20=F0=9F=9F=A1=20(0=20misread);=20the=20destinationEnds=20?= =?UTF-8?q?comment=20names=20a=20stop=20and=20the=20stack,=20the=20changel?= =?UTF-8?q?og=20entry=20says=20neither=20escaped=20nor=20closed,=20the=20t?= =?UTF-8?q?est=20name=20says=20where=20the=20paren=20is=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++--- src/markdown/commonmark/link-syntax.test.ts | 2 +- src/markdown/commonmark/link-syntax.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd5552..14c8f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,9 +55,9 @@ when the label runs over 999 characters, where it read them as a link or a definition. CommonMark caps a label at 999 characters, an escape counting as two. - Every reader leaves a link or a definition literal when its unbracketed destination holds a `(` - that is neither escaped nor closed by a `)` before the space ending the destination, where it - read it as a link: `[a](b(c "t")` is now text, as in CommonMark. Markdown the writers wrote reads - as before, since they escape such a parenthesis. + that is neither escaped nor closed, as CommonMark requires: `[a](b(c "t")` is now text, where it + read as a link to `b(c`. Markdown the writers wrote reads as before, since they escape such a + parenthesis. - The README compares the package with seven other ADF converters, each checked against its published version. diff --git a/src/markdown/commonmark/link-syntax.test.ts b/src/markdown/commonmark/link-syntax.test.ts index 10fc996..7455326 100644 --- a/src/markdown/commonmark/link-syntax.test.ts +++ b/src/markdown/commonmark/link-syntax.test.ts @@ -28,7 +28,7 @@ test('an unbracketed destination ends at its first unmatched `)`', () => { assert.deepEqual(targets('[a](b\\)c)'), [{ destination: 'b)c', length: 6 }]) }) -test('a destination holding an unbalanced unescaped `(` at a space or the end reads as none', () => { +test('an unbracketed destination with an unescaped `(` still open where it stops reads as none', () => { assert.deepEqual(targets('[a](b(c "t")'), [undefined]) assert.deepEqual(targets('[a](b(c "t") [d](e)'), [undefined, { destination: 'e', length: 3 }]) assert.deepEqual(targets('[a](b(c) "t")'), [{ destination: 'b(c)', length: 10, title: 't' }]) diff --git a/src/markdown/commonmark/link-syntax.ts b/src/markdown/commonmark/link-syntax.ts index bcaba70..627d8a9 100644 --- a/src/markdown/commonmark/link-syntax.ts +++ b/src/markdown/commonmark/link-syntax.ts @@ -72,7 +72,7 @@ export function targetMemo(text: string): TargetMemo { return { destinationEnds: undefined, tails: new Map(), text } } -// `ends[start]` is where an unbracketed destination from `start` stops, filled in one pass for every start a target can have: just after a `(`, a space or a control character, and 0, where `readDestination`'s run begins. At a stop only the innermost open start has its parentheses balanced, so the starts below it keep no end. +// `ends[start]` is where an unbracketed destination from `start` stops, for every start a target can have: just after a `(`, a space or a control character, and 0, where `readDestination`'s run begins. A destination stops at a space, a control character or the end of the text. Of the starts on the `open` stack only the innermost has its parentheses balanced there, so every start below it keeps 0, which reads as no destination. function destinationEnds(text: string): Int32Array { const ends = new Int32Array(text.length + 1) let open = [0]