23 - the block directive's spellings are one file
This commit was merged in pull request #122.
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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<Record<BlockType, string>>),
|
||||
)
|
||||
|
||||
export function blockArgument(type: string): string | undefined {
|
||||
return argumentByType.get(type)
|
||||
}
|
||||
@@ -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'
|
||||
}
|
||||
@@ -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<Record<BlockType, string>>),
|
||||
)
|
||||
|
||||
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)
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { spellDirectiveOpener } from './directive-syntax.ts'
|
||||
|
||||
export const listBreakName = 'listBreak'
|
||||
|
||||
export const listBreakSpelling = spellDirectiveOpener(listBreakName, undefined, '')
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user