21 - the table's row is the node's model, never the node
This commit was merged in pull request #119.
This commit is contained in:
@@ -78,8 +78,8 @@ test("the ADF JSON Schemas hold no type the tables leave unspelled, the pinned c
|
|||||||
|
|
||||||
function spelled(): Spelled[] {
|
function spelled(): Spelled[] {
|
||||||
return [
|
return [
|
||||||
...Object.entries(blockNodes).map(([type, entry]) => spelledType(type, entry.attributes, blockArgument(type))),
|
...Object.entries(blockNodes).map(([type, model]) => spelledType(type, model.attributes, blockArgument(type))),
|
||||||
...Object.entries(inlineNodes).map(([type, entry]) => spelledType(type, entry.attributes)),
|
...Object.entries(inlineNodes).map(([type, model]) => spelledType(type, model.attributes)),
|
||||||
...Object.entries(markAttributes).map(([type, attributes]) => spelledType(type, attributes)),
|
...Object.entries(markAttributes).map(([type, attributes]) => spelledType(type, attributes)),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { AttributeVocabulary } from './attribute-vocabulary.ts'
|
import type { AttributeVocabulary } from './attribute-vocabulary.ts'
|
||||||
|
|
||||||
export type BlockNode = {
|
export type BlockNodeModel = {
|
||||||
attributes: AttributeVocabulary
|
attributes: AttributeVocabulary
|
||||||
contentModel: 'block' | 'code' | 'inline' | 'none'
|
contentModel: 'block' | 'code' | 'inline' | 'none'
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ export const blockNodes = {
|
|||||||
tableRow: { attributes: localIdAttributes, contentModel: 'block' },
|
tableRow: { attributes: localIdAttributes, contentModel: 'block' },
|
||||||
taskItem: { attributes: localIdAttributes, contentModel: 'inline' },
|
taskItem: { attributes: localIdAttributes, contentModel: 'inline' },
|
||||||
taskList: { attributes: localIdAttributes, contentModel: 'block' },
|
taskList: { attributes: localIdAttributes, contentModel: 'block' },
|
||||||
} satisfies Readonly<Record<string, BlockNode>>
|
} satisfies Readonly<Record<string, BlockNodeModel>>
|
||||||
|
|
||||||
export type BlockType = keyof typeof blockNodes
|
export type BlockType = keyof typeof blockNodes
|
||||||
|
|
||||||
export function blockNodeNamed(type: string): BlockNode | undefined {
|
export function blockNodeModel(type: string): BlockNodeModel | undefined {
|
||||||
return isBlockType(type) ? blockNodes[type] : undefined
|
return isBlockType(type) ? blockNodes[type] : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import type { AttributeVocabulary } from './attribute-vocabulary.ts'
|
import type { AttributeVocabulary } from './attribute-vocabulary.ts'
|
||||||
|
|
||||||
export type InlineNode = {
|
export type InlineNodeModel = {
|
||||||
attributes: AttributeVocabulary
|
attributes: AttributeVocabulary
|
||||||
textAttribute?: string
|
textAttribute?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inlineNodes: Readonly<Record<string, InlineNode>> = {
|
export const inlineNodes: Readonly<Record<string, InlineNodeModel>> = {
|
||||||
date: { attributes: { localId: 'string', timestamp: 'string' } },
|
date: { attributes: { localId: 'string', timestamp: 'string' } },
|
||||||
emoji: { attributes: { id: 'string', localId: 'string', shortName: 'string', text: 'string' }, textAttribute: 'text' },
|
emoji: { attributes: { id: 'string', localId: 'string', shortName: 'string', text: 'string' }, textAttribute: 'text' },
|
||||||
hardBreak: { attributes: { localId: 'string', text: 'string' } },
|
hardBreak: { attributes: { localId: 'string', text: 'string' } },
|
||||||
@@ -27,6 +27,6 @@ export const inlineNodes: Readonly<Record<string, InlineNode>> = {
|
|||||||
status: { attributes: { color: 'string', localId: 'string', style: 'string', text: 'string' }, textAttribute: 'text' },
|
status: { attributes: { color: 'string', localId: 'string', style: 'string', text: 'string' }, textAttribute: 'text' },
|
||||||
}
|
}
|
||||||
|
|
||||||
export function inlineNodeNamed(type: string): InlineNode | undefined {
|
export function inlineNodeModel(type: string): InlineNodeModel | undefined {
|
||||||
return Object.hasOwn(inlineNodes, type) ? inlineNodes[type] : undefined
|
return Object.hasOwn(inlineNodes, type) ? inlineNodes[type] : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const fixpointFloor = 600
|
|||||||
const gateRuns = 1000
|
const gateRuns = 1000
|
||||||
const markdownMarkTypes = new Set(Object.keys(markAttributes).filter((type) => markSpelling(type)?.kind !== 'directive'))
|
const markdownMarkTypes = new Set(Object.keys(markAttributes).filter((type) => markSpelling(type)?.kind !== 'directive'))
|
||||||
|
|
||||||
const vocabularies = [...Object.values(blockNodes).map((blockNode) => blockNode.attributes), ...Object.values(inlineNodes).map((inlineNode) => inlineNode.attributes), ...Object.values(markAttributes)]
|
const vocabularies = [...Object.values(blockNodes).map((model) => model.attributes), ...Object.values(inlineNodes).map((model) => model.attributes), ...Object.values(markAttributes)]
|
||||||
const attributeKeys = [
|
const attributeKeys = [
|
||||||
...new Set([...vocabularies.flatMap((vocabulary) => Object.keys(vocabulary)), ...Object.keys(blockNodes).flatMap((type) => blockArgument(type) ?? []), marksAttribute, 'json', textDirectiveName]),
|
...new Set([...vocabularies.flatMap((vocabulary) => Object.keys(vocabulary)), ...Object.keys(blockNodes).flatMap((type) => blockArgument(type) ?? []), marksAttribute, 'json', textDirectiveName]),
|
||||||
]
|
]
|
||||||
@@ -233,9 +233,9 @@ function inlineMarkdown(hostile: boolean): InlineMarkdown {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
arbitrary: fc.oneof(
|
arbitrary: fc.oneof(
|
||||||
...Object.entries(inlineNodes).map(([name, inlineNode]) =>
|
...Object.entries(inlineNodes).map(([name, model]) =>
|
||||||
fc
|
fc
|
||||||
.tuple(inlineNode.textAttribute === undefined ? fc.constant(null) : fc.option(hostile ? word : prose), tableAttributes(inlineNode.attributes, inlineNode.textAttribute))
|
.tuple(model.textAttribute === undefined ? fc.constant(null) : fc.option(hostile ? word : prose), tableAttributes(model.attributes, model.textAttribute))
|
||||||
.map(([slot, attrs]) => (slot === null ? spellInlineLeafDirective(name, attrs) : `${spellInlineDirectiveOpener(name)}${slot}]${attrs}`)),
|
.map(([slot, attrs]) => (slot === null ? spellInlineLeafDirective(name, attrs) : `${spellInlineDirectiveOpener(name)}${slot}]${attrs}`)),
|
||||||
),
|
),
|
||||||
...Object.entries(markAttributes)
|
...Object.entries(markAttributes)
|
||||||
@@ -328,15 +328,15 @@ function blockMarkdown(hostile: boolean, { inlines, oneLine }: InlineMarkdown, {
|
|||||||
const blockDepth = fc.createDepthIdentifier()
|
const blockDepth = fc.createDepthIdentifier()
|
||||||
const { blocks } = fc.letrec<{ block: string; blocks: string }>((tie) => {
|
const { blocks } = fc.letrec<{ block: string; blocks: string }>((tie) => {
|
||||||
const bodyByModel = { block: fc.oneof(tie('blocks'), fc.constant('')), code: fencedCode, inline: fc.oneof(oneLine, fc.constant('')) }
|
const bodyByModel = { block: fc.oneof(tie('blocks'), fc.constant('')), code: fencedCode, inline: fc.oneof(oneLine, fc.constant('')) }
|
||||||
const tableDirectives = Object.entries(blockNodes).map(([name, blockNode]) => {
|
const tableDirectives = Object.entries(blockNodes).map(([name, model]) => {
|
||||||
const argument =
|
const argument =
|
||||||
blockArgument(name) === undefined
|
blockArgument(name) === undefined
|
||||||
? fc.constant(undefined)
|
? fc.constant(undefined)
|
||||||
: fc.oneof({ arbitrary: fc.constantFrom('DONE', 'TODO', 'custom', 'info', 'warning'), weight: 3 }, { arbitrary: bareToken, weight: 1 })
|
: fc.oneof({ arbitrary: fc.constantFrom('DONE', 'TODO', 'custom', 'info', 'warning'), weight: 3 }, { arbitrary: bareToken, weight: 1 })
|
||||||
const attrs = hostile ? fc.oneof({ arbitrary: tableAttributes(blockNode.attributes), weight: 4 }, { arbitrary: hostileAttributes, weight: 1 }) : tableAttributes(blockNode.attributes)
|
const attrs = hostile ? fc.oneof({ arbitrary: tableAttributes(model.attributes), weight: 4 }, { arbitrary: hostileAttributes, weight: 1 }) : tableAttributes(model.attributes)
|
||||||
if (blockNode.contentModel === 'none') return fc.tuple(argument, attrs).map(([held, spelled]) => spellDirectiveOpener(name, held, spelled))
|
if (model.contentModel === 'none') return fc.tuple(argument, attrs).map(([held, spelled]) => spellDirectiveOpener(name, held, spelled))
|
||||||
return fc
|
return fc
|
||||||
.tuple(argument, attrs, bodyByModel[blockNode.contentModel], hostile ? closerDrift : fc.constant(null))
|
.tuple(argument, attrs, bodyByModel[model.contentModel], hostile ? closerDrift : fc.constant(null))
|
||||||
.map(([held, spelled, body, closer]) => container(spellDirectiveOpener(name, held, spelled), body, closer ?? spellDirectiveCloser(name)))
|
.map(([held, spelled, body, closer]) => container(spellDirectiveOpener(name, held, spelled), body, closer ?? spellDirectiveCloser(name)))
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { blockNodeNamed } from '../adf/block-nodes.ts'
|
import { blockNodeModel } from '../adf/block-nodes.ts'
|
||||||
import { listBreakName } from './list-break.ts'
|
import { listBreakName } from './list-break.ts'
|
||||||
|
|
||||||
export function blockDirectiveForm(name: string): 'container' | 'leaf' | undefined {
|
export function blockDirectiveForm(name: string): 'container' | 'leaf' | undefined {
|
||||||
if (name === listBreakName) return 'leaf'
|
if (name === listBreakName) return 'leaf'
|
||||||
const blockNode = blockNodeNamed(name)
|
const model = blockNodeModel(name)
|
||||||
if (blockNode === undefined) return undefined
|
if (model === undefined) return undefined
|
||||||
return blockNode.contentModel === 'none' ? 'leaf' : 'container'
|
return model.contentModel === 'none' ? 'leaf' : 'container'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import type { AdfDocument, AdfNode } from '../../adf/document.ts'
|
import type { AdfDocument, AdfNode } from '../../adf/document.ts'
|
||||||
import type { BlockNode } from '../../adf/block-nodes.ts'
|
import type { BlockNodeModel } from '../../adf/block-nodes.ts'
|
||||||
import { adfDocumentFault, carriesOnly, nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts'
|
import { adfDocumentFault, carriesOnly, nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts'
|
||||||
import { blockDirectiveForm } from '../block-directive-forms.ts'
|
import { blockDirectiveForm } from '../block-directive-forms.ts'
|
||||||
import { blockNodeNamed, blockNodes } from '../../adf/block-nodes.ts'
|
import { blockNodeModel, blockNodes } from '../../adf/block-nodes.ts'
|
||||||
import { carriedBlock } from '../opaque-carry.ts'
|
import { carriedBlock } from '../opaque-carry.ts'
|
||||||
import { emitInlineLine } from './inline-line.ts'
|
import { emitInlineLine } from './inline-line.ts'
|
||||||
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||||
@@ -87,11 +87,11 @@ function interruptsParagraph(node: AdfNode): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function emitBlock(node: AdfNode, path: ConvertErrorPath, depth: number, memo: SpellingMemo | undefined): Result<EmittedBlock> {
|
function emitBlock(node: AdfNode, path: ConvertErrorPath, depth: number, memo: SpellingMemo | undefined): Result<EmittedBlock> {
|
||||||
const blockNode = blockNodeNamed(node.type)
|
const model = blockNodeModel(node.type)
|
||||||
if (blockNode === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
if (model === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
||||||
const readable = readableBlock(node, path, depth, memo)
|
const readable = readableBlock(node, path, depth, memo)
|
||||||
if (readable !== undefined) return readable
|
if (readable !== undefined) return readable
|
||||||
return emitDirectiveBlock(node, blockNode, path, depth, () => walkBlocks(nodeContent(node), path, depth + 1, memo))
|
return emitDirectiveBlock(node, model, path, depth, () => walkBlocks(nodeContent(node), path, depth + 1, memo))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function commonMarkSpelling(node: AdfNode, path: ConvertErrorPath, depth: number, memo: SpellingMemo): Result<null> | undefined {
|
export function commonMarkSpelling(node: AdfNode, path: ConvertErrorPath, depth: number, memo: SpellingMemo): Result<null> | undefined {
|
||||||
@@ -143,18 +143,18 @@ function directivePair(node: AdfNode, opener: string, body: string, headroom: nu
|
|||||||
return { headroom, spelling: 'directive', text: `${opener}\n${body === '' ? '' : `${body}\n`}${spellDirectiveCloser(node.type)}` }
|
return { headroom, spelling: 'directive', text: `${opener}\n${body === '' ? '' : `${body}\n`}${spellDirectiveCloser(node.type)}` }
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitDirectiveBlock(node: AdfNode, blockNode: BlockNode, path: ConvertErrorPath, depth: number, walkBody: () => Result<Walk>): Result<EmittedBlock> {
|
function emitDirectiveBlock(node: AdfNode, model: BlockNodeModel, path: ConvertErrorPath, depth: number, walkBody: () => Result<Walk>): Result<EmittedBlock> {
|
||||||
if (node.text !== undefined) return failure('unsupported-node-shape', `a ${node.type} carries no text: this one holds text`, path)
|
if (node.text !== undefined) return failure('unsupported-node-shape', `a ${node.type} carries no text: this one holds text`, path)
|
||||||
if (blockDirectiveForm(node.type) === 'leaf' && nodeContent(node).length > 0) return failure('unsupported-node-shape', `a ${node.type} holds no content: this one holds some`, path)
|
if (blockDirectiveForm(node.type) === 'leaf' && nodeContent(node).length > 0) return failure('unsupported-node-shape', `a ${node.type} holds no content: this one holds some`, path)
|
||||||
if (blockNode.contentModel === 'code') return emitCodeDirective(node, blockNode, path, depth)
|
if (model.contentModel === 'code') return emitCodeDirective(node, model, path, depth)
|
||||||
const opener = spellBlockDirectiveOpener(node, blockNode)
|
const opener = spellBlockDirectiveOpener(node, model)
|
||||||
if (opener === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
if (opener === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
||||||
return emitDirectiveBody(node, blockNode, opener, path, walkBody)
|
return emitDirectiveBody(node, model, opener, path, walkBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitDirectiveBody(node: AdfNode, blockNode: BlockNode, opener: string, path: ConvertErrorPath, walkBody: () => Result<Walk>): Result<EmittedBlock> {
|
function emitDirectiveBody(node: AdfNode, model: BlockNodeModel, opener: string, path: ConvertErrorPath, walkBody: () => Result<Walk>): Result<EmittedBlock> {
|
||||||
if (blockDirectiveForm(node.type) === 'leaf') return success({ headroom: Number.POSITIVE_INFINITY, spelling: 'directive', text: opener })
|
if (blockDirectiveForm(node.type) === 'leaf') return success({ headroom: Number.POSITIVE_INFINITY, spelling: 'directive', text: opener })
|
||||||
if (blockNode.contentModel === 'inline') {
|
if (model.contentModel === 'inline') {
|
||||||
const line = emitInlineLine(nodeContent(node), 'paragraph', path)
|
const line = emitInlineLine(nodeContent(node), 'paragraph', path)
|
||||||
if (!line.ok) return line
|
if (!line.ok) return line
|
||||||
return success(directivePair(node, opener, line.value))
|
return success(directivePair(node, opener, line.value))
|
||||||
@@ -184,9 +184,9 @@ function tryCodeBlock(node: AdfNode, path: ConvertErrorPath): Result<EmittedBloc
|
|||||||
return success(commonMarkText(fencedCodeBlock(slot.kind === 'fence' ? slot.info : '', text.value)))
|
return success(commonMarkText(fencedCodeBlock(slot.kind === 'fence' ? slot.info : '', text.value)))
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitCodeDirective(node: AdfNode, blockNode: BlockNode, path: ConvertErrorPath, depth: number): Result<EmittedBlock> {
|
function emitCodeDirective(node: AdfNode, model: BlockNodeModel, path: ConvertErrorPath, depth: number): Result<EmittedBlock> {
|
||||||
const slot = languageSlot(nodeAttrs(node)['language'])
|
const slot = languageSlot(nodeAttrs(node)['language'])
|
||||||
const opener = spellBlockDirectiveOpener(node, blockNode, slot.kind === 'attribute' ? [] : ['language'])
|
const opener = spellBlockDirectiveOpener(node, model, slot.kind === 'attribute' ? [] : ['language'])
|
||||||
if (opener === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
if (opener === undefined) return commonMarkLine(carriedBlock(node, path, depth))
|
||||||
const text = codeBlockText(node, path)
|
const text = codeBlockText(node, path)
|
||||||
if (!text.ok) return text
|
if (!text.ok) return text
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import type { AdfNode } from '../../adf/document.ts'
|
import type { AdfNode } from '../../adf/document.ts'
|
||||||
import type { BlockNode } from '../../adf/block-nodes.ts'
|
import type { BlockNodeModel } from '../../adf/block-nodes.ts'
|
||||||
import { blockArgument } from '../block-directive-arguments.ts'
|
import { blockArgument } from '../block-directive-arguments.ts'
|
||||||
import { isBareToken, spellAttributes, spellDirectiveOpener, spellJsonAttribute, spellVocabulary } from '../directive-syntax.ts'
|
import { isBareToken, spellAttributes, spellDirectiveOpener, spellJsonAttribute, spellVocabulary } from '../directive-syntax.ts'
|
||||||
import { markValues, marksAttribute } from '../block-directive-marks.ts'
|
import { markValues, marksAttribute } from '../block-directive-marks.ts'
|
||||||
import { nodeAttrs, nodeMarks } from '../../adf/document.ts'
|
import { nodeAttrs, nodeMarks } from '../../adf/document.ts'
|
||||||
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
|
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
|
||||||
|
|
||||||
export function spellBlockDirectiveOpener(node: AdfNode, blockNode: BlockNode, spelledByBody: readonly string[] = []): string | undefined {
|
export function spellBlockDirectiveOpener(node: AdfNode, model: BlockNodeModel, spelledByBody: readonly string[] = []): string | undefined {
|
||||||
const argumentAttribute = blockArgument(node.type)
|
const argumentAttribute = blockArgument(node.type)
|
||||||
const slot = bareArgument(node, argumentAttribute)
|
const slot = bareArgument(node, argumentAttribute)
|
||||||
if (slot === undefined) return undefined
|
if (slot === undefined) return undefined
|
||||||
const spelled = argumentAttribute === undefined ? spelledByBody : [argumentAttribute, ...spelledByBody]
|
const spelled = argumentAttribute === undefined ? spelledByBody : [argumentAttribute, ...spelledByBody]
|
||||||
const pairs = vocabularyPairs(nodeAttrs(node), blockNode.attributes, spelled)
|
const pairs = vocabularyPairs(nodeAttrs(node), model.attributes, spelled)
|
||||||
if (pairs === undefined) return undefined
|
if (pairs === undefined) return undefined
|
||||||
const spelledPairs = spellVocabulary(pairs)
|
const spelledPairs = spellVocabulary(pairs)
|
||||||
const marks = nodeMarks(node)
|
const marks = nodeMarks(node)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import type { AdfNode } from '../../adf/document.ts'
|
import type { AdfNode } from '../../adf/document.ts'
|
||||||
import type { InlineNode } from '../../adf/inline-nodes.ts'
|
import type { InlineNodeModel } from '../../adf/inline-nodes.ts'
|
||||||
import { nodeAttrs } from '../../adf/document.ts'
|
import { nodeAttrs } from '../../adf/document.ts'
|
||||||
import { spellAttributes, spellVocabulary } from '../directive-syntax.ts'
|
import { spellAttributes, spellVocabulary } from '../directive-syntax.ts'
|
||||||
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
|
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
|
||||||
|
|
||||||
export function spellInlineNodeAttributes(node: AdfNode, inlineNode: InlineNode): string | undefined {
|
export function spellInlineNodeAttributes(node: AdfNode, model: InlineNodeModel): string | undefined {
|
||||||
const pairs = vocabularyPairs(nodeAttrs(node), inlineNode.attributes, inlineNode.textAttribute === undefined ? [] : [inlineNode.textAttribute])
|
const pairs = vocabularyPairs(nodeAttrs(node), model.attributes, model.textAttribute === undefined ? [] : [model.textAttribute])
|
||||||
return pairs === undefined ? undefined : spellAttributes(spellVocabulary(pairs))
|
return pairs === undefined ? undefined : spellAttributes(spellVocabulary(pairs))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import type { AdfMark, AdfNode } from '../../adf/document.ts'
|
import type { AdfMark, AdfNode } from '../../adf/document.ts'
|
||||||
import type { InlineNode } from '../../adf/inline-nodes.ts'
|
import type { InlineNodeModel } from '../../adf/inline-nodes.ts'
|
||||||
import { assembleInlineLine, isSyntax, type InlineEscaping, type InlineSegment, type LineContainer, type NodeRange } from './line-escaping.ts'
|
import { assembleInlineLine, isSyntax, type InlineEscaping, type InlineSegment, type LineContainer, type NodeRange } from './line-escaping.ts'
|
||||||
import { carriedInline } from '../opaque-carry.ts'
|
import { carriedInline } from '../opaque-carry.ts'
|
||||||
import { claimsLine, holdsNullCharacter, trimTrailingSpace } from '../commonmark/grammar.ts'
|
import { claimsLine, holdsNullCharacter, trimTrailingSpace } from '../commonmark/grammar.ts'
|
||||||
import { commonMarkLink, linkHref, markSpelling, spellMarkAttributes } from '../mark-spellings.ts'
|
import { commonMarkLink, linkHref, markSpelling, spellMarkAttributes } from '../mark-spellings.ts'
|
||||||
import { escapeUnbalanced, spellDestination } from '../commonmark/link-syntax.ts'
|
import { escapeUnbalanced, spellDestination } from '../commonmark/link-syntax.ts'
|
||||||
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||||
import { inlineNodeNamed } from '../../adf/inline-nodes.ts'
|
import { inlineNodeModel } from '../../adf/inline-nodes.ts'
|
||||||
import { largestNesting } from '../../nesting.ts'
|
import { largestNesting } from '../../nesting.ts'
|
||||||
import { longestBacktickRun } from '../commonmark/backtick-runs.ts'
|
import { longestBacktickRun } from '../commonmark/backtick-runs.ts'
|
||||||
import { nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts'
|
import { nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts'
|
||||||
@@ -196,7 +196,7 @@ function nodePath(context: InlineContext, index: number): ConvertErrorPath {
|
|||||||
|
|
||||||
function carries(node: AdfNode, carried: ReadonlySet<number>, index: number): boolean {
|
function carries(node: AdfNode, carried: ReadonlySet<number>, index: number): boolean {
|
||||||
if (carried.has(index)) return true
|
if (carried.has(index)) return true
|
||||||
return node.type !== 'text' && inlineNodeNamed(node.type) === undefined
|
return node.type !== 'text' && inlineNodeModel(node.type) === undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitLeaf(node: AdfNode, context: InlineContext, index: number): Result<Emission> {
|
function emitLeaf(node: AdfNode, context: InlineContext, index: number): Result<Emission> {
|
||||||
@@ -208,27 +208,27 @@ function emitLeaf(node: AdfNode, context: InlineContext, index: number): Result<
|
|||||||
}
|
}
|
||||||
const types = nodeMarks(node).map((mark) => mark.type)
|
const types = nodeMarks(node).map((mark) => mark.type)
|
||||||
if (new Set(types).size !== types.length) return failure('unsupported-node-shape', `a ${node.type} node carries one mark type twice`, path)
|
if (new Set(types).size !== types.length) return failure('unsupported-node-shape', `a ${node.type} node carries one mark type twice`, path)
|
||||||
const inlineNode = inlineNodeNamed(node.type)
|
const model = inlineNodeModel(node.type)
|
||||||
if (inlineNode === undefined) return emitText(node, context, index, path)
|
if (model === undefined) return emitText(node, context, index, path)
|
||||||
if (node.type === 'hardBreak') return emitHardBreak(node, inlineNode, context, index, path)
|
if (node.type === 'hardBreak') return emitHardBreak(node, model, context, index, path)
|
||||||
return emitInlineDirective(node, inlineNode, index, path)
|
return emitInlineDirective(node, model, index, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitHardBreak(node: AdfNode, inlineNode: InlineNode, context: InlineContext, index: number, path: ConvertErrorPath): Result<Emission> {
|
function emitHardBreak(node: AdfNode, model: InlineNodeModel, context: InlineContext, index: number, path: ConvertErrorPath): Result<Emission> {
|
||||||
const empty = refuseContentAndText(node, path)
|
const empty = refuseContentAndText(node, path)
|
||||||
if (!empty.ok) return empty
|
if (!empty.ok) return empty
|
||||||
const attributes = spellInlineNodeAttributes(node, inlineNode)
|
const attributes = spellInlineNodeAttributes(node, model)
|
||||||
if (attributes === undefined) return success({ carry: { first: index, last: index } })
|
if (attributes === undefined) return success({ carry: { first: index, last: index } })
|
||||||
if (attributes === '' && context.spansLines && !context.atBlockEnd) return success({ segments: [syntax('\\\n')] })
|
if (attributes === '' && context.spansLines && !context.atBlockEnd) return success({ segments: [syntax('\\\n')] })
|
||||||
return success({ segments: [syntax(spellInlineLeafDirective('hardBreak', attributes))] })
|
return success({ segments: [syntax(spellInlineLeafDirective('hardBreak', attributes))] })
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitInlineDirective(node: AdfNode, inlineNode: InlineNode, index: number, path: ConvertErrorPath): Result<Emission> {
|
function emitInlineDirective(node: AdfNode, model: InlineNodeModel, index: number, path: ConvertErrorPath): Result<Emission> {
|
||||||
const empty = refuseContentAndText(node, path)
|
const empty = refuseContentAndText(node, path)
|
||||||
if (!empty.ok) return empty
|
if (!empty.ok) return empty
|
||||||
const attributes = spellInlineNodeAttributes(node, inlineNode)
|
const attributes = spellInlineNodeAttributes(node, model)
|
||||||
if (attributes === undefined) return success({ carry: { first: index, last: index } })
|
if (attributes === undefined) return success({ carry: { first: index, last: index } })
|
||||||
const slot = inlineNode.textAttribute === undefined ? undefined : nodeAttrs(node)[inlineNode.textAttribute]
|
const slot = model.textAttribute === undefined ? undefined : nodeAttrs(node)[model.textAttribute]
|
||||||
if (slot === undefined) return success({ segments: [syntax(spellInlineLeafDirective(node.type, attributes))] })
|
if (slot === undefined) return success({ segments: [syntax(spellInlineLeafDirective(node.type, attributes))] })
|
||||||
if (typeof slot !== 'string') return success({ carry: { first: index, last: index } })
|
if (typeof slot !== 'string') return success({ carry: { first: index, last: index } })
|
||||||
const spans = slotLineEndingFault(node.type, slot)
|
const spans = slotLineEndingFault(node.type, slot)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { AdfAttributes, AdfMark, AdfNode } from '../../adf/document.ts'
|
import type { AdfAttributes, AdfMark, AdfNode } from '../../adf/document.ts'
|
||||||
import type { BlockNode } from '../../adf/block-nodes.ts'
|
import type { BlockNodeModel } from '../../adf/block-nodes.ts'
|
||||||
import type { ConvertFault } from '../../result.ts'
|
import type { ConvertFault } from '../../result.ts'
|
||||||
import type { DirectiveAttributes, DirectiveValue } from '../directive-syntax.ts'
|
import type { DirectiveAttributes, DirectiveValue } from '../directive-syntax.ts'
|
||||||
import type { Elsewhere } from './directive-attributes.ts'
|
import type { Elsewhere } from './directive-attributes.ts'
|
||||||
@@ -7,17 +7,17 @@ import { attributeNestingMessage, nodeAttrs, nodeContent, nodeMarks } from '../.
|
|||||||
import { attributeValue, directivePrefix, spellAttributeValue, unknownDirectiveFault } from '../directive-syntax.ts'
|
import { attributeValue, directivePrefix, spellAttributeValue, unknownDirectiveFault } from '../directive-syntax.ts'
|
||||||
import { blockArgument } from '../block-directive-arguments.ts'
|
import { blockArgument } from '../block-directive-arguments.ts'
|
||||||
import { blockDirectiveForm } from '../block-directive-forms.ts'
|
import { blockDirectiveForm } from '../block-directive-forms.ts'
|
||||||
import { blockNodeNamed } from '../../adf/block-nodes.ts'
|
import { blockNodeModel } from '../../adf/block-nodes.ts'
|
||||||
import { carryName } from '../opaque-carry.ts'
|
import { carryName } from '../opaque-carry.ts'
|
||||||
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||||
import { inlineMarkSpellingFault } from './directive-marks.ts'
|
import { inlineMarkSpellingFault } from './directive-marks.ts'
|
||||||
import { inlineNodeNamed } from '../../adf/inline-nodes.ts'
|
import { inlineNodeModel } from '../../adf/inline-nodes.ts'
|
||||||
import { marksAttribute, readMarkValues } from '../block-directive-marks.ts'
|
import { marksAttribute, readMarkValues } from '../block-directive-marks.ts'
|
||||||
import { readVocabulary } from './directive-attributes.ts'
|
import { readVocabulary } from './directive-attributes.ts'
|
||||||
import { slotLineEndingFault } from '../directive-syntax.ts'
|
import { slotLineEndingFault } from '../directive-syntax.ts'
|
||||||
import { textDirectiveName } from '../text-directive.ts'
|
import { textDirectiveName } from '../text-directive.ts'
|
||||||
|
|
||||||
export type BlockDirectiveNode = { contentModel: BlockNode['contentModel']; node: AdfNode }
|
export type BlockDirectiveNode = { contentModel: BlockNodeModel['contentModel']; node: AdfNode }
|
||||||
|
|
||||||
export function readBlockDirectiveNode(
|
export function readBlockDirectiveNode(
|
||||||
name: string,
|
name: string,
|
||||||
@@ -28,13 +28,13 @@ export function readBlockDirectiveNode(
|
|||||||
if (name === carryName) {
|
if (name === carryName) {
|
||||||
return failure('malformed-directive', `the name ${carryName} is reserved for the opaque carry, whose block form is the ${carryName} fence`, path)
|
return failure('malformed-directive', `the name ${carryName} is reserved for the opaque carry, whose block form is the ${carryName} fence`, path)
|
||||||
}
|
}
|
||||||
const blockNode = blockNodeNamed(name)
|
const model = blockNodeModel(name)
|
||||||
if (blockNode === undefined) return faulted(inlineSpellingFault(name) ?? unknownDirectiveFault(name), path)
|
if (model === undefined) return faulted(inlineSpellingFault(name) ?? unknownDirectiveFault(name), path)
|
||||||
const argumentKey = blockArgument(name)
|
const argumentKey = blockArgument(name)
|
||||||
const rest = new Map(attributes)
|
const rest = new Map(attributes)
|
||||||
rest.delete(marksAttribute)
|
rest.delete(marksAttribute)
|
||||||
const elsewhere: Elsewhere | undefined = argumentKey === undefined ? undefined : { key: argumentKey, slot: 'argument' }
|
const elsewhere: Elsewhere | undefined = argumentKey === undefined ? undefined : { key: argumentKey, slot: 'argument' }
|
||||||
const attrs = readVocabulary(name, rest, blockNode.attributes, elsewhere, path)
|
const attrs = readVocabulary(name, rest, model.attributes, elsewhere, path)
|
||||||
if (!attrs.ok) return attrs
|
if (!attrs.ok) return attrs
|
||||||
if (argument !== undefined) {
|
if (argument !== undefined) {
|
||||||
if (argumentKey === undefined) return failure('unsupported-node-shape', `${name} takes no argument: this one spells one`, path)
|
if (argumentKey === undefined) return failure('unsupported-node-shape', `${name} takes no argument: this one spells one`, path)
|
||||||
@@ -43,7 +43,7 @@ export function readBlockDirectiveNode(
|
|||||||
const spelled = attributes.get(marksAttribute)
|
const spelled = attributes.get(marksAttribute)
|
||||||
const marks: Result<AdfMark[] | undefined> = spelled === undefined ? success(undefined) : readMarks(name, spelled, path)
|
const marks: Result<AdfMark[] | undefined> = spelled === undefined ? success(undefined) : readMarks(name, spelled, path)
|
||||||
if (!marks.ok) return marks
|
if (!marks.ok) return marks
|
||||||
return success({ contentModel: blockNode.contentModel, node: namedNode(name, attrs.value, marks.value) })
|
return success({ contentModel: model.contentModel, node: namedNode(name, attrs.value, marks.value) })
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readInlineDirectiveNode(
|
export function readInlineDirectiveNode(
|
||||||
@@ -52,12 +52,12 @@ export function readInlineDirectiveNode(
|
|||||||
content: readonly AdfNode[] | undefined,
|
content: readonly AdfNode[] | undefined,
|
||||||
path: ConvertErrorPath,
|
path: ConvertErrorPath,
|
||||||
): Result<AdfNode> {
|
): Result<AdfNode> {
|
||||||
const inlineNode = inlineNodeNamed(name)
|
const model = inlineNodeModel(name)
|
||||||
if (inlineNode === undefined) return faulted(blockSpellingFault(name) ?? unknownDirectiveFault(name), path)
|
if (model === undefined) return faulted(blockSpellingFault(name) ?? unknownDirectiveFault(name), path)
|
||||||
const slot = inlineNode.textAttribute
|
const slot = model.textAttribute
|
||||||
if (slot === undefined && content !== undefined) return failure('unsupported-node-shape', `${name} takes no content: this one holds some`, path)
|
if (slot === undefined && content !== undefined) return failure('unsupported-node-shape', `${name} takes no content: this one holds some`, path)
|
||||||
const elsewhere: Elsewhere | undefined = slot === undefined ? undefined : { key: slot, slot: 'content' }
|
const elsewhere: Elsewhere | undefined = slot === undefined ? undefined : { key: slot, slot: 'content' }
|
||||||
const attrs = readVocabulary(name, attributes, inlineNode.attributes, elsewhere, path)
|
const attrs = readVocabulary(name, attributes, model.attributes, elsewhere, path)
|
||||||
if (!attrs.ok) return attrs
|
if (!attrs.ok) return attrs
|
||||||
if (slot !== undefined && content !== undefined) {
|
if (slot !== undefined && content !== undefined) {
|
||||||
const text = slotText(content)
|
const text = slotText(content)
|
||||||
@@ -75,7 +75,7 @@ export function readInlineDirectiveNode(
|
|||||||
function inlineSpellingFault(name: string): ConvertFault | undefined {
|
function inlineSpellingFault(name: string): ConvertFault | undefined {
|
||||||
const mark = inlineMarkSpellingFault(name)
|
const mark = inlineMarkSpellingFault(name)
|
||||||
if (mark !== undefined) return mark
|
if (mark !== undefined) return mark
|
||||||
if (inlineNodeNamed(name) === undefined && name !== textDirectiveName) return undefined
|
if (inlineNodeModel(name) === undefined && name !== textDirectiveName) return undefined
|
||||||
return { code: 'unsupported-node-shape', message: `${name} takes the inline form, ${directivePrefix}${name}{…}, never the block form` }
|
return { code: 'unsupported-node-shape', message: `${name} takes the inline form, ${directivePrefix}${name}{…}, never the block form` }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { backtickRun, closingBacktickRun } from '../commonmark/backtick-runs.ts'
|
|||||||
import { commonMarkLink, linkHref } from '../mark-spellings.ts'
|
import { commonMarkLink, linkHref } from '../mark-spellings.ts'
|
||||||
import { delimiterFlags, matchEmphasis, runLength } from '../commonmark/emphasis-matching.ts'
|
import { delimiterFlags, matchEmphasis, runLength } from '../commonmark/emphasis-matching.ts'
|
||||||
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||||
import { inlineNodeNamed } from '../../adf/inline-nodes.ts'
|
import { inlineNodeModel } from '../../adf/inline-nodes.ts'
|
||||||
import { mergeAdjacentText } from '../../adf/editor-normal.ts'
|
import { mergeAdjacentText } from '../../adf/editor-normal.ts'
|
||||||
import { noSpans, readInlineDirective } from '../directive-syntax.ts'
|
import { noSpans, readInlineDirective } from '../directive-syntax.ts'
|
||||||
import { nodeAttrs, nodeMarks } from '../../adf/document.ts'
|
import { nodeAttrs, nodeMarks } from '../../adf/document.ts'
|
||||||
@@ -407,7 +407,7 @@ function imageAlt(inner: readonly Piece[], path: ConvertErrorPath): Result<strin
|
|||||||
// spec/flavour.md, The CommonMark image: the description's plain text, the content slot included.
|
// spec/flavour.md, The CommonMark image: the description's plain text, the content slot included.
|
||||||
function altText(node: AdfNode): string {
|
function altText(node: AdfNode): string {
|
||||||
if (node.type === 'hardBreak') return ' '
|
if (node.type === 'hardBreak') return ' '
|
||||||
const slot = inlineNodeNamed(node.type)?.textAttribute
|
const slot = inlineNodeModel(node.type)?.textAttribute
|
||||||
const spelled = slot === undefined ? undefined : nodeAttrs(node)[slot]
|
const spelled = slot === undefined ? undefined : nodeAttrs(node)[slot]
|
||||||
return typeof spelled === 'string' ? spelled : (node.text ?? '')
|
return typeof spelled === 'string' ? spelled : (node.text ?? '')
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -94,8 +94,8 @@ const autolinkTextNode = fc
|
|||||||
.record({ href: fc.tuple(fc.constantFrom('ab:', 'http://'), textOf(0)).map(([scheme, rest]) => `${scheme}${rest}`), marks })
|
.record({ href: fc.tuple(fc.constantFrom('ab:', 'http://'), textOf(0)).map(([scheme, rest]) => `${scheme}${rest}`), marks })
|
||||||
.map(({ href, marks: held }): AdfNode => ({ marks: [...held.filter((outer) => outer.type !== 'link'), { attrs: { href }, type: 'link' }], text: href, type: 'text' }))
|
.map(({ href, marks: held }): AdfNode => ({ marks: [...held.filter((outer) => outer.type !== 'link'), { attrs: { href }, type: 'link' }], text: href, type: 'text' }))
|
||||||
|
|
||||||
const tableInlineNodes = Object.entries(inlineNodes).map(([type, inlineNode]) =>
|
const inlineArbitraries = Object.entries(inlineNodes).map(([type, model]) =>
|
||||||
fc.record({ attrs: attributes(inlineNode.attributes), marks }).map((held): AdfNode => ({ ...held, type })),
|
fc.record({ attrs: attributes(model.attributes), marks }).map((held): AdfNode => ({ ...held, type })),
|
||||||
)
|
)
|
||||||
|
|
||||||
function weighted(arbitraries: readonly Arbitrary<AdfNode>[], weight: number): { arbitrary: Arbitrary<AdfNode>; weight: number }[] {
|
function weighted(arbitraries: readonly Arbitrary<AdfNode>[], weight: number): { arbitrary: Arbitrary<AdfNode>; weight: number }[] {
|
||||||
@@ -112,17 +112,17 @@ const positions = fc.letrec<Positions>((tie) => {
|
|||||||
none: fc.constant<AdfNode[]>([]),
|
none: fc.constant<AdfNode[]>([]),
|
||||||
}
|
}
|
||||||
const blockMarks = fc.oneof({ arbitrary: fc.constant<AdfMark[]>([]), weight: 4 }, { arbitrary: marks, weight: 1 })
|
const blockMarks = fc.oneof({ arbitrary: fc.constant<AdfMark[]>([]), weight: 4 }, { arbitrary: marks, weight: 1 })
|
||||||
const tableBlockNodes = Object.entries(blockNodes).map(([type, blockNode]) => {
|
const blockArbitraries = Object.entries(blockNodes).map(([type, model]) => {
|
||||||
const argument = blockArgument(type)
|
const argument = blockArgument(type)
|
||||||
const vocabulary: AttributeVocabulary = argument === undefined ? blockNode.attributes : { ...blockNode.attributes, [argument]: 'string' }
|
const vocabulary: AttributeVocabulary = argument === undefined ? model.attributes : { ...model.attributes, [argument]: 'string' }
|
||||||
const node = fc.record({ attrs: attributes(vocabulary), content: contentByModel[blockNode.contentModel], marks: blockMarks }).map((held): AdfNode => ({ ...held, type }))
|
const node = fc.record({ attrs: attributes(vocabulary), content: contentByModel[model.contentModel], marks: blockMarks }).map((held): AdfNode => ({ ...held, type }))
|
||||||
return { leaf: blockNode.contentModel === 'code' || blockNode.contentModel === 'none', node }
|
return { leaf: model.contentModel === 'code' || model.contentModel === 'none', node }
|
||||||
})
|
})
|
||||||
const unknownNode = fc
|
const unknownNode = fc
|
||||||
.record({ attrs: fc.dictionary(jsonKey, jsonValue, { maxKeys: 2, noNullPrototype: true }), content: fc.array(tie('inline'), { depthIdentifier, maxLength: 2 }), marks, type: unknownType })
|
.record({ attrs: fc.dictionary(jsonKey, jsonValue, { maxKeys: 2, noNullPrototype: true }), content: fc.array(tie('inline'), { depthIdentifier, maxLength: 2 }), marks, type: unknownType })
|
||||||
.map((held): AdfNode => held)
|
.map((held): AdfNode => held)
|
||||||
const leafBlocks = tableBlockNodes.filter((entry) => entry.leaf).map((entry) => entry.node)
|
const leafBlocks = blockArbitraries.filter((entry) => entry.leaf).map((entry) => entry.node)
|
||||||
const containerBlocks = tableBlockNodes.filter((entry) => !entry.leaf).map((entry) => entry.node)
|
const containerBlocks = blockArbitraries.filter((entry) => !entry.leaf).map((entry) => entry.node)
|
||||||
const misplacedWeight = 7
|
const misplacedWeight = 7
|
||||||
const paragraph = fc.oneof({ arbitrary: inlineContent, weight: 3 }, { arbitrary: fc.array(backtickRunNode, { maxLength: 4, minLength: 2 }), weight: 1 }).map((content): AdfNode => ({ content, type: 'paragraph' }))
|
const paragraph = fc.oneof({ arbitrary: inlineContent, weight: 3 }, { arbitrary: fc.array(backtickRunNode, { maxLength: 4, minLength: 2 }), weight: 1 }).map((content): AdfNode => ({ content, type: 'paragraph' }))
|
||||||
const cell = (type: string) => paragraph.map((held): AdfNode => ({ content: [held], type }))
|
const cell = (type: string) => paragraph.map((held): AdfNode => ({ content: [held], type }))
|
||||||
@@ -148,7 +148,7 @@ const positions = fc.letrec<Positions>((tie) => {
|
|||||||
{ depthIdentifier, depthSize: 'small', maxDepth: 4 },
|
{ depthIdentifier, depthSize: 'small', maxDepth: 4 },
|
||||||
{ arbitrary: fc.oneof(...flatBlocks), weight: flatBlocks.reduce((sum, entry) => sum + entry.weight, 0) },
|
{ arbitrary: fc.oneof(...flatBlocks), weight: flatBlocks.reduce((sum, entry) => sum + entry.weight, 0) },
|
||||||
{ arbitrary: fc.oneof(...containerBlocks), weight: containerBlocks.length * 2 },
|
{ arbitrary: fc.oneof(...containerBlocks), weight: containerBlocks.length * 2 },
|
||||||
{ arbitrary: fc.oneof(textNode, ...tableInlineNodes, unknownNode), weight: misplacedWeight },
|
{ arbitrary: fc.oneof(textNode, ...inlineArbitraries, unknownNode), weight: misplacedWeight },
|
||||||
{ arbitrary: fc.oneof(...nestingCommonMarkShapes), weight: nestingCommonMarkShapes.length * nestingCommonMarkShapeWeight },
|
{ arbitrary: fc.oneof(...nestingCommonMarkShapes), weight: nestingCommonMarkShapes.length * nestingCommonMarkShapeWeight },
|
||||||
),
|
),
|
||||||
inline: fc.oneof(
|
inline: fc.oneof(
|
||||||
@@ -156,8 +156,8 @@ const positions = fc.letrec<Positions>((tie) => {
|
|||||||
{ arbitrary: textNode, weight: 12 },
|
{ arbitrary: textNode, weight: 12 },
|
||||||
{ arbitrary: autolinkTextNode, weight: 2 },
|
{ arbitrary: autolinkTextNode, weight: 2 },
|
||||||
{ arbitrary: backtickRunNode, weight: 3 },
|
{ arbitrary: backtickRunNode, weight: 3 },
|
||||||
{ arbitrary: fc.oneof(...tableInlineNodes), weight: 7 },
|
{ arbitrary: fc.oneof(...inlineArbitraries), weight: 7 },
|
||||||
{ arbitrary: fc.oneof(...tableBlockNodes.map((entry) => entry.node), unknownNode), weight: 2 },
|
{ arbitrary: fc.oneof(...blockArbitraries.map((entry) => entry.node), unknownNode), weight: 2 },
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
+9
-6
@@ -1000,12 +1000,15 @@ The done `todo.md` items in full, as they were written. `todo.md` keeps a one-li
|
|||||||
to know a format. Rename to the noun `spec/flavour.md` uses, types and accessors with them.
|
to know a format. Rename to the noun `spec/flavour.md` uses, types and accessors with them.
|
||||||
Before 7 doubles the import sites.
|
Before 7 doubles the import sites.
|
||||||
**Done** (2026-09-21): the tables are `adf/block-nodes.ts` and `adf/inline-nodes.ts`,
|
**Done** (2026-09-21): the tables are `adf/block-nodes.ts` and `adf/inline-nodes.ts`,
|
||||||
`blockNodes` and `inlineNodes` holding `BlockNode` and `InlineNode`, read by
|
`blockNodes` and `inlineNodes` — `spec/flavour.md`'s own headings — each row a
|
||||||
`blockNodeNamed` and `inlineNodeNamed` — the accessor named apart from the entry so every
|
`BlockNodeModel` or `InlineNodeModel` read by `blockNodeModel` and `inlineNodeModel`. The row
|
||||||
call site's local is the one name `blockNode`/`inlineNode` rather than shadowing its own
|
is the node's model, never the node: `BlockNode` beside `AdfNode` put two kinds of thing one
|
||||||
lookup. `BlockType` stays: it names a node type, the parallel of `mark-attributes.ts`'s
|
lookup apart in every signature the rename touched, where §8 already calls the content model
|
||||||
`MarkType`. `markdown/`'s `blockDirectiveForm`, `blockArgument` and the `spell*Directive*`
|
the model. `markdown-to-adf.ts`'s own `blockNodes`/`blockNode` walk became
|
||||||
family keep the word, naming the spelling rather than the node.
|
`readBlocks`/`readBlock`, so the table's name means one thing repo-wide. `BlockType` stays:
|
||||||
|
it names a node type, the parallel of `mark-attributes.ts`'s `MarkType`. `markdown/`'s
|
||||||
|
`blockDirectiveForm`, `blockArgument` and the `spell*Directive*` family keep the word,
|
||||||
|
naming the spelling rather than the node.
|
||||||
|
|
||||||
## 5 — Ship `0.1.0`
|
## 5 — Ship `0.1.0`
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Start a session with: `Read AGENTS.md and todo.md, then do what todo.md's "Next
|
|||||||
## Milestones
|
## Milestones
|
||||||
|
|
||||||
Shipping order: 3h, 3i, 3j, 5a, 5b, 5c, 5d, 5 → `0.1.0` (shipped 2026-09-05); 3k, 11, 4, 12, 13, 4b,
|
Shipping order: 3h, 3i, 3j, 5a, 5b, 5c, 5d, 5 → `0.1.0` (shipped 2026-09-05); 3k, 11, 4, 12, 13, 4b,
|
||||||
4c, 14, 15, 16, 18, 4d, 28, 17, 29, 19, 20, 21, 22, 23, 24, 25, 30, 26, 27, 10, 6, 7, 31, 5f, 5g →
|
4c, 14, 15, 16, 18, 4d, 28, 17, 29, 19, 20, 21, 22, 32, 23, 24, 25, 30, 26, 27, 10, 6, 7, 31, 5f, 5g →
|
||||||
`0.2.0`;
|
`0.2.0`;
|
||||||
8, 9 → TBD; 5e last.
|
8, 9 → TBD; 5e last.
|
||||||
The numbering is the order the work was planned in, not the order it ships. Everything known and
|
The numbering is the order the work was planned in, not the order it ships. Everything known and
|
||||||
@@ -44,7 +44,8 @@ panel says the next reader pays for.
|
|||||||
29 and 30 come from 17's prose pass (2026-09-20). 29 reads first because every goal is what a later
|
29 and 30 come from 17's prose pass (2026-09-20). 29 reads first because every goal is what a later
|
||||||
ask is settled against, 19's included; 30 sits beside 25, the other chunk rereading AGENTS.md.
|
ask is settled against, 19's included; 30 sits beside 25, the other chunk rereading AGENTS.md.
|
||||||
31 comes from 20's gate runs (2026-09-21) and reads beside 5f, the other chunk putting a measured
|
31 comes from 20's gate runs (2026-09-21) and reads beside 5f, the other chunk putting a measured
|
||||||
number under the pipeline.
|
number under the pipeline. 32 comes from 21's review (2026-09-21) and reads beside 22, the other
|
||||||
|
chunk clearing a §11 seam.
|
||||||
|
|
||||||
- [ ] **31 — The branch figure the floor is read against is stable (`0.2.0`).** Three Node test
|
- [ ] **31 — The branch figure the floor is read against is stable (`0.2.0`).** Three Node test
|
||||||
legs over one unchanged tree reported `emit/inline-line.ts` at 95.83%, 96.23% and 96.23%,
|
legs over one unchanged tree reported `emit/inline-line.ts` at 95.83%, 96.23% and 96.23%,
|
||||||
@@ -59,6 +60,14 @@ number under the pipeline.
|
|||||||
`parse/` → `emit/` imports fetch this type from `emit/line-escaping.ts`, camouflaging the two
|
`parse/` → `emit/` imports fetch this type from `emit/line-escaping.ts`, camouflaging the two
|
||||||
that are the deliberate spelling consultation. Move it, and name those two in §11 as the whole
|
that are the deliberate spelling consultation. Move it, and name those two in §11 as the whole
|
||||||
of that surface, so a reviewer checks the seam with one grep.
|
of that surface, so a reviewer checks the seam with one grep.
|
||||||
|
- [ ] **32 — The mark depth `adf/` counts is stated in ADF's terms (`0.2.0`).**
|
||||||
|
`document.ts`'s `markAttributeNesting` is `largestNesting - 3`, and both the comment above it
|
||||||
|
and AGENTS.md §8 give the reason as markdown's: the block directive spells the whole mark set
|
||||||
|
as one JSON attribute, so the parser reads the value at the bottom of array, mark and
|
||||||
|
`attrs`. That is a format's spelling deciding a constant inside the directory §11 forbids to
|
||||||
|
know a format. Move the derivation to where that spelling lives, or state the three levels in
|
||||||
|
ADF's own vocabulary. Before 7 gives the constant a second format whose spelling may not
|
||||||
|
spend the same three levels.
|
||||||
- [ ] **23 — The block-directive fragments are one file (`0.2.0`).** `block-directive-arguments.ts`,
|
- [ ] **23 — The block-directive fragments are one file (`0.2.0`).** `block-directive-arguments.ts`,
|
||||||
`-forms.ts` and `-marks.ts` are three files under 25 lines answering one question. Fold them,
|
`-forms.ts` and `-marks.ts` are three files under 25 lines answering one question. Fold them,
|
||||||
and take `src/markdown/` — the worst level both architects named, 13 entries with no
|
and take `src/markdown/` — the worst level both architects named, 13 entries with no
|
||||||
|
|||||||
Reference in New Issue
Block a user