From 88ec96556c51fab5359f8625aed0c291b9d0d353 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 4 Oct 2026 22:55:08 +0200 Subject: [PATCH] Answer architecture round 1: the comments the panel found as bare spec pointers state their rule, and the spec cites no plan item --- spec/flavour.md | 2 +- src/markdown/directive-syntax.ts | 2 +- src/markdown/emit/adf-to-markdown.ts | 2 +- src/markdown/emit/inline-line.ts | 6 +++--- src/markdown/emit/line-escaping.ts | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/flavour.md b/spec/flavour.md index 7bb2458..41de75c 100644 --- a/spec/flavour.md +++ b/spec/flavour.md @@ -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. diff --git a/src/markdown/directive-syntax.ts b/src/markdown/directive-syntax.ts index 30d205b..c3b6696 100644 --- a/src/markdown/directive-syntax.ts +++ b/src/markdown/directive-syntax.ts @@ -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) diff --git a/src/markdown/emit/adf-to-markdown.ts b/src/markdown/emit/adf-to-markdown.ts index 12cf34d..99d6436 100644 --- a/src/markdown/emit/adf-to-markdown.ts +++ b/src/markdown/emit/adf-to-markdown.ts @@ -47,7 +47,7 @@ export function writeMarkdown(document: AdfDocument, flavour: Flavour): Result { let headroom = largestNesting - depth if (headroom < 0) return tooDeep(path) diff --git a/src/markdown/emit/inline-line.ts b/src/markdown/emit/inline-line.ts index 878c3e7..0950941 100644 --- a/src/markdown/emit/inline-line.ts +++ b/src/markdown/emit/inline-line.ts @@ -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' diff --git a/src/markdown/emit/line-escaping.ts b/src/markdown/emit/line-escaping.ts index 120faf8..d50c4d6 100644 --- a/src/markdown/emit/line-escaping.ts +++ b/src/markdown/emit/line-escaping.ts @@ -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 =