\\n"'],
+ ['\n', 'unmappable-html at /content/0/content/0: a holds an , inside where a link marks it: found "x\n', 'unmappable-html at /content/0/content/0: around an image ends at : found "x\\n"'],
+ ['\n', 'unmappable-html at /content/0/content/0: height on holds a positive whole number written as JavaScript writes it'],
+ ['\n', 'unmappable-html at /content/0/content/0: height on holds a positive whole number written as JavaScript writes it'],
+ ['x\n', 'unmappable-html at /content/0: holds its image, then its , then : found "x\\n"'],
+ ['cx\n', 'unmappable-html at /content/0: holds its image, then its , then : found "x\\n"'],
+ ['c\n', 'unsupported-node-shape at /content/0/content/1: takes no data-bogus attribute'],
+ ['c\n', 'unmappable-html at /content/0/content/1: takes no style attribute'],
+ ['c
d
\n', 'unmappable-html at /content/0/content/1:
as written here is no inline element of the dialect: found "
d
\n', 'unmappable-html at /content/0/content/0: takes no class attribute'],
+ ['\n', 'unmappable-html at /content/0/content/0: an holds src, or class="adf-media" where its media holds no url, and never both'],
+ ['\n', 'unmappable-html at /content/0/content/0: an in the dialect has class="adf-media" or none'],
+ ['\n', 'unmappable-html at /content/0/content/0: an with src leaves out data-type where its media is external'],
+ ['\n', 'unsupported-node-shape at /content/0/content/0: takes no data-bogus attribute'],
+ ['\n', 'unmappable-html at /content/0:
takes no other attribute: found "
\n', 'unmappable-html at /content/0/content/0: a media group holds files: found "
\\n"'],
+ ['
\n', 'unmappable-html at /content/0/content/0: a media group holds files: found "<"…'],
+ ['
\n', 'unsupported-node-shape at /content/0/content/1: takes no data-bogus attribute'],
+ ['
x
\n', 'unmappable-html at /content/0/content/0: holds nothing, and ends at : found "x
\\n"'],
+ ['
x
\n', 'unmappable-html at /content/0:
holds its files, then
: found "x
\\n"'],
+ ['
a
\n', 'unmappable-html at /content/0: style on
holds text-align:center or text-align:right'],
+ ['
a
\n', 'unmappable-html at /content/0: style on
holds text-align:center or text-align:right'],
+ ['
a b
\n', 'unmappable-html at /content/0/content/1: a of the dialect is a carry element, holding class="adf-carry" and then data-adf alone, or opens with class="adf-emoji", "adf-mention" or "adf-status": found ""…'],
+]
+
+for (const [html, expected] of pinnedRefusals) {
+ test(`refuses with its code, path and message: ${JSON.stringify(html)}`, () => {
+ const result = htmlToAdf(html)
+ assert.equal(result.ok ? 'read' : `${result.error.code} at /${result.error.path.join('/')}: ${result.error.message}`, expected)
+ })
+}
+
// The documents adfToHtml's own tests write, by what each holds.
const written: Readonly> = {
'a panel holding a code block': document({ attrs: { panelType: 'info' }, content: [paragraph(text('Run this:')), { attrs: { language: 'python' }, content: [text('if ready:\n deploy()')], type: 'codeBlock' }], type: 'panel' }),
diff --git a/src/html/parse/task-item.ts b/src/html/parse/task-item.ts
index fb89f72..d58a473 100644
--- a/src/html/parse/task-item.ts
+++ b/src/html/parse/task-item.ts
@@ -47,8 +47,7 @@ function readItemAttributes(list: TaskListType, pairs: readonly (readonly [strin
const data = readDataAttributes(rest, 'li', itemAttributes, [])
if (data.fault !== undefined) return { fault: data.fault }
if (list === 'decisionList') return { value: { attrs: data.value, done: undefined } }
- const state = data.value['state']
- const done = typeof state === 'string' ? taskStates.get(state) : undefined
+ const done = taskStates.get(data.value['state'])
if (done === undefined) return { fault: { code: 'unmappable-html', message: 'an
of a task list has data-state="DONE" or data-state="TODO"' } }
return { value: { attrs: data.value, done } }
}
diff --git a/src/html/task-element.ts b/src/html/task-element.ts
index 2f05a2d..22abc6a 100644
--- a/src/html/task-element.ts
+++ b/src/html/task-element.ts
@@ -1,10 +1,11 @@
import type { AdfNode } from '../adf/document.ts'
+import type { JsonValue } from '../json-value.ts'
import { dataAttributes } from './data-attributes.ts'
import { nodeAttrs } from '../adf/document.ts'
import { taskLists, type TaskListType } from './block-classes.ts'
// A task item's two states, and whether the checkbox before its text is checked.
-export const taskStates: ReadonlyMap = new Map([
+export const taskStates: ReadonlyMap = new Map([
['DONE', true],
['TODO', false],
])
@@ -16,7 +17,6 @@ export function itemOpener(list: TaskListType, item: AdfNode): { attributes: str
if (data === undefined) return undefined
const attributes = ` class="${itemClass}"${data}`
if (list === 'decisionList') return { attributes, lead: '' }
- const state = nodeAttrs(item)['state']
- const done = typeof state === 'string' ? taskStates.get(state) : undefined
+ const done = taskStates.get(nodeAttrs(item)['state'])
return done === undefined ? undefined : { attributes, lead: `` }
}