Keep the browser leg on dist/index.js: tag -0 in the JSON it hands back

This commit is contained in:
2026-10-03 14:44:14 +02:00
parent a565d49c24
commit 2d02165702
2 changed files with 10 additions and 6 deletions
+2 -3
View File
@@ -1,8 +1,7 @@
try {
const { adfToMarkdown, isAdfDocument, markdownToAdf } = await import('/dist/index.js')
const { serializeCanonicalJson } = await import('/dist/canonical-json.js')
// WebDriver's JSON reads -0 back as 0, so a document crosses as its canonical spelling.
const spelled = (result) => (result.ok ? { ok: true, value: `${serializeCanonicalJson(result.value, 'two-space')}\n` } : result)
// 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)
window.convertCorpus = (corpus) => ({
errors: corpus.errors.map(({ markdown, name }) => ({ name, parsed: markdownToAdf(markdown) })),
normalization: corpus.normalization.map(({ markdown, name }) => ({ name, parsed: spelled(markdownToAdf(markdown)) })),