3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 23:25:43 +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) => ({