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

Answer the stability nits: the spellings a position hint names, and the fault its name owns

This commit is contained in:
2026-09-02 12:28:21 +02:00
parent fdbcbd6fb7
commit a5877a8fd5
5 changed files with 18 additions and 16 deletions
+3 -4
View File
@@ -2,17 +2,16 @@ import type { ConvertFault } from '../result.ts'
import type { DirectiveSpan, Read } from './directive-syntax.ts'
import { spellAttributes, spellLeafDirective, spellStringAttribute } from './directive-syntax.ts'
export const textDirectiveName = 'text'
const name = 'text'
const whitespaceRun = /^(?:[ \t]+|\n+)$/
export const textDirectiveName = name
export function spellTextDirective(text: string): string {
const name = textDirectiveName
return spellLeafDirective(name, spellAttributes([[name, spellStringAttribute(text)]]))
}
export function readTextDirective(span: DirectiveSpan): Read<string> | undefined {
const name = textDirectiveName
if (span.name !== name) return undefined
if (span.content !== undefined) return { fault: unsupported(`${name} takes no content`) }
const spelled = span.attributes.get(name)