Read the three directive forms, their attributes and the fences that nest them
CI / gate (push) Successful in 5s
CI / gate (push) Successful in 5s
This commit is contained in:
@@ -7,6 +7,7 @@ import { delimiterFlags, matchEmphasis, runLength } from '../emphasis-matching.t
|
||||
import { failure, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||
import { mergeAdjacentText } from '../../adf/editor-normal.ts'
|
||||
import { normalizeLabel, readInlineTarget, readLabel } from '../link-syntax.ts'
|
||||
import { readInlineDirective, unknownDirectiveFault } from '../directive-syntax.ts'
|
||||
|
||||
export type InlineContent = { image: AdfNode; nodes?: undefined } | { image?: undefined; nodes: AdfNode[] }
|
||||
|
||||
@@ -50,6 +51,12 @@ export function parseInlineContent(source: string, definitions: LinkDefinitions,
|
||||
index = angle.value
|
||||
break
|
||||
}
|
||||
case ':': {
|
||||
const directive = readDirective(scan, index)
|
||||
if (!directive.ok) return directive
|
||||
index = directive.value
|
||||
break
|
||||
}
|
||||
case '!':
|
||||
case '[':
|
||||
index = openBracket(scan, index)
|
||||
@@ -131,6 +138,16 @@ function openBracket(scan: Scan, index: number): number {
|
||||
return index + width
|
||||
}
|
||||
|
||||
function readDirective(scan: Scan, index: number): Result<number> {
|
||||
const directive = readInlineDirective(scan.source, index)
|
||||
if (directive === undefined) {
|
||||
scan.pending += ':'
|
||||
return success(index + 1)
|
||||
}
|
||||
const fault = directive.fault ?? unknownDirectiveFault(directive.value.name)
|
||||
return failure(fault.code, fault.message, scan.path)
|
||||
}
|
||||
|
||||
function flush(scan: Scan, strip: boolean): void {
|
||||
const raw = strip ? scan.pending.replace(trailingSpace, '') : scan.pending
|
||||
scan.pending = ''
|
||||
|
||||
Reference in New Issue
Block a user