3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Give the directive grammar, flavours and reader failures one place each

This commit is contained in:
2026-10-21 23:43:05 +02:00
committed by Lillem4n
parent db10287cae
commit b080410852
37 changed files with 212 additions and 189 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
import type { AdfAttributes } from '../../adf/document.ts'
import type { AttributeVocabulary } from '../../adf/attribute-vocabulary.ts'
import type { DirectiveAttributes } from '../directive-syntax.ts'
import type { DirectiveAttributes } from './syntax.ts'
import { attributeNestingMessage } from '../../adf/document.ts'
import { attributeValue, spellAttributeValue } from '../directive-syntax.ts'
import { attributeValue, spellAttributeValue } from './syntax.ts'
import { failure, success, type ConvertErrorPath, type Result } from '../../result.ts'
export type Elsewhere = { key: string; slot: 'argument' | 'content' }
+2 -2
View File
@@ -1,9 +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, marksAttribute, spellBlockMarks } from '../block-directive.ts'
import { blockArgument, marksAttribute, spellBlockMarks } from './block.ts'
import { failure, success, type ConvertErrorPath, type Result } from '../../result.ts'
import { isBareToken, spellAttributes, spellDirectiveOpener, spellVocabulary } from '../directive-syntax.ts'
import { isBareToken, spellAttributes, spellDirectiveOpener, spellVocabulary } from './syntax.ts'
import { spellEmptyKeys } from '../empty-keys.ts'
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
+10 -10
View File
@@ -1,13 +1,13 @@
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 } from '../adf/document.ts'
import { markVocabularies } from '../adf/mark-attributes.ts'
import { overNested } from '../json-value.ts'
import { serializeCanonicalJson } from '../canonical-json.ts'
import { spellAttributes, spellDirectiveOpener, spellJsonAttribute, spellStringAttribute } from './directive-syntax.ts'
import { spellMarkVocabulary } from './mark-spellings.ts'
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 } from '../../adf/document.ts'
import { markVocabularies } from '../../adf/mark-attributes.ts'
import { overNested } from '../../json-value.ts'
import { serializeCanonicalJson } from '../../canonical-json.ts'
import { spellAttributes, spellDirectiveOpener, spellJsonAttribute, spellStringAttribute } from './syntax.ts'
import { spellMarkVocabulary } from '../mark-spellings.ts'
const argumentByType = new Map(
Object.entries({
+1 -1
View File
@@ -1,7 +1,7 @@
import type { AdfNode } from '../../adf/document.ts'
import type { InlineNodeModel } from '../../adf/inline-nodes.ts'
import { nodeAttrs } from '../../adf/document.ts'
import { spellAttributes, spellVocabulary } from '../directive-syntax.ts'
import { spellAttributes, spellVocabulary } from './syntax.ts'
import { spellEmptyKeys } from '../empty-keys.ts'
import { vocabularyPairs } from '../../adf/attribute-vocabulary.ts'
+3 -3
View File
@@ -1,13 +1,13 @@
import type { AdfMark } from '../../adf/document.ts'
import type { AttributeVocabulary } from '../../adf/attribute-vocabulary.ts'
import type { ConvertFault } from '../../result.ts'
import type { DirectiveAttributes } from '../directive-syntax.ts'
import type { DirectiveAttributes } from './syntax.ts'
import type { MarkSpelling } from '../mark-spellings.ts'
import { directivePrefix } from '../directive-syntax.ts'
import { directivePrefix } from './syntax.ts'
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
import { markSpelling } from '../mark-spellings.ts'
import { readEmptyKeys } from '../empty-keys.ts'
import { readVocabulary } from './directive-attributes.ts'
import { readVocabulary } from './attributes.ts'
export function readDirectiveMark(name: string, attributes: DirectiveAttributes, path: ConvertErrorPath): Result<AdfMark> | undefined {
const spelling = markSpelling(name)
+8 -8
View File
@@ -1,22 +1,22 @@
import type { AdfAttributes, AdfMark, AdfNode, EmptyKey } from '../../adf/document.ts'
import type { BlockNodeModel } from '../../adf/block-nodes.ts'
import type { ConvertFault } from '../../result.ts'
import type { DirectiveAttributes, DirectiveValue } from '../directive-syntax.ts'
import type { Elsewhere } from './directive-attributes.ts'
import type { DirectiveAttributes, DirectiveValue } from './syntax.ts'
import type { Elsewhere } from './attributes.ts'
import { attributeNestingMessage, isUnmarkedSpellableText } from '../../adf/document.ts'
import { attributePairCause, attributeValue, directivePrefix, readAttributes, readDirectiveName, unknownDirectiveFault } from '../directive-syntax.ts'
import { blockArgument, blockDirectiveForm, marksAttribute, readMarkValues, spellBlockMarks } from '../block-directive.ts'
import { attributePairCause, attributeValue, directivePrefix, readAttributes, readDirectiveName, unknownDirectiveFault } from './syntax.ts'
import { blockArgument, blockDirectiveForm, marksAttribute, readMarkValues, spellBlockMarks } from './block.ts'
import { blockNodeModel } from '../../adf/block-nodes.ts'
import { carryFencePrefix, carryName } from '../opaque-carry.ts'
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
import { inlineMarkSpellingFault, readMarkAttributes } from './directive-marks.ts'
import { inlineMarkSpellingFault, readMarkAttributes } from './marks.ts'
import { inlineNodeModel } from '../../adf/inline-nodes.ts'
import { markVocabularies } from '../../adf/mark-attributes.ts'
import { readEmptyKeys, spellsEmpty } from '../empty-keys.ts'
import { readVocabulary } from './directive-attributes.ts'
import { slotFault } from '../directive-syntax.ts'
import { readVocabulary } from './attributes.ts'
import { slotFault } from './syntax.ts'
import { textBreakName } from '../adjacent-text.ts'
import { textDirectiveName } from '../text-directive.ts'
import { textDirectiveName } from './text.ts'
export type BlockDirectiveNode = { contentModel: BlockNodeModel['contentModel']; node: AdfNode }
+4 -4
View File
@@ -1,10 +1,10 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import type { DirectiveAttributes, DirectiveLine } from './directive-syntax.ts'
import { claimDirectivePrefix, readDirectiveLine, readInlineDirective } from './directive-syntax.ts'
import { inlineSource } from './inline-tokens.ts'
import { largestNesting } from '../nesting.ts'
import type { DirectiveAttributes, DirectiveLine } from './syntax.ts'
import { claimDirectivePrefix, readDirectiveLine, readInlineDirective } from './syntax.ts'
import { inlineSource } from '../inline-tokens.ts'
import { largestNesting } from '../../nesting.ts'
// A pair the input spells bare decodes to itself; a quoted one names its spelling beside the decoding.
type Pair = [string, string, string?]
+12 -14
View File
@@ -1,15 +1,15 @@
import type { AttributeKind, VocabularyPair, VocabularyValue } from '../adf/attribute-vocabulary.ts'
import type { CodeSpanCloser } from './commonmark/backtick-runs.ts'
import type { ConvertFault } from '../result.ts'
import type { InlineSource } from './inline-tokens.ts'
import type { JsonValue } from '../json-value.ts'
import { backslashEscape, holdsNullCharacter } from './commonmark/grammar.ts'
import { backtickRun } from './commonmark/backtick-runs.ts'
import { isNumberList } from '../adf/attribute-vocabulary.ts'
import { overNested } from '../json-value.ts'
import { largestNesting } from '../nesting.ts'
import { parseJsonText } from '../json-text.ts'
import { serializeCanonicalJson } from '../canonical-json.ts'
import type { AttributeKind, VocabularyPair, VocabularyValue } from '../../adf/attribute-vocabulary.ts'
import type { CodeSpanCloser } from '../commonmark/backtick-runs.ts'
import type { ConvertFault, Read } from '../../result.ts'
import type { InlineSource } from '../inline-tokens.ts'
import type { JsonValue } from '../../json-value.ts'
import { backslashEscape, holdsNullCharacter } from '../commonmark/grammar.ts'
import { backtickRun } from '../commonmark/backtick-runs.ts'
import { isNumberList } from '../../adf/attribute-vocabulary.ts'
import { overNested } from '../../json-value.ts'
import { largestNesting } from '../../nesting.ts'
import { parseJsonText } from '../../json-text.ts'
import { serializeCanonicalJson } from '../../canonical-json.ts'
export type AttributeReading = { refusal: 'kind' | 'nesting'; value?: undefined } | { refusal?: undefined; value: VocabularyValue }
@@ -31,8 +31,6 @@ export type DirectiveSpan = { attributes: DirectiveAttributes; content: string |
export type NestedSpans = ReadonlyMap<number, DirectiveSpan>
export type Read<T> = { fault: ConvertFault; value?: undefined } | { fault?: undefined; value: T }
type AttributePair = { end: number; key: string; value: DirectiveValue }
type Content = { content: string | undefined; end: number; spans: NestedSpans }
+3 -2
View File
@@ -1,5 +1,6 @@
import type { DirectiveSpan, Read } from './directive-syntax.ts'
import { readSoleStringAttribute, spellAttributes, spellInlineLeafDirective, spellStringAttribute, unsupportedNodeShape } from './directive-syntax.ts'
import type { DirectiveSpan } from './syntax.ts'
import type { Read } from '../../result.ts'
import { readSoleStringAttribute, spellAttributes, spellInlineLeafDirective, spellStringAttribute, unsupportedNodeShape } from './syntax.ts'
const name = 'text'
const spelledRun = /^(?:[ \t]+|\n+|\0+)$/