@antora/assembler 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -171,22 +171,10 @@ function aggregateAsciiDoc (
|
|
|
171
171
|
const ignoreLines = []
|
|
172
172
|
// TODO: think more about when multipart is allowed; perhaps configurable
|
|
173
173
|
if (doc.hasSections()) fixSectionLevels(doc.getSections(), level === 0)
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
accum.push(block)
|
|
179
|
-
if (block.getContext() === 'table') {
|
|
180
|
-
const rows = block.rows
|
|
181
|
-
;[...rows.body, ...rows.foot].forEach((row) => {
|
|
182
|
-
row.forEach((cell) => {
|
|
183
|
-
if (cell.style !== 'asciidoc') return
|
|
184
|
-
accum.push(...cell.inner_document.findBy((it) => it.getContext() !== 'document'))
|
|
185
|
-
})
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
return accum
|
|
189
|
-
}, [])
|
|
174
|
+
const allBlocks = doc.findBy(
|
|
175
|
+
{ traverse_documents: true },
|
|
176
|
+
(it) => it.getContext() !== 'document' && !(it.getContext() === 'table_cell' && it.getStyle() === 'asciidoc')
|
|
177
|
+
)
|
|
190
178
|
allBlocks.forEach((block) => {
|
|
191
179
|
const contentModel = block.content_model
|
|
192
180
|
if (
|
|
@@ -301,6 +289,7 @@ function aggregateAsciiDoc (
|
|
|
301
289
|
// NOTE: need to do this last since it modifies the line numbers
|
|
302
290
|
// we could remap the line numbers to make them resilient
|
|
303
291
|
// or we could mark which lines to remove and filter them after
|
|
292
|
+
let lastImageMacroAt
|
|
304
293
|
;[...allBlocks].reverse().forEach((block) => {
|
|
305
294
|
const lineno = block.getLineNumber()
|
|
306
295
|
// NOTE: lineno is not defined for preamble
|
|
@@ -327,33 +316,34 @@ function aggregateAsciiDoc (
|
|
|
327
316
|
if (block.getId()) rewriteStyleAttribute(block, lines, idx, idprefix, blockStyle)
|
|
328
317
|
} else {
|
|
329
318
|
if (context === 'image') {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
//
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
319
|
+
let line = lines[idx] || ''
|
|
320
|
+
let prefix = ''
|
|
321
|
+
// Q: can we use startsWith('image::') in certain cases?
|
|
322
|
+
let imageMacroOffset = (
|
|
323
|
+
lastImageMacroAt && lastImageMacroAt[0] === idx ? line.substr(0, lastImageMacroAt[1]) : line
|
|
324
|
+
).lastIndexOf('image::')
|
|
325
|
+
if (imageMacroOffset > 0) {
|
|
326
|
+
if (
|
|
327
|
+
block.getParent().getContext() === 'document' &&
|
|
328
|
+
block.getParent().isNested() &&
|
|
329
|
+
(prefix = line.substr(0, imageMacroOffset)).trimRight().endsWith('|')
|
|
330
|
+
) {
|
|
331
|
+
line = line.substr(prefix.length)
|
|
332
|
+
} else {
|
|
333
|
+
imageMacroOffset = -1
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (imageMacroOffset >= 0) {
|
|
337
|
+
const target = block.getAttribute('target')
|
|
338
|
+
if (isResourceSpec(target)) {
|
|
339
|
+
const image = contentCatalog.resolveResource(target, page.src, 'image', ['image'])
|
|
340
|
+
// FIXME: handle (or report) case when image is not resolved
|
|
341
|
+
if (image) {
|
|
342
|
+
lines[idx] = `${prefix}image::${image.pub.url.substr(1)}${line.substr(line.indexOf('['))}`
|
|
343
|
+
image.out.assembled = true
|
|
344
|
+
}
|
|
356
345
|
}
|
|
346
|
+
lastImageMacroAt = [idx, imageMacroOffset]
|
|
357
347
|
}
|
|
358
348
|
}
|
|
359
349
|
if (block.getId()) rewriteStyleAttribute(block, lines, idx, idprefix)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/assembler",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "An extension library for Antora that assembles content from multiple pages into a single AsciiDoc file to converted and publish.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|