3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-12 11:48:29 +01:00

Answer prose round 1: 0 🔴, 10 🟡 (0 misread); say the HTML is read as a browser spells it, wherever it said exactly

This commit is contained in:
2026-10-31 02:13:10 +01:00
committed by Lillem4n
parent b9991fff59
commit 73c262c5e8
6 changed files with 31 additions and 30 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ try {
const { adfToHtml, adfToLosslessMarkdown, htmlToAdf, isAdfDocument, losslessMarkdownToAdf } = 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)
// The page's own innerHTML is what a viewer/editor app posts back, so htmlToAdf reads what the browser writes.
// A viewer/editor app posts the page's innerHTML back, so htmlToAdf must read what the browser writes.
const throughInnerHtml = (adf) => {
const html = adfToHtml(adf)
if (!html.ok) return { parsed: html }
+2 -2
View File
@@ -70,7 +70,7 @@ async function whenDriverAnswers() {
}
}
// Text the browser's innerHTML spells other than adfToHtml does (WHATWG HTML §13.3): a raw ", &nbsp;, and in an attribute < 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.
const text = (value, ...marks) => (marks.length === 0 ? { text: value, type: 'text' } : { marks, text: value, type: 'text' })
const browserDocuments = [
{
@@ -175,5 +175,5 @@ for (const [index, { name }] of corpus.errors.entries()) {
}
console.log(
`Firefox ${session.capabilities.browserVersion} converted ${corpus.roundTrip.length} round-trip, ${corpus.normalization.length} normalization and ${corpus.errors.length} error fixtures, ${corpus.realPayloads.length} real payloads and ${corpus.browserDocuments.length} documents through innerHTML`,
`Firefox ${session.capabilities.browserVersion} converted ${corpus.roundTrip.length} round-trip, ${corpus.normalization.length} normalization and ${corpus.errors.length} error fixtures, ${corpus.realPayloads.length} real payloads, and read the real payloads and ${corpus.browserDocuments.length} hand-built document(s) back through innerHTML`,
)