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

Answer prose round 1: the README says which refusal differs between engines, items 106 and 107 read one idea a sentence, and two test titles and a comment read on one pass

This commit is contained in:
2026-10-11 20:54:59 +02:00
committed by Lillem4n
parent 5e05fa6f30
commit 62d80a69b7
7 changed files with 27 additions and 27 deletions
+1 -2
View File
@@ -15,7 +15,7 @@ export function serializeCanonicalJson(value: JsonValue, spelling: JsonSpelling)
return text.join('')
}
// Stops at the first piece `text` does not hold: two-space indentation can spell a short compact text past the engine's longest string.
// Stops at the first piece that does not match `text`: re-spelled with two-space indentation, a short compact text can pass the engine's longest string.
export function spellsCanonicalJson(value: JsonValue, spelling: JsonSpelling, text: string): boolean {
let offset = 0
const whole = writeCanonicalJson(value, spelling, (piece) => {
@@ -26,7 +26,6 @@ export function spellsCanonicalJson(value: JsonValue, spelling: JsonSpelling, te
return whole && offset === text.length
}
// `write` returns false to stop the walk, and the walk then returns false.
function writeCanonicalJson(value: JsonValue, spelling: JsonSpelling, write: (piece: string) => boolean): boolean {
const indent = spelling === 'compact' ? '' : ' '
const pending: Pending[] = [{ depth: 0, value }]
+1 -1
View File
@@ -448,7 +448,7 @@ test('names the canonical spelling a carried JSON reads alone', () => {
assert.equal(content(losslessMarkdownToAdf('!adf:carry{json="{\\"type\\":\\"blockCard\\",\\"attrs\\":{}}"}\n')), `${canonically}compact, keys sorted${literal}`)
})
test('refuses compact JSON in the carry fence without spelling it two-space past the engine\'s longest string', () => {
test('refuses compact JSON in the carry fence without building its two-space spelling', () => {
const json = `{"attrs":{"value":${'['.repeat(495)}${new Array(2_200_000).fill(0).join(',')}${']'.repeat(495)}}}`
assert.equal(
content(losslessMarkdownToAdf(`\`\`\`adf:unknownBlock\n${json}\n\`\`\`\n`)),
@@ -70,7 +70,7 @@ test('refuses what the document guard refuses, and nothing else', () => {
assert.match(portableDocument(document(paragraph(deepInline))), /^unsupported-nesting-depth at /)
})
test('refuses a document whose text merges past the engine\'s longest string', () => {
test('refuses a paragraph whose merged text passes the engine\'s longest string', () => {
const long = 'a'.repeat(2 ** 28)
const merged = paragraph(...Array.from({ length: 9 }, () => text(long)))
assert.equal(portableDocument(document(merged)), 'unsupported-node-shape at /')