mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 06:35:44 +01:00
Answer prose round 1: the refusal messages name what passed the bound, the decisions read one idea a sentence, and the changelog gives the readers' fix its own bullet
This commit is contained in:
@@ -44,7 +44,7 @@ test('refuses a value that is not an ADF document, naming the check it failed',
|
||||
assert.equal(markdown(adfToLosslessMarkdown({ type: 'doc', version: Number.NaN })), 'not-an-adf-document: an ADF document holds a version number: found NaN')
|
||||
})
|
||||
|
||||
const tooLong = 'unsupported-node-shape: spelled as markdown, this would be longer than 536870888 characters, the longest markdown this library writes'
|
||||
const tooLong = 'unsupported-node-shape: the markdown for this document, or for a directive\'s plain CommonMark, would be longer than 536870888 characters, the longest this library writes'
|
||||
|
||||
// A code block of 300 lines; two of these together fall some 1000 characters short of V8's longest string, so only what their spelling adds passes it.
|
||||
function nearlyHalfTheBound(): AdfNode {
|
||||
@@ -59,7 +59,7 @@ test('refuses a carry whose JSON would run past V8\'s longest string, on every e
|
||||
assert.equal(markdown(result), tooLong)
|
||||
})
|
||||
|
||||
test('refuses lines their quotes would prefix past V8\'s longest string', () => {
|
||||
test('refuses a quote whose prefixed lines would pass V8\'s longest string', () => {
|
||||
const code = nearlyHalfTheBound()
|
||||
assert.equal(markdown(adfToLosslessMarkdown(document({ content: [code, code], type: 'blockquote' }))), tooLong)
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ function walkBlocks(nodes: readonly AdfNode[], path: ConvertErrorPath, depth: nu
|
||||
for (const [index, node] of nodes.entries()) {
|
||||
const block = emitBlock(node, [...path, 'content', index], depth, writing)
|
||||
if (!block.ok) return block
|
||||
// V8 throws building a block past the bound; an engine holding longer strings stops at the same block.
|
||||
// Refused here, so an engine holding longer strings stops at the block where V8 throws.
|
||||
const fits = withinLongest(block.value.text)
|
||||
if (!fits.ok) return fits
|
||||
headroom = Math.min(headroom, block.value.headroom)
|
||||
@@ -136,7 +136,7 @@ function readableBlock(node: AdfNode, path: ConvertErrorPath, depth: number, wri
|
||||
return spellReadableBlock(node, path, depth, writing)
|
||||
}
|
||||
|
||||
// The CommonMark ask fills an entry; the walk above reads it once and spells it into its own text, so kept, every level of a deep subtree would hold its whole text.
|
||||
// docs/decisions.md §The spelling memo
|
||||
function takeKeptSpelling(memo: SpellingMemo | undefined, node: AdfNode): KeptSpelling | undefined {
|
||||
const kept = memo?.get(node)
|
||||
memo?.delete(node)
|
||||
|
||||
Reference in New Issue
Block a user