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

Spell colwidth as a comma list and a block's marks by name

This commit is contained in:
2026-10-14 09:59:21 +02:00
committed by Lillem4n
parent 1c7518aea1
commit e882b5de7a
18 changed files with 209 additions and 59 deletions
+15
View File
@@ -1,5 +1,14 @@
import type { AttributeVocabulary } from './attribute-vocabulary.ts'
// Marks only a block's marks key holds, so no inline spelling names them.
export const blockMarkAttributes = {
alignment: { align: 'string' },
breakout: { mode: 'string', width: 'number' },
dataConsumer: { sources: 'json' },
fragment: { localId: 'string', name: 'string' },
indentation: { level: 'number' },
} satisfies Readonly<Record<string, AttributeVocabulary>>
export const markAttributes = {
border: { color: 'string', size: 'number' },
code: {},
@@ -12,8 +21,14 @@ export const markAttributes = {
underline: {},
} satisfies Readonly<Record<string, AttributeVocabulary>>
const blockMarkVocabularies: ReadonlyMap<string, AttributeVocabulary> = new Map(Object.entries(blockMarkAttributes))
export type MarkType = keyof typeof markAttributes
export function isMarkType(type: string): type is MarkType {
return Object.hasOwn(markAttributes, type)
}
export function markVocabulary(type: string): AttributeVocabulary | undefined {
return isMarkType(type) ? markAttributes[type] : blockMarkVocabularies.get(type)
}