mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 15:15:44 +01:00
Answer stability round 2: the advice names the array limit, the guard's test names both, and the decision rewraps
This commit is contained in:
+2
-2
@@ -87,8 +87,8 @@
|
|||||||
engine builds, on V8 about 537 million characters, or about 134 million in one text node:
|
engine builds, on V8 about 537 million characters, or about 134 million in one text node:
|
||||||
`adfToLosslessMarkdown` and `adfToPortableMarkdown` refuse it as `unsupported-node-shape`, where
|
`adfToLosslessMarkdown` and `adfToPortableMarkdown` refuse it as `unsupported-node-shape`, where
|
||||||
they threw.
|
they threw.
|
||||||
- Fix compact JSON in an `adf:` fence: `losslessMarkdownToAdf` refuses it as
|
- Fix deeply nested compact JSON in an `adf:` fence: `losslessMarkdownToAdf` refuses it as
|
||||||
`unsupported-node-shape`, where a megabyte of deeply nested JSON threw.
|
`unsupported-node-shape`, like any compact JSON there, where a megabyte of it threw.
|
||||||
- Add `adfToPortableMarkdown` and `portableMarkdownToAdf`, a lossy pair converting ADF to and from
|
- Add `adfToPortableMarkdown` and `portableMarkdownToAdf`, a lossy pair converting ADF to and from
|
||||||
markdown GitHub, GitLab and Obsidian render: alerts, callouts, task lists, `==highlights==` and
|
markdown GitHub, GitLab and Obsidian render: alerts, callouts, task lists, `==highlights==` and
|
||||||
pipe tables. A task item keeps its paragraphs, then its nested task lists; the rest of the item,
|
pipe tables. A task item keeps its paragraphs, then its nested task lists; the rest of the item,
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ The emitter raises these, and so does a parse, which asks the emitter how to spe
|
|||||||
| Code | Fires when | What you can do |
|
| Code | Fires when | What you can do |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `unsupported-nesting-depth` | blocks, marks, an attribute's JSON or a carried node's JSON nest past 500 levels | keep the ADF and pass the document over, or show it read-only; flatten the input where you are the one who wrote it |
|
| `unsupported-nesting-depth` | blocks, marks, an attribute's JSON or a carried node's JSON nest past 500 levels | keep the ADF and pass the document over, or show it read-only; flatten the input where you are the one who wrote it |
|
||||||
| `unsupported-node-shape` | parsing, in `losslessMarkdownToAdf`: markdown spells a node with an attribute, value, argument or body its type does not take, or without one it needs, wraps a directive mark around nothing or only hard breaks, writes as a directive a node or mark the lossless flavour spells as CommonMark, or puts a reserved directive out of place: `!adf:textBreak{}` parting nothing, `!adf:doc` anywhere but as the whole document. Emitting, in `adfToLosslessMarkdown`: a node not riding the carry that carries one mark type twice, a block or a non-text inline node holding `text`, or a leaf block or a non-text inline node holding `content`. Emitting, in `adfToPortableMarkdown`: a line or task list the portable writer cannot spell, a bug in this library. Emitting, in both writers: a document whose markdown would be longer than the longest string or array the JavaScript engine builds — on V8, about 537 million characters of markdown, or about 134 million in one text node | fix what the message names; [`spec/flavour.md`](https://github.com/larvit/adf-codec/blob/main/spec/flavour.md) lists every type's attributes and body. For a portable line or task list, report it. Past the engine's longest string, keep the ADF and pass the document over, or show it read-only |
|
| `unsupported-node-shape` | parsing, in `losslessMarkdownToAdf`: markdown spells a node with an attribute, value, argument or body its type does not take, or without one it needs, wraps a directive mark around nothing or only hard breaks, writes as a directive a node or mark the lossless flavour spells as CommonMark, or puts a reserved directive out of place: `!adf:textBreak{}` parting nothing, `!adf:doc` anywhere but as the whole document. Emitting, in `adfToLosslessMarkdown`: a node not riding the carry that carries one mark type twice, a block or a non-text inline node holding `text`, or a leaf block or a non-text inline node holding `content`. Emitting, in `adfToPortableMarkdown`: a line or task list the portable writer cannot spell, a bug in this library. Emitting, in both writers: a document whose markdown would be longer than the longest string or array the JavaScript engine builds — on V8, about 537 million characters of markdown, or about 134 million in one text node | fix what the message names; [`spec/flavour.md`](https://github.com/larvit/adf-codec/blob/main/spec/flavour.md) lists every type's attributes and body. For a portable line or task list, report it. Past the engine's longest string or array, keep the ADF and pass the document over, or show it read-only |
|
||||||
|
|
||||||
## The guarantees
|
## The guarantees
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -462,10 +462,10 @@ handles one cause alike whichever node, attribute or direction raised it.
|
|||||||
- A non-finite number takes two codes: `unsupported-node-shape` parsing, `not-an-adf-document`
|
- A non-finite number takes two codes: `unsupported-node-shape` parsing, `not-an-adf-document`
|
||||||
emitting — no document holds one, so no round-trip crosses them (2026-09-23).
|
emitting — no document holds one, so no round-trip crosses them (2026-09-23).
|
||||||
- A document whose markdown would be longer than the longest string or array the JavaScript engine
|
- A document whose markdown would be longer than the longest string or array the JavaScript engine
|
||||||
builds is `unsupported-node-shape` at the document's path, in either writer: the document does not
|
builds is `unsupported-node-shape` at the document's path, in either writer: the document does
|
||||||
convert, and the bound is the engine's own. A carried node reaches it on about 1 MB of deeply nested JSON,
|
not convert, and the bound is the engine's own. A carried node reaches it on about 1 MB of
|
||||||
since the block carry indents two spaces a level; `todo.md` item 107 spells it in a length linear
|
deeply nested JSON, since the block carry indents two spaces a level; `todo.md` item 107 spells
|
||||||
in its JSON (2026-10-11).
|
it in a length linear in its JSON (2026-10-11).
|
||||||
- The markdown readers and `htmlToAdf` refuse a value that is not a string as `not-a-string`, at
|
- The markdown readers and `htmlToAdf` refuse a value that is not a string as `not-a-string`, at
|
||||||
position `{ line: 1, offset: 0 }` with an empty path: no existing code reads true of it, and
|
position `{ line: 1, offset: 0 }` with an empty path: no existing code reads true of it, and
|
||||||
`not-an-adf-document` names the emitters' input (2026-10-05).
|
`not-an-adf-document` names the emitters' input (2026-10-05).
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ test('every ConvertErrorCode is the code of a production call site, and every ca
|
|||||||
assert.deepEqual(calledCodes(), declaredCodes())
|
assert.deepEqual(calledCodes(), declaredCodes())
|
||||||
})
|
})
|
||||||
|
|
||||||
test('refuses where SpiderMonkey runs out of string, and lets a stack overflow or any other throw through', () => {
|
test('refuses where the engine runs out of string or array, and lets a stack overflow or any other throw through', () => {
|
||||||
const overflow = new Error('allocation size overflow')
|
const overflow = new Error('allocation size overflow')
|
||||||
overflow.name = 'InternalError'
|
overflow.name = 'InternalError'
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
|||||||
Reference in New Issue
Block a user