mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 14:45:44 +01:00
Escape a line against the inline reader's own tokens, in time linear in a run
This commit is contained in:
@@ -3,7 +3,7 @@ import test from 'node:test'
|
||||
|
||||
import type { DirectiveAttributes, DirectiveLine } from './directive-syntax.ts'
|
||||
import { largestNesting } from '../nesting.ts'
|
||||
import { readDirectiveLine, readInlineDirective } from './directive-syntax.ts'
|
||||
import { claimsDirectivePrefix, readDirectiveLine, readInlineDirective } from './directive-syntax.ts'
|
||||
|
||||
// A pair the input spells bare decodes to itself; a quoted one names its spelling beside the decoding.
|
||||
type Pair = [string, string, string?]
|
||||
@@ -22,8 +22,8 @@ function fault(line: string): string {
|
||||
}
|
||||
|
||||
function inline(text: string): unknown {
|
||||
if (!claimsDirectivePrefix(text, 0)) return 'unclaimed'
|
||||
const read = readInlineDirective(text, 0)
|
||||
if (read === undefined) return 'unclaimed'
|
||||
if (read.fault !== undefined) return read.fault.message
|
||||
return { attributes: read.value.attributes, content: read.value.content, length: read.value.length, name: read.value.name }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user