From 6f80ac63513206a45687bbf43e998c8b9526bd1f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 17 Nov 2026 07:28:48 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20read=20the?= =?UTF-8?q?=20document=20carry=20whatever=20whitespace=20parts=20its=20mac?= =?UTF-8?q?ros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wiki/parse/jira-wiki-to-adf.test.ts | 2 +- src/wiki/parse/jira-wiki-to-adf.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wiki/parse/jira-wiki-to-adf.test.ts b/src/wiki/parse/jira-wiki-to-adf.test.ts index 6fe1fe8..512813f 100644 --- a/src/wiki/parse/jira-wiki-to-adf.test.ts +++ b/src/wiki/parse/jira-wiki-to-adf.test.ts @@ -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 } }) }) diff --git a/src/wiki/parse/jira-wiki-to-adf.ts b/src/wiki/parse/jira-wiki-to-adf.ts index 526a316..1bc5cea 100644 --- a/src/wiki/parse/jira-wiki-to-adf.ts +++ b/src/wiki/parse/jira-wiki-to-adf.ts @@ -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 { function readWiki(wiki: string): Result { 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