From 7be4f59f0b3bed46d88bfb6643469d746313c54a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 23 Sep 2026 23:13:01 +0200 Subject: [PATCH] 23 - the block directive's spellings are one file --- src/adf-schema.test.ts | 2 +- src/markdown-property.test.ts | 4 +-- src/markdown/block-directive-arguments.ts | 13 ---------- src/markdown/block-directive-forms.ts | 9 ------- ...-directive-marks.ts => block-directive.ts} | 26 +++++++++++++++++++ src/markdown/emit/adf-to-markdown.ts | 3 +-- src/markdown/emit/block-directive-spelling.ts | 3 +-- src/markdown/list-break.ts | 5 ---- src/markdown/parse/blocks.ts | 2 +- src/markdown/parse/directive-nodes.ts | 4 +-- src/markdown/parse/markdown-to-adf.ts | 2 +- src/property-harness.ts | 2 +- todo-history.md | 8 ++++++ todo.md | 5 +--- 14 files changed, 43 insertions(+), 45 deletions(-) delete mode 100644 src/markdown/block-directive-arguments.ts delete mode 100644 src/markdown/block-directive-forms.ts rename src/markdown/{block-directive-marks.ts => block-directive.ts} (51%) delete mode 100644 src/markdown/list-break.ts diff --git a/src/adf-schema.test.ts b/src/adf-schema.test.ts index e373afa..839a041 100644 --- a/src/adf-schema.test.ts +++ b/src/adf-schema.test.ts @@ -6,7 +6,7 @@ import { readFileSync } from 'node:fs' import test from 'node:test' import type { AttributeKind, AttributeVocabulary } from './adf/attribute-vocabulary.ts' -import { blockArgument } from './markdown/block-directive-arguments.ts' +import { blockArgument } from './markdown/block-directive.ts' import { blockNodes } from './adf/block-nodes.ts' import { inlineNodes } from './adf/inline-nodes.ts' import { markAttributes } from './adf/mark-attributes.ts' diff --git a/src/markdown-property.test.ts b/src/markdown-property.test.ts index b69dd72..acbb8d2 100644 --- a/src/markdown-property.test.ts +++ b/src/markdown-property.test.ts @@ -9,7 +9,7 @@ import type { JsonValue } from './json-value.ts' import type { Result } from './result.ts' import { adfDocument, attributes, jsonKey, jsonValue, markdownPieces, propertyRuns, propertyTimeout, textOf } from './property-harness.ts' import { adfToMarkdown } from './markdown/emit/adf-to-markdown.ts' -import { blockArgument } from './markdown/block-directive-arguments.ts' +import { blockArgument, listBreakName, marksAttribute } from './markdown/block-directive.ts' import { blockNodes } from './adf/block-nodes.ts' import { carryName } from './markdown/opaque-carry.ts' import { @@ -25,11 +25,9 @@ import { } from './markdown/directive-syntax.ts' import { fencedCodeBlock } from './markdown/commonmark/backtick-runs.ts' import { inlineNodes } from './adf/inline-nodes.ts' -import { listBreakName } from './markdown/list-break.ts' import { markAttributes } from './adf/mark-attributes.ts' import { markSpelling } from './markdown/mark-spellings.ts' import { markdownToAdf } from './markdown/parse/markdown-to-adf.ts' -import { marksAttribute } from './markdown/block-directive-marks.ts' import { nodeContent, nodeMarks } from './adf/document.ts' import { serializeCanonicalJson } from './canonical-json.ts' import { textDirectiveName } from './markdown/text-directive.ts' diff --git a/src/markdown/block-directive-arguments.ts b/src/markdown/block-directive-arguments.ts deleted file mode 100644 index 1d1bf29..0000000 --- a/src/markdown/block-directive-arguments.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { BlockType } from '../adf/block-nodes.ts' - -const argumentByType = new Map( - Object.entries({ - blockTaskItem: 'state', - panel: 'panelType', - taskItem: 'state', - } satisfies Partial>), -) - -export function blockArgument(type: string): string | undefined { - return argumentByType.get(type) -} diff --git a/src/markdown/block-directive-forms.ts b/src/markdown/block-directive-forms.ts deleted file mode 100644 index a12cbb1..0000000 --- a/src/markdown/block-directive-forms.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { blockNodeModel } from '../adf/block-nodes.ts' -import { listBreakName } from './list-break.ts' - -export function blockDirectiveForm(name: string): 'container' | 'leaf' | undefined { - if (name === listBreakName) return 'leaf' - const model = blockNodeModel(name) - if (model === undefined) return undefined - return model.contentModel === 'none' ? 'leaf' : 'container' -} diff --git a/src/markdown/block-directive-marks.ts b/src/markdown/block-directive.ts similarity index 51% rename from src/markdown/block-directive-marks.ts rename to src/markdown/block-directive.ts index 311ba2e..c528e23 100644 --- a/src/markdown/block-directive-marks.ts +++ b/src/markdown/block-directive.ts @@ -1,10 +1,36 @@ import type { AdfMark } from '../adf/document.ts' +import type { BlockType } from '../adf/block-nodes.ts' import type { JsonValue } from '../json-value.ts' +import { blockNodeModel } from '../adf/block-nodes.ts' import { isAdfMark, nodeAttrs } from '../adf/document.ts' import { serializeCanonicalJson } from '../canonical-json.ts' +import { spellDirectiveOpener } from './directive-syntax.ts' + +const argumentByType = new Map( + Object.entries({ + blockTaskItem: 'state', + panel: 'panelType', + taskItem: 'state', + } satisfies Partial>), +) + +export const listBreakName = 'listBreak' + +export const listBreakSpelling = spellDirectiveOpener(listBreakName, undefined, '') export const marksAttribute = 'marks' +export function blockArgument(type: string): string | undefined { + return argumentByType.get(type) +} + +export function blockDirectiveForm(name: string): 'container' | 'leaf' | undefined { + if (name === listBreakName) return 'leaf' + const model = blockNodeModel(name) + if (model === undefined) return undefined + return model.contentModel === 'none' ? 'leaf' : 'container' +} + export function markValues(marks: readonly AdfMark[]): JsonValue { return marks.map((mark) => { const attrs = nodeAttrs(mark) diff --git a/src/markdown/emit/adf-to-markdown.ts b/src/markdown/emit/adf-to-markdown.ts index 10d2825..89afb50 100644 --- a/src/markdown/emit/adf-to-markdown.ts +++ b/src/markdown/emit/adf-to-markdown.ts @@ -1,7 +1,7 @@ import type { AdfDocument, AdfNode } from '../../adf/document.ts' import type { BlockNodeModel } from '../../adf/block-nodes.ts' import { adfDocumentFault, carriesOnly, nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts' -import { blockDirectiveForm } from '../block-directive-forms.ts' +import { blockDirectiveForm, listBreakSpelling } from '../block-directive.ts' import { blockNodeModel, blockNodes } from '../../adf/block-nodes.ts' import { carriedBlock } from '../opaque-carry.ts' import { emitInlineLine } from './inline-line.ts' @@ -10,7 +10,6 @@ import { fencedCodeBlock } from '../commonmark/backtick-runs.ts' import { holdsNullCharacter, isBlankLine, isThematicBreak, markerInterruptsParagraph } from '../commonmark/grammar.ts' import { languageSlot } from '../code-language.ts' import { largestNesting } from '../../nesting.ts' -import { listBreakSpelling } from '../list-break.ts' import { spellBlockDirectiveOpener } from './block-directive-spelling.ts' import { spellDirectiveCloser, spellDirectiveOpener } from '../directive-syntax.ts' import { tryImage } from './image.ts' diff --git a/src/markdown/emit/block-directive-spelling.ts b/src/markdown/emit/block-directive-spelling.ts index 1460699..4d4a964 100644 --- a/src/markdown/emit/block-directive-spelling.ts +++ b/src/markdown/emit/block-directive-spelling.ts @@ -1,10 +1,9 @@ import type { AdfNode } from '../../adf/document.ts' import type { BlockNodeModel } from '../../adf/block-nodes.ts' import { attributeNestingMessage, nodeAttrs, nodeMarks } from '../../adf/document.ts' -import { blockArgument } from '../block-directive-arguments.ts' +import { blockArgument, markValues, marksAttribute } from '../block-directive.ts' import { failure, success, type ConvertErrorPath, type Result } from '../../result.ts' import { isBareToken, spellAttributes, spellDirectiveOpener, spellJsonAttribute, spellVocabulary } from '../directive-syntax.ts' -import { markValues, marksAttribute } from '../block-directive-marks.ts' import { overNested } from '../../json-value.ts' import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts' diff --git a/src/markdown/list-break.ts b/src/markdown/list-break.ts deleted file mode 100644 index eba28c8..0000000 --- a/src/markdown/list-break.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { spellDirectiveOpener } from './directive-syntax.ts' - -export const listBreakName = 'listBreak' - -export const listBreakSpelling = spellDirectiveOpener(listBreakName, undefined, '') diff --git a/src/markdown/parse/blocks.ts b/src/markdown/parse/blocks.ts index 4ff6c24..df1a13b 100644 --- a/src/markdown/parse/blocks.ts +++ b/src/markdown/parse/blocks.ts @@ -19,7 +19,7 @@ import { type ThematicBreakTail, } from '../commonmark/grammar.ts' import { barePipeCells, isDelimiterRow, isPipeAlignment, isPipeDelimiter, malformedPipeTable, pipeCells } from '../pipe-table-syntax.ts' -import { blockDirectiveForm } from '../block-directive-forms.ts' +import { blockDirectiveForm } from '../block-directive.ts' import { directiveEscape, malformedDirective, readDirectiveLine, spellDirectiveCloser } from '../directive-syntax.ts' import { readLinkDefinitions } from '../commonmark/link-reference-definitions.ts' diff --git a/src/markdown/parse/directive-nodes.ts b/src/markdown/parse/directive-nodes.ts index 9211ab5..a72ecd4 100644 --- a/src/markdown/parse/directive-nodes.ts +++ b/src/markdown/parse/directive-nodes.ts @@ -5,14 +5,12 @@ import type { DirectiveAttributes, DirectiveValue } from '../directive-syntax.ts import type { Elsewhere } from './directive-attributes.ts' import { attributeNestingMessage, nodeAttrs, nodeContent, nodeMarks } from '../../adf/document.ts' import { attributeValue, directivePrefix, spellAttributeValue, unknownDirectiveFault } from '../directive-syntax.ts' -import { blockArgument } from '../block-directive-arguments.ts' -import { blockDirectiveForm } from '../block-directive-forms.ts' +import { blockArgument, blockDirectiveForm, marksAttribute, readMarkValues } from '../block-directive.ts' import { blockNodeModel } from '../../adf/block-nodes.ts' import { carryName } from '../opaque-carry.ts' import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts' import { inlineMarkSpellingFault } from './directive-marks.ts' import { inlineNodeModel } from '../../adf/inline-nodes.ts' -import { marksAttribute, readMarkValues } from '../block-directive-marks.ts' import { readVocabulary } from './directive-attributes.ts' import { slotLineEndingFault } from '../directive-syntax.ts' import { textDirectiveName } from '../text-directive.ts' diff --git a/src/markdown/parse/markdown-to-adf.ts b/src/markdown/parse/markdown-to-adf.ts index 021c003..c78a60d 100644 --- a/src/markdown/parse/markdown-to-adf.ts +++ b/src/markdown/parse/markdown-to-adf.ts @@ -9,7 +9,7 @@ import { commonMarkSpelling, type SpellingMemo } from '../emit/adf-to-markdown.t import { failure, faulted, positioned, success, type ConvertErrorPath, type ParseError, type Result, type SourcePosition } from '../../result.ts' import { languageSlot } from '../code-language.ts' import { largestNesting } from '../../nesting.ts' -import { listBreakName, listBreakSpelling } from '../list-break.ts' +import { listBreakName, listBreakSpelling } from '../block-directive.ts' import { nodeAttrs } from '../../adf/document.ts' import { parseBlocks } from './blocks.ts' import { parseInlineContent } from './inline-content.ts' diff --git a/src/property-harness.ts b/src/property-harness.ts index 70ebc21..9b09bdf 100644 --- a/src/property-harness.ts +++ b/src/property-harness.ts @@ -6,7 +6,7 @@ import type { AdfAttributes, AdfDocument, AdfMark, AdfNode } from './adf/documen import type { Arbitrary } from 'fast-check' import type { AttributeKind, AttributeVocabulary } from './adf/attribute-vocabulary.ts' import type { JsonValue } from './json-value.ts' -import { blockArgument } from './markdown/block-directive-arguments.ts' +import { blockArgument } from './markdown/block-directive.ts' import { blockNodes } from './adf/block-nodes.ts' import { directivePrefix } from './markdown/directive-syntax.ts' import { inlineNodes } from './adf/inline-nodes.ts' diff --git a/todo-history.md b/todo-history.md index 30db6d5..b806d93 100644 --- a/todo-history.md +++ b/todo-history.md @@ -1030,6 +1030,14 @@ The done `todo.md` items in full, as they were written. `todo.md` keeps a one-li the block directive's `marks` spelling refuses its own over-deep JSON with the parser's message and the node's path, and §8 says a deeper spelling refuses in its own format. +- [x] **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, + and take `src/markdown/` — the worst level both architects named, 13 entries with no + organising question — down with them. + **Done** (2026-09-23): `markdown/block-directive.ts` holds the form, the argument, the `marks` + attribute and the `listBreak` spelling — what the block directive spells of a node that the + grammar does not — and `src/markdown/` drops from 15 entries to 12. + ## 5 — Ship `0.1.0` - [ ] **5 — Ship `0.1.0`.** Only the maintainer's own acts are left (§15): make the Gitea repo diff --git a/todo.md b/todo.md index a2dc67f..99419ed 100644 --- a/todo.md +++ b/todo.md @@ -56,10 +56,6 @@ chunk clearing a §11 seam. upward, so the first raise to the measured figure reddens a run that changed nothing. Make the measurement repeatable, or state the number the floor may be raised to and why it is not the measured one. -- [ ] **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, - and take `src/markdown/` — the worst level both architects named, 13 entries with no - organising question — down with them. - [ ] **24 — The conformance gates have a directory (`0.2.0`).** Six root tests with no sibling source (`adf-property`, `adf-schema`, `commonmark-spec`, `corpus`, `flavour`, `markdown-property`) plus `property-harness.ts` are the machinery that makes the docs @@ -281,6 +277,7 @@ chunk clearing a §11 seam. - [x] **20 — The give-way channel is unmistakable (`0.2.0`).** - [x] **21 — The ADF tables carry ADF's nouns (`0.2.0`).** - [x] **22 — `LineContainer` sits at the markdown level (`0.2.0`).** +- [x] **23 — The block-directive fragments are one file (`0.2.0`).** - [x] **28 — `emitLine`'s retry loop cannot spin (`0.2.0`).** - [x] **29 — The README reads raw HTML as refused for good (`0.2.0`).** - [x] **30 — AGENTS.md says each thing once (`0.2.0`).** -- 2.52.0