3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Answer product-owner round 1: 0 🔴, 0 🟡; scope only backtick runs to outside a directive, and name the kept closer codeSpanCloser

This commit is contained in:
2026-10-18 10:52:07 +02:00
committed by Lillem4n
parent 26446c0b89
commit 637fbc914c
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -20,14 +20,14 @@ export type InlineToken =
// A text and what its openers look ahead for, read once, so a walk reading a token at every index stays linear in it.
export type InlineSource = {
readonly closingBacktickRun: (from: number, opener: number) => number | undefined
readonly codeSpanCloser: (from: number, opener: number) => number | undefined
// Each HTML construct terminator's last start in the text, -1 for none, read the first time an opener asks.
readonly terminators: Map<string, number>
readonly text: string
}
export function inlineSource(text: string): InlineSource {
return { closingBacktickRun: backtickCloser(text), terminators: new Map(), text }
return { codeSpanCloser: backtickCloser(text), terminators: new Map(), text }
}
export function readInlineToken(inline: InlineSource, index: number, claims: Claims): InlineToken {
@@ -86,7 +86,7 @@ function angleToken(inline: InlineSource, index: number): InlineToken {
function backtickToken(inline: InlineSource, index: number): InlineToken {
const opener = backtickRun(inline.text, index)
const closer = inline.closingBacktickRun(index + opener, opener)
const closer = inline.codeSpanCloser(index + opener, opener)
return closer === undefined ? text(opener) : { kind: 'code-span', opener, width: closer + opener - index }
}