Answer the stability nits: the spellings a position hint names, and the fault its name owns
CI / gate (push) Successful in 9s
CI / gate (push) Successful in 9s
This commit is contained in:
@@ -16,7 +16,7 @@ export function readDirectiveMark(name: string, attributes: DirectiveAttributes,
|
||||
return success(Object.keys(attrs.value).length === 0 ? { type: name } : { attrs: attrs.value, type: name })
|
||||
}
|
||||
|
||||
export function markSpellingFault(name: string): ConvertFault | undefined {
|
||||
export function inlineMarkSpellingFault(name: string): ConvertFault | undefined {
|
||||
const spelling = markSpelling(name)
|
||||
if (spelling === undefined) return undefined
|
||||
return { code: 'unsupported-node-shape', message: `${name} is spelled ${markdownForm(spelling) ?? `:${name}[…]`}, never as a block directive` }
|
||||
|
||||
@@ -9,7 +9,7 @@ import { blockDirective } from '../../adf/block-directives.ts'
|
||||
import { carryName } from '../opaque-carry.ts'
|
||||
import { failure, faulted, success, type ConvertErrorPath, type Result } from '../../result.ts'
|
||||
import { inlineDirective } from '../../adf/inline-directives.ts'
|
||||
import { markSpellingFault } from './directive-marks.ts'
|
||||
import { inlineMarkSpellingFault } from './directive-marks.ts'
|
||||
import { marksAttribute, readMarkValues } from '../block-directive-marks.ts'
|
||||
import { readVocabulary } from './directive-attributes.ts'
|
||||
import { slotLineEndingFault } from '../directive-syntax.ts'
|
||||
@@ -69,15 +69,17 @@ export function readInlineDirectiveNode(
|
||||
|
||||
// A name the other position spells names that spelling, never the code a later MINOR may fill (AGENTS.md §8).
|
||||
function inlineSpellingFault(name: string): ConvertFault | undefined {
|
||||
const mark = markSpellingFault(name)
|
||||
const mark = inlineMarkSpellingFault(name)
|
||||
if (mark !== undefined) return mark
|
||||
if (inlineDirective(name) === undefined && name !== textDirectiveName) return undefined
|
||||
return { code: 'unsupported-node-shape', message: `${name} takes the inline form, :${name}` }
|
||||
return { code: 'unsupported-node-shape', message: `${name} takes the inline form, :${name}{…}` }
|
||||
}
|
||||
|
||||
function blockSpellingFault(name: string): ConvertFault | undefined {
|
||||
if (blockDirective(name) === undefined) return undefined
|
||||
return { code: 'unsupported-node-shape', message: `${name} takes the block form, ::${name}` }
|
||||
const directive = blockDirective(name)
|
||||
if (directive === undefined) return undefined
|
||||
const form = directive.contentModel === 'none' ? `::${name}` : `:::${name}`
|
||||
return { code: 'unsupported-node-shape', message: `${name} takes the block form, ${form}` }
|
||||
}
|
||||
|
||||
// spec/flavour.md, Inline nodes: the slot is plain text, its adjacent nodes already merged.
|
||||
|
||||
@@ -254,9 +254,10 @@ test('names the directive name no node reads back to', () => {
|
||||
test('names the position a directive name the other one spells belongs to', () => {
|
||||
assert.equal(content(markdownToAdf(':::em\na\n:::\n')), 'unsupported-node-shape: em is spelled _x_, never as a block directive')
|
||||
assert.equal(content(markdownToAdf('::underline\n')), 'unsupported-node-shape: underline is spelled :underline[…], never as a block directive')
|
||||
assert.equal(content(markdownToAdf('::text {text=" "}\n')), 'unsupported-node-shape: text takes the inline form, :text')
|
||||
assert.equal(content(markdownToAdf('::date {timestamp=1}\n')), 'unsupported-node-shape: date takes the inline form, :date')
|
||||
assert.equal(content(markdownToAdf(':paragraph[a]\n')), 'unsupported-node-shape: paragraph takes the block form, ::paragraph')
|
||||
assert.equal(content(markdownToAdf('::text {text=" "}\n')), 'unsupported-node-shape: text takes the inline form, :text{…}')
|
||||
assert.equal(content(markdownToAdf('::date {timestamp=1}\n')), 'unsupported-node-shape: date takes the inline form, :date{…}')
|
||||
assert.equal(content(markdownToAdf(':paragraph[a]\n')), 'unsupported-node-shape: paragraph takes the block form, :::paragraph')
|
||||
assert.equal(content(markdownToAdf(':rule[a]\n')), 'unsupported-node-shape: rule takes the block form, ::rule')
|
||||
assert.equal(code(markdownToAdf(':::widget\na\n:::\n')), 'unknown-directive-name')
|
||||
assert.equal(code(markdownToAdf(':widget[a]\n')), 'unknown-directive-name')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user