mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-13 04:08:29 +01:00
Answer prose round 1: 0 🔴, 3 🟡 (0 misread); the destinationEnds comment names a stop and the stack, the changelog entry says neither escaped nor closed, the test name says where the paren is open
This commit is contained in:
+3
-3
@@ -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.
|
||||
|
||||
|
||||
@@ -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' }])
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user