mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-13 04:08:29 +01:00
Give each markdown input its own reader: commonMarkToAdf, losslessMarkdownToAdf and portableMarkdownToAdf, each claiming only its flavour
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { Claims } from './portable/conventions.ts'
|
||||
import type { JsonValue } from '../json-value.ts'
|
||||
import { carryFenceType } from './opaque-carry.ts'
|
||||
import { infoStringCarries } from './commonmark/grammar.ts'
|
||||
@@ -5,8 +6,8 @@ import { infoStringCarries } from './commonmark/grammar.ts'
|
||||
export type LanguageSlot = { info: string; kind: 'fence' } | { kind: 'attribute' } | { kind: 'none' }
|
||||
|
||||
// spec/flavour.md, The CommonMark blocks: the one slot a codeBlock's language rides.
|
||||
export function languageSlot(language: JsonValue | undefined): LanguageSlot {
|
||||
export function languageSlot(language: JsonValue | undefined, claims: Claims): LanguageSlot {
|
||||
if (language === undefined) return { kind: 'none' }
|
||||
if (typeof language !== 'string' || carryFenceType(language) !== undefined || !infoStringCarries(language)) return { kind: 'attribute' }
|
||||
if (typeof language !== 'string' || (claims.carryFence && carryFenceType(language) !== undefined) || !infoStringCarries(language)) return { kind: 'attribute' }
|
||||
return { info: language, kind: 'fence' }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user