diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index e0bfe90795638bd16c0fa35332a78b4bab82f36a..8499dd0d39be16fff78608a5bb2325e74910d1fd 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -4,6 +4,12 @@ This document provides a summary of all notable changes to Antora Assembler by release. For a detailed view of what's changed, refer to the {url-repo}/commits[commit history] of this project. +== Unreleased + +=== Fixed + +* preserve empty line in multiline attribute entry that follows line with value continuation (#130) + == 1.0.0-beta.9 (2025-10-14) === Changed diff --git a/packages/assembler/lib/produce-assembly-file.js b/packages/assembler/lib/produce-assembly-file.js index d9d8d6938576d706432278ea5169a3d0b6e217aa..ce4525012161d47e0dd5e268cae569f48bfb21c9 100644 --- a/packages/assembler/lib/produce-assembly-file.js +++ b/packages/assembler/lib/produce-assembly-file.js @@ -666,12 +666,8 @@ function processDocumentHeader (doc, lines, buffer, ignoreLines) { } const line = lines[idx] if (open === ':' || open === '-:') { - if (line) { - if (open === ':') buffer.push(line) - if (!line.endsWith(' \\')) open = undefined - } else { - open = undefined - } + if (open === ':') buffer.push(line) + if (!line || !line.endsWith(' \\')) open = undefined } else if (line) { const chr0 = line.charAt() let attributeEntryMatch @@ -687,7 +683,7 @@ function processDocumentHeader (doc, lines, buffer, ignoreLines) { } else if (chr0 === ':' && ~line.indexOf(':', 2) && (attributeEntryMatch = line.match(AttributeEntryRx))) { const attributeName = attributeEntryMatch[1].replace('!', '') if (DiscardAttributes.includes(attributeName)) { - if (line.endsWith(' \\')) open = '-:' + if (line.endsWith(' \\')) open = '-:' // disallow value continuation } else { if (line.endsWith(' \\')) open = ':' buffer.push(line) diff --git a/packages/assembler/test/produce-assembly-files-test.js b/packages/assembler/test/produce-assembly-files-test.js index 5327dece586843491a36de5b62e295bd5c4d22e4..8a146901bde6ad6e22190266df5f838a4a961a01 100644 --- a/packages/assembler/test/produce-assembly-files-test.js +++ b/packages/assembler/test/produce-assembly-files-test.js @@ -314,6 +314,10 @@ describe('produceAssemblyFiles()', () => { await runScenario('process-lines-around-doctitle', __dirname) }) + it('should preserve multiline attribute entries', async () => { + await runScenario('preserve-multiline-attribute-entries', __dirname) + }) + it('should promote value of assembly-style attribute to block style on section for page', async () => { await runScenario('assembly-style', __dirname) }) diff --git a/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/data.yml b/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/data.yml new file mode 100644 index 0000000000000000000000000000000000000000..a602252c539f16aec1dba6a551af106429be4014 --- /dev/null +++ b/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/data.yml @@ -0,0 +1,19 @@ +name: the-component +version: '1.0' +title: The Component +navigation: + items: + - content: xref:the-page.adoc[] +files: +- relative: the-page.adoc + contents: |- + = The Page Title + :bars: fizz + \ + buzz + \ + rat-a-tat + :references: foo \ + bar \ + + :revised-date: 2025-01-01 + + contents diff --git a/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/expects/index.adoc b/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/expects/index.adoc new file mode 100644 index 0000000000000000000000000000000000000000..1429e2c039d519e86004cc1e4460cf9e25c64faf --- /dev/null +++ b/packages/assembler/test/scenarios/preserve-multiline-attribute-entries/expects/index.adoc @@ -0,0 +1,33 @@ += The Component +:revnumber: 1.0 +:doctype: book +:underscore: _ +:page-component-name: the-component +:page-component-version: 1.0 +:page-version: {page-component-version} +:page-component-display-version: 1.0 +:page-component-title: The Component + +:docname: the-page +:page-module: ROOT +:page-relative-src-path: the-page.adoc +:page-origin-url: https://github.com/acme/the-component +:page-origin-start-path: +:page-origin-refname: v1.0 +:page-origin-reftype: branch +:page-origin-refhash: a00000000000000000000000000000000000000z +:bars: fizz + \ +buzz + \ +rat-a-tat +:references: foo \ +bar \ + +:revised-date: 2025-01-01 +[#the-page] +== The Page Title + +contents + +:!bars: +:!references: +:!revised-date: