3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-18 22:25:44 +01:00

Build text holding no border mark in losslessMarkdownToAdf, and carry text holding one

This commit is contained in:
2026-10-31 02:40:51 +01:00
parent de0033c083
commit 7ce296c455
13 changed files with 47 additions and 28 deletions
+11 -1
View File
@@ -8,7 +8,7 @@ import test from 'node:test'
import type { AttributeKind, AttributeVocabulary } from '../adf/attribute-vocabulary.ts'
import { blockArgument } from '../markdown/directive/block.ts'
import { blockNodes } from '../adf/block-nodes.ts'
import { codeTextMarkTypes, inlineNodes } from '../adf/inline-nodes.ts'
import { codeTextMarkTypes, formattedTextMarkTypes, inlineNodes } from '../adf/inline-nodes.ts'
import { markVocabularies } from '../adf/mark-attributes.ts'
type Held = Map<string, Set<AttributeKind>>
@@ -92,6 +92,16 @@ test('code text takes exactly the mark types the ADF JSON Schemas give a code_in
}
})
test('formatted text takes exactly the mark types the ADF JSON Schemas give a formatted_text_inline_node', () => {
for (const file of schemaFiles) {
const definitions = schemaObject(schemaObject(JSON.parse(readFileSync(join(root, file), 'utf8')), file)['definitions'], `${file} definitions`)
const where = `${file} formatted_text_inline_node`
const marks = alternatives(schemaObject(definitions['formatted_text_inline_node'], where), definitions, where).flatMap((properties) => properties.get('marks') ?? [])
const narrowed = marks.map((schema) => heldMarkTypes(schema, definitions, `${where}.marks`)).filter((types) => !types.includes('every mark type'))
assert.deepEqual(narrowed.flat().sort(), formattedTextMarkTypes, file)
}
})
function spelled(): Spelled[] {
return [
...Object.entries(blockNodes).map(([type, model]) => spelledType(type, model.attributes, blockArgument(type))),