Share the CommonMark grammar, close the guard's hole, refuse the lists no marker spells
CI / gate (push) Successful in 4s

This commit is contained in:
2026-08-24 16:18:47 +02:00
parent 0728ea1cfb
commit e92484eb85
14 changed files with 205 additions and 126 deletions
+1 -10
View File
@@ -1,16 +1,7 @@
export type JsonValue = JsonValue[] | boolean | null | number | string | { [key: string]: JsonValue }
import type { JsonValue } from './json-value.ts'
export type JsonSpelling = 'compact' | 'two-space'
export function isJsonValue(value: unknown): value is JsonValue {
if (value === null) return true
if (typeof value === 'boolean' || typeof value === 'string') return true
if (typeof value === 'number') return Number.isFinite(value)
if (Array.isArray(value)) return value.every(isJsonValue)
if (typeof value === 'object') return Object.values(value).every(isJsonValue)
return false
}
export function serializeCanonicalJson(value: JsonValue, spelling: JsonSpelling): string {
return serialize(value, spelling === 'compact' ? '' : ' ', 0)
}