mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-18 22:25:44 +01:00
Answer architecture round 1: the comments the panel found as bare spec pointers state their rule, and the spec cites no plan item
This commit is contained in:
+1
-1
@@ -196,7 +196,7 @@ is the fence.
|
||||
|
||||
CommonMark input may contain raw HTML. `markdownToAdf` routes each construct through the foreign
|
||||
HTML element mapping (`docs/decisions.md` §Foreign HTML sorts three ways; specified with the HTML
|
||||
dialect, `todo.md` item 6) — ADF has no raw-HTML node, so a construct without a mapping, comments
|
||||
dialect) — ADF has no raw-HTML node, so a construct without a mapping, comments
|
||||
and processing instructions included, is an error result naming it. The flavour never emits raw
|
||||
HTML.
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ const bareToken = new RegExp(`^${bareTokenSource}$`)
|
||||
const directiveName = /[a-z][A-Za-z0-9]*/y
|
||||
const inlineDirectiveOpener = new RegExp(`${directivePrefix}[a-z][A-Za-z0-9]*[[{]`, 'y')
|
||||
const lineEnd = /^[ \t]*$/
|
||||
// spec/flavour.md, Attributes.
|
||||
// A quoted value spells these as \uXXXX: CommonMark binds a code span, entity, HTML tag or pipe cell before a directive.
|
||||
const reservedSource = '[&<`|]'
|
||||
const quotedEscapes = new RegExp(reservedSource, 'g')
|
||||
const rawReserved = new RegExp(reservedSource)
|
||||
|
||||
@@ -47,7 +47,7 @@ export function writeMarkdown(document: AdfDocument, flavour: Flavour): Result<s
|
||||
return success(text === '' ? '' : `${text}\n`)
|
||||
}
|
||||
|
||||
// headroom: the least slack any depth guard below the walk has.
|
||||
// headroom: the nesting levels the deepest node below may still spend before the 500-level guard refuses it.
|
||||
function walkBlocks(nodes: readonly AdfNode[], path: ConvertErrorPath, depth: number, writing: Writing): Result<PlacedBlocks> {
|
||||
let headroom = largestNesting - depth
|
||||
if (headroom < 0) return tooDeep(path)
|
||||
|
||||
@@ -130,7 +130,7 @@ function lineVerdict(segments: readonly InlineSegment[], container: LineContaine
|
||||
return run === undefined ? { kind: 'line', text: assembled.line } : { kind: 'unspellable-run', runs: [run, ...others] }
|
||||
}
|
||||
|
||||
// spec/flavour.md, Inline nodes.
|
||||
// A space or tab CommonMark strips at a line edge rides !adf:text{} instead.
|
||||
function spellEdgeWhitespace(segments: readonly InlineSegment[]): InlineSegment[] {
|
||||
const spelled: InlineSegment[] = []
|
||||
for (const [index, segment] of segments.entries()) {
|
||||
@@ -194,7 +194,7 @@ function inlineRuns(nodes: readonly AdfNode[], depth: number, firstIndex: number
|
||||
const runs: InlineRun[] = []
|
||||
for (const [offset, node] of nodes.entries()) {
|
||||
const index = firstIndex + offset
|
||||
// spec/flavour.md, Marks.
|
||||
// `depth` indexes each node's marks, outermost first; a carried node spells its marks inside the carry.
|
||||
const mark = carries(node, carried, index) ? undefined : nodeMarks(node)[depth]
|
||||
if (mark === undefined) {
|
||||
runs.push({ index, kind: 'plain', node })
|
||||
@@ -263,7 +263,7 @@ function emitInlineDirective(node: AdfNode, model: InlineNodeModel, index: numbe
|
||||
return success({ segments: [syntax(spellInlineDirectiveOpener(node.type)), ...content, syntax(`]${attributes}`)] })
|
||||
}
|
||||
|
||||
// spec/flavour.md, Text CommonMark cannot hold plainly.
|
||||
// CommonMark reads a raw carriage return as a line ending and a null character as U+FFFD, so neither is written raw.
|
||||
function emitText(node: AdfNode, context: InlineContext, index: number): Emission {
|
||||
if (!isBareText(node) || typeof node.text !== 'string' || node.text === '') return { carry: { first: index, last: index } }
|
||||
const escaping: InlineEscaping = context.bracketed ? 'bracketed' : 'backslash'
|
||||
|
||||
@@ -15,6 +15,7 @@ export type InlineEscaping = 'backslash' | 'bracketed' | 'bracketed-link-target'
|
||||
|
||||
export type NodeRange = { first: number; last: number }
|
||||
|
||||
// `depth` is the index into each node's marks array that the run spells.
|
||||
export type MarkRun = NodeRange & { depth: number }
|
||||
|
||||
export type InlineSegment =
|
||||
|
||||
Reference in New Issue
Block a user