mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-14 20:40:25 +01:00
Give code text no mark but code, link and annotation, in every reader
This commit is contained in:
@@ -8,7 +8,7 @@ import test from 'node:test'
|
||||
import type { AttributeKind, AttributeVocabulary } from '../adf/attribute-vocabulary.ts'
|
||||
import { blockArgument } from '../markdown/block-directive.ts'
|
||||
import { blockNodes } from '../adf/block-nodes.ts'
|
||||
import { inlineNodes } from '../adf/inline-nodes.ts'
|
||||
import { codeTextMarkTypes, inlineNodes } from '../adf/inline-nodes.ts'
|
||||
import { markVocabularies } from '../adf/mark-attributes.ts'
|
||||
|
||||
type Held = Map<string, Set<AttributeKind>>
|
||||
@@ -81,6 +81,17 @@ test('the inline node table gives a type exactly the mark types the ADF JSON Sch
|
||||
for (const [type, model] of Object.entries(inlineNodes)) assert.deepEqual(model.markTypes, [...(marked.get(type) ?? [])].sort(), type)
|
||||
})
|
||||
|
||||
test('code text takes exactly the mark types the ADF JSON Schemas give a code_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} code_inline_node`
|
||||
const marks = alternatives(schemaObject(definitions['code_inline_node'], where), definitions, where).flatMap((properties) => properties.get('marks') ?? [])
|
||||
// allOf narrows text_node's marks, which hold every mark type, to the ones code text takes.
|
||||
const narrowed = marks.map((schema) => heldMarkTypes(schema, definitions, `${where}.marks`)).filter((types) => !types.includes('every mark type'))
|
||||
assert.deepEqual(narrowed.flat().sort(), codeTextMarkTypes, file)
|
||||
}
|
||||
})
|
||||
|
||||
function spelled(): Spelled[] {
|
||||
return [
|
||||
...Object.entries(blockNodes).map(([type, model]) => spelledType(type, model.attributes, blockArgument(type))),
|
||||
|
||||
Reference in New Issue
Block a user