3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Answer stability round 2: 0 🔴, 1 🟡 (0 misread); read the document carry whatever whitespace parts its macros

This commit is contained in:
2026-11-17 07:28:48 +01:00
committed by Lillem4n
parent 57909974a6
commit 6f80ac6351
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -345,5 +345,5 @@ test('names the line of a refusal after empty lines', () => {
})
test('reads the carry of a document holding no content key, whatever whitespace surrounds it', () => {
for (const around of ['\n', '\r\n', ' ']) assert.deepEqual(jiraWikiToAdf(`${around}{adf:display=block}\n{"type":"doc","version":1}\n{adf}${around}`), { ok: true, value: { type: 'doc', version: 1 } })
for (const around of ['\n', '\r\n', ' ']) assert.deepEqual(jiraWikiToAdf(`${around}{adf:display=block}${around}{"type":"doc","version":1}${around}{adf}${around}`), { ok: true, value: { type: 'doc', version: 1 } })
})
+2 -2
View File
@@ -24,7 +24,7 @@ type Reading = { containers: Container[]; levels: Level[]; paragraph: AdfNode[]
const codeMacro = /\{(code|noformat)(?::([^}\n]*))?\}/y
const codeEdge = /\r?\n|/y
const documentCarry = '{adf:display=block}\n{"type":"doc","version":1}\n{adf}'
const documentCarry = /^\s*\{adf:display=block\}\s*\{"type":"doc","version":1\}\s*\{adf\}\s*$/
const image = /^!([^\s!|]+)(?:\|([^!]*))?!$/
const itemMarker = /^([*#]+|-) +/
const lineSpace = /[^\S\n]*/y
@@ -39,7 +39,7 @@ export function jiraWikiToAdf(wiki: string): Result<AdfDocument, ParseError> {
function readWiki(wiki: string): Result<AdfDocument> {
if (typeof wiki !== 'string') return notAString(wiki, 'Jira wiki markup')
if (wiki.trim() === documentCarry) return success({ type: 'doc', version: 1 })
if (documentCarry.test(wiki)) return success({ type: 'doc', version: 1 })
const root: Container = { content: [], kind: 'document' }
const reading: Reading = { containers: [root], levels: [], paragraph: undefined, rows: undefined, wiki }
let at = 0