3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 07:32:58 +01:00

Answer architecture round 3: the forecast never overcounts, the carry's JSON and the portable code block join through joinedWithin, and the list's choice of form stands in its own function

This commit is contained in:
2026-10-12 17:52:15 +02:00
committed by Lillem4n
parent 3414c8690a
commit ae1a47f1bc
14 changed files with 83 additions and 84 deletions
+3 -3
View File
@@ -2,16 +2,16 @@ import type { AdfNode } from '../adf/document.ts'
import type { DirectiveSpan, Read } from './directive-syntax.ts'
import type { JsonSpelling } from '../canonical-json.ts'
import type { JsonValue } from '../json-value.ts'
import { boundedThen, joinedWithin } from './length-bound.ts'
import { directiveEscape, malformedDirective, readSoleStringAttribute, spellAttributes, spellDirectiveOpener, spellInlineLeafDirective, spellStringAttribute, unsupportedNodeShape } from './directive-syntax.ts'
import { failure, success, type ConvertErrorPath, type Result } from '../result.ts'
import { fencePieces } from './commonmark/backtick-runs.ts'
import { infoStringCarries } from './commonmark/grammar.ts'
import { isAdfNode } from '../adf/document.ts'
import { isJsonValue, nestingDepth, overNested } from '../json-value.ts'
import { boundedThen, joinedWithin, longestMarkdown } from './length-bound.ts'
import { largestNesting } from '../nesting.ts'
import { parseJsonText } from '../json-text.ts'
import { serializeCanonicalJsonWithin, spellsCanonicalJson } from '../canonical-json.ts'
import { canonicalJsonPieces, spellsCanonicalJson } from '../canonical-json.ts'
export const carryFencePrefix = 'adf:'
@@ -60,7 +60,7 @@ function carriedJson(node: AdfNode, spelled: object, spelling: JsonSpelling, pat
if (!isJsonValue(spelled) || headroom < 0) {
return failure('unsupported-nesting-depth', `a carried node's JSON nests deeper than the ${levels} levels its position leaves`, path)
}
const json = serializeCanonicalJsonWithin(spelled, spelling, longestMarkdown)
const json = joinedWithin(canonicalJsonPieces(spelled, spelling))
return boundedThen(json, (spelled) => success({ headroom, json: spelled }))
}