Name the position a directive name the other one spells belongs to
CI / gate (push) Successful in 8s

This commit is contained in:
2026-09-01 23:04:23 +02:00
parent 1429f4ce3c
commit 5defa89b8d
7 changed files with 55 additions and 4 deletions
+4 -1
View File
@@ -2,14 +2,17 @@ import type { ConvertFault } from '../result.ts'
import type { DirectiveSpan, Read } from './directive-syntax.ts'
import { spellAttributes, spellLeafDirective, spellStringAttribute } from './directive-syntax.ts'
const name = 'text'
export const textDirectiveName = 'text'
const whitespaceRun = /^(?:[ \t]+|\n+)$/
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)