3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 07:05:44 +01:00

Answer stability round 1: 0 🔴, 2 🟡 (0 misread); open every expand in the browser leg, pin the indentation refusals with their messages

This commit is contained in:
2026-11-15 12:29:56 +01:00
committed by Lillem4n
parent 617ad5ea46
commit 14b5a25452
3 changed files with 16 additions and 5 deletions
+2 -1
View File
@@ -2,12 +2,13 @@ try {
const { adfToHtml, adfToLosslessMarkdown, htmlToAdf, losslessMarkdownToAdf, readAdfDocument } = await import('/dist/index.js')
// WebDriver's JSON reads -0 back as 0, so a document crosses as JSON text with -0 tagged; run.js revives it.
const spelled = (result) => (result.ok ? { ok: true, value: JSON.stringify(result.value, (_, value) => (Object.is(value, -0) ? '\u0000-0' : value)) } : result)
// A viewer/editor app posts the page's innerHTML back, so htmlToAdf must read what the browser writes.
// A viewer/editor app posts the page's innerHTML back, so htmlToAdf must read what the browser writes, an expand its user opened included.
const throughInnerHtml = (adf) => {
const html = adfToHtml(adf)
if (!html.ok) return { parsed: html }
const page = document.createElement('div')
page.innerHTML = html.value
for (const details of page.querySelectorAll('details')) details.open = true
return { parsed: spelled(htmlToAdf(page.innerHTML)) }
}
window.convertCorpus = (corpus) => ({
+9 -1
View File
@@ -70,7 +70,7 @@ async function whenDriverAnswers() {
}
}
// Documents holding what a browser's innerHTML spells other than adfToHtml does (WHATWG HTML §13.3): a raw ", &nbsp;, and in an attribute value < and > escaped or not, by version.
// Documents holding what a browser's innerHTML spells other than adfToHtml does (WHATWG HTML §13.3): a raw ", &nbsp;, and in an attribute value < and > escaped or not, by version. convert-corpus.js opens every expand before it reads innerHTML.
const text = (value, ...marks) => (marks.length === 0 ? { text: value, type: 'text' } : { marks, text: value, type: 'text' })
const browserDocuments = [
{
@@ -86,6 +86,14 @@ const browserDocuments = [
}),
name: 'quotes, no-break spaces and angle brackets',
},
{
json: JSON.stringify({
content: [{ attrs: { localId: '0199f4c2-8b1e-7d03-9a6f-2c5e8d71b4a0', title: 'More' }, content: [{ content: [text('Hidden')], type: 'paragraph' }], type: 'expand' }],
type: 'doc',
version: 1,
}),
name: 'an expand its user opened',
},
]
const corpus = {
browserDocuments,