@antora/assembler 1.0.0-rc.7 → 1.0.0-rc.9
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.
- package/lib/assemble-content.js +8 -1
- package/lib/compile-conversion-attributes.js +7 -4
- package/lib/constants.js +1 -0
- package/lib/log-command.js +3 -5
- package/lib/produce-assembly-file.js +75 -81
- package/lib/produce-assembly-files.js +14 -16
- package/lib/util/identify-mutable-attributes.js +1 -1
- package/lib/util/rewriter.js +1 -1
- package/package.json +4 -4
package/lib/assemble-content.js
CHANGED
|
@@ -78,7 +78,13 @@ async function assembleContent (playbook, contentCatalog, converter, providers)
|
|
|
78
78
|
buildConfig.command ??= typeof getDefaultCommand === 'function' ? await getDefaultCommand(cwd, playbook) : null
|
|
79
79
|
const { publishSite: publishFiles = context.require('@antora/site-publisher') } = generatorFunctions
|
|
80
80
|
await prepareWorkspace(publishFiles, assemblyFiles, buildConfig)
|
|
81
|
-
const helpers = {
|
|
81
|
+
const helpers = { runCommand }
|
|
82
|
+
Object.defineProperty(helpers, 'logger', {
|
|
83
|
+
get: () => context?.getLogger(loggerName),
|
|
84
|
+
})
|
|
85
|
+
Object.defineProperty(helpers, 'logCommand', {
|
|
86
|
+
get: () => logCommand.bind(null, helpers.logger),
|
|
87
|
+
})
|
|
82
88
|
const boundConvert = convert.bind(context)
|
|
83
89
|
const boundResolveFileOrContents = resolveFileOrContents.bind(context)
|
|
84
90
|
return new PromiseQueue({ concurrency: buildConfig.processLimit })
|
|
@@ -116,6 +122,7 @@ async function assembleContent (playbook, contentCatalog, converter, providers)
|
|
|
116
122
|
const assemblerMeta = (page.assembler ??= {})
|
|
117
123
|
const exports = (assemblerMeta.exports ??= [])
|
|
118
124
|
const exportEntry = { fragment, file }
|
|
125
|
+
if (fragment === pages.rootPageFragment) exportEntry.root = true
|
|
119
126
|
const insertIdx = exports.findIndex(
|
|
120
127
|
({ file: candidate }) =>
|
|
121
128
|
!(candidate.src.component === page.src.component && candidate.src.version === page.src.version)
|
|
@@ -12,16 +12,19 @@ async function compileConversionAttributes (doc, targetExtname, assemblerConfig,
|
|
|
12
12
|
} = doc
|
|
13
13
|
const { cwd = process.cwd(), dir = cwd, mkdirs } = assemblerConfig.build
|
|
14
14
|
const docname = family + '$' + relative.substring(0, relative.length - docfilesuffix.length)
|
|
15
|
-
const docfile = ospath.join(dir, reldocfile)
|
|
15
|
+
const docfile = (doc.src.path = ospath.join(dir, reldocfile))
|
|
16
16
|
const outdir = ospath.dirname(docfile)
|
|
17
17
|
const outfile = docfile.substring(0, docfile.length - docfilesuffix.length) + targetExtname
|
|
18
|
+
const docdir = relativeToOutput ? dir : outdir
|
|
19
|
+
//const imagesoutdir = ospath.join(outdir, '..', '_images/generated')
|
|
20
|
+
const imagesoutdir = outdir
|
|
18
21
|
const attributes = Object.assign({ revdate: `${assemblerConfig.assembly.revdate}@` }, docAttributes, {
|
|
19
|
-
docdir
|
|
22
|
+
docdir,
|
|
20
23
|
docfile,
|
|
21
24
|
docfilesuffix,
|
|
22
|
-
docname
|
|
25
|
+
docname,
|
|
23
26
|
imagesdir: '',
|
|
24
|
-
imagesoutdir
|
|
27
|
+
imagesoutdir,
|
|
25
28
|
outdir,
|
|
26
29
|
outfile,
|
|
27
30
|
outfilesuffix: targetExtname,
|
package/lib/constants.js
CHANGED
package/lib/log-command.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
function logCommand (
|
|
4
|
-
const logger = this?.getLogger(loggerName)
|
|
3
|
+
function logCommand (logger, command, extraArgsOrAttributeOptionFlag, file, attributes) {
|
|
5
4
|
if (!logger?.isLevelEnabled('debug')) return
|
|
6
|
-
const { docfile, 'assembler-filetype': filetype } = attributes
|
|
7
5
|
const args = (
|
|
8
6
|
Array.isArray(extraArgsOrAttributeOptionFlag)
|
|
9
7
|
? extraArgsOrAttributeOptionFlag
|
|
@@ -11,10 +9,10 @@ function logCommand (loggerName, command, extraArgsOrAttributeOptionFlag, file,
|
|
|
11
9
|
? attributes.toArgs(extraArgsOrAttributeOptionFlag)
|
|
12
10
|
: []
|
|
13
11
|
).map((it) => (~it.indexOf(' ') ? `'${it}'` : it))
|
|
14
|
-
const ctx = { command: [command].concat(args).join(' '), file:
|
|
12
|
+
const ctx = { command: [command].concat(args).join(' '), file: file.src }
|
|
15
13
|
const msg = `Running external command to export assembly in %s to %s: %s`
|
|
16
14
|
const componentVersionStr = file.src.version ? `${file.src.version}@${file.src.component}` : file.src.component
|
|
17
|
-
logger.debug(ctx, msg, componentVersionStr, filetype, file.src.relative)
|
|
15
|
+
logger.debug(ctx, msg, componentVersionStr, attributes['assembler-filetype'], file.src.relative)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
module.exports = logCommand
|
|
@@ -44,11 +44,15 @@ function produceAssemblyFile (
|
|
|
44
44
|
const pagesByUrl = files.reduce((map, it) => (it.src.family === 'page' ? map.set(it.pub.url, it) : map), new Map())
|
|
45
45
|
const pagesInOutline = selectPagesInOutline(outline, pagesByUrl)
|
|
46
46
|
if (outline.urlType === 'internal' && !pagesByUrl.has(outline.pathname) && !outline.items?.length) return
|
|
47
|
+
const { name: component, version } = componentVersion
|
|
47
48
|
const { rootLevel, xmlIds } = assemblyModel
|
|
48
49
|
const scratchDoc = loadAsciiDoc(
|
|
49
|
-
{
|
|
50
|
+
{
|
|
51
|
+
contents: Buffer.alloc(0),
|
|
52
|
+
src: { component, version, module: 'ROOT', family: 'page', relative: '_.adoc', path: '_.adoc' },
|
|
53
|
+
},
|
|
50
54
|
undefined,
|
|
51
|
-
asciidocConfig
|
|
55
|
+
Object.assign({}, asciidocConfig, { antoraResourceRefs: false, extensions: [] })
|
|
52
56
|
)
|
|
53
57
|
const idSeparators = {
|
|
54
58
|
prefix:
|
|
@@ -57,7 +61,6 @@ function produceAssemblyFile (
|
|
|
57
61
|
coordinate: xmlIds ? '----' : ':',
|
|
58
62
|
generateIdFromTitle: generateIdFromTitle.bind(scratchDoc),
|
|
59
63
|
}
|
|
60
|
-
const { name: component, version } = componentVersion
|
|
61
64
|
asciidocConfig = prepareAsciiDocConfig(
|
|
62
65
|
contentCatalog,
|
|
63
66
|
{ component, version },
|
|
@@ -92,7 +95,7 @@ function produceAssemblyFile (
|
|
|
92
95
|
src: { component, version, componentVersion, module: 'ROOT', family: 'export', relative: stem + '.adoc' },
|
|
93
96
|
pub: false,
|
|
94
97
|
})
|
|
95
|
-
file.path = file.
|
|
98
|
+
file.path = file.out.path // use out path as path so assets can be published to same hierarchy
|
|
96
99
|
delete file.out
|
|
97
100
|
return file
|
|
98
101
|
}
|
|
@@ -220,7 +223,8 @@ function mergeAsciiDoc (
|
|
|
220
223
|
let navtitle = outlineEntry.navtitle ?? (page && hash ? page.asciidoc.navtitle : outlineEntry.content)
|
|
221
224
|
let navtitlePlain = sanitize(navtitle)
|
|
222
225
|
let navtitleAsciiDoc = unconvertInlineAsciiDoc(navtitle)
|
|
223
|
-
const { filetype, linkReferenceStyle, pubRoot,
|
|
226
|
+
const { filetype, linkReferenceStyle, pubRoot, siteRoot, logger, rootLevel, rootPageStyle } = assemblyModel
|
|
227
|
+
let sectionMergeStrategy = assemblyModel.sectionMergeStrategy
|
|
224
228
|
const doctype = assemblyModel.doctype
|
|
225
229
|
const atDocumentRoot = !builder.body?.length
|
|
226
230
|
let atBookRoot = atDocumentRoot && !level && doctype === 'book' && (supportsParts = true)
|
|
@@ -232,19 +236,12 @@ function mergeAsciiDoc (
|
|
|
232
236
|
return builder
|
|
233
237
|
}
|
|
234
238
|
const pageAsAsciiDoc = new page.constructor(
|
|
235
|
-
Object.assign({}, page, { contents:
|
|
239
|
+
Object.assign({}, page, { contents: Buffer.from(contents.toString().trimEnd()), mediaType: page.src.mediaType })
|
|
236
240
|
)
|
|
237
241
|
const doc = loadAsciiDoc(pageAsAsciiDoc, contentCatalog, asciidocConfig)
|
|
242
|
+
if (typeof doc.applyLogger === 'function') doc.applyLogger()
|
|
243
|
+
if (logger) doc.getLogger().delegate = logger
|
|
238
244
|
doc.catalog.syntheticIds = {}
|
|
239
|
-
doc.logger = logger
|
|
240
|
-
? Object.assign(doc.getLogger().$dup(), {
|
|
241
|
-
delegate: {
|
|
242
|
-
warn () {
|
|
243
|
-
return logger.warn.apply(logger, arguments)
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
})
|
|
247
|
-
: doc.getLogger()
|
|
248
245
|
doc.source_header_attributes ??= toHash()
|
|
249
246
|
const isRootPage = atDocumentRoot && !level
|
|
250
247
|
const { component, version, module: module_, relative, origin } = page.src
|
|
@@ -267,15 +264,16 @@ function mergeAsciiDoc (
|
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
266
|
}
|
|
267
|
+
const overviewTitle = doc.getAttribute('overview-title', 'Overview')
|
|
270
268
|
// NOTE: in Antora, docname is relative src path from module without file extension
|
|
271
269
|
const docname = doc.getAttribute('docname')
|
|
272
270
|
const pageId = generateScopedId(page.src, componentVersion, idSeparators, filetype)
|
|
273
271
|
const pageIdLeader = pageId + idSeparators.scope
|
|
274
|
-
let pageFragment =
|
|
272
|
+
let pageFragment = `#${pageId}`
|
|
275
273
|
let pageRoles = []
|
|
276
274
|
let pageStyle = doc.getAttribute('assembly-style', '')
|
|
277
|
-
if (!pageStyle &&
|
|
278
|
-
pageStyle = '
|
|
275
|
+
if (!pageStyle && isRootPage && !doc.source_header_attributes['$key?']('assembly-style')) {
|
|
276
|
+
pageStyle = rootPageStyle || ''
|
|
279
277
|
}
|
|
280
278
|
let part
|
|
281
279
|
if ((part = pageStyle === 'part')) {
|
|
@@ -286,45 +284,27 @@ function mergeAsciiDoc (
|
|
|
286
284
|
if (!supportsParts) part = undefined
|
|
287
285
|
}
|
|
288
286
|
const hasSections = doc.hasSections()
|
|
287
|
+
const encloseSections = sectionMergeStrategy === 'enclose' && hasItems && hasSections
|
|
289
288
|
let nextSectionLevel = 1
|
|
290
289
|
const lines = doc.getSourceLines()
|
|
291
290
|
const ignoreLines = []
|
|
292
291
|
const buffer = (builder.body ??= [])
|
|
293
292
|
if (buffer.length) buffer.push('')
|
|
294
|
-
buffer.push(`:docname: ${docname}`)
|
|
295
|
-
if (component !== builder.currentComponentVersion.name) {
|
|
296
|
-
const thisComponentVersion =
|
|
297
|
-
component === componentVersion.name && version === componentVersion.version
|
|
298
|
-
? componentVersion
|
|
299
|
-
: contentCatalog.getComponentVersion(component, version)
|
|
300
|
-
if (thisComponentVersion) {
|
|
301
|
-
buffer.push(`:page-component-name: ${thisComponentVersion.name}`)
|
|
302
|
-
buffer.push(`:page-component-version:${thisComponentVersion.version ? ' ' + thisComponentVersion.version : ''}`)
|
|
303
|
-
buffer.push(':page-version: {page-component-version}')
|
|
304
|
-
buffer.push(`:page-component-display-version: ${thisComponentVersion.displayVersion}`)
|
|
305
|
-
buffer.push(`:page-component-title: ${thisComponentVersion.title}`)
|
|
306
|
-
builder.currentComponentVersion = thisComponentVersion
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
buffer.push(`:page-module: ${module_}`)
|
|
310
|
-
buffer.push(`:page-relative-src-path: ${relative}`)
|
|
311
|
-
buffer.push(`:page-origin-url: ${origin.url}`)
|
|
312
|
-
buffer.push(`:page-origin-start-path:${origin.startPath && ' '}${origin.startPath}`)
|
|
313
|
-
buffer.push(`:page-origin-refname: ${origin.branch || origin.tag}`)
|
|
314
|
-
buffer.push(`:page-origin-reftype: ${origin.branch ? 'branch' : 'tag'}`)
|
|
315
|
-
buffer.push(`:page-origin-refhash: ${origin.worktree ? '(worktree)' : origin.refhash}`)
|
|
316
293
|
if (doc.hasHeader()) {
|
|
317
294
|
for (const entry of processDocumentHeader(doc, lines, ignoreLines, isRootPage)) {
|
|
318
295
|
if (entry.type === 'author_line') {
|
|
319
296
|
builder.setAuthor(entry.lines[0])
|
|
320
297
|
} else if (entry.type === 'attribute_entry') {
|
|
321
298
|
const name = entry.name
|
|
322
|
-
if (
|
|
299
|
+
if (entry.negated && name === 'sectnums') {
|
|
300
|
+
// catch sectnums missed by reducer; only allow turned off, not turning on
|
|
301
|
+
doc.source_header_attributes['$[]=']('sectnums', null)
|
|
302
|
+
} else if (!entry.negated && !doc.isAttributeLocked(name)) {
|
|
323
303
|
let val, newVal
|
|
324
304
|
if (
|
|
325
305
|
name.endsWith('-image') &&
|
|
326
306
|
(val = doc.getAttribute(name)) &&
|
|
327
|
-
(newVal = rewriteImageAttr(val, contentCatalog, assemblyModel, page.src, assembled.assets))
|
|
307
|
+
(newVal = rewriteImageAttr(val, contentCatalog, assemblyModel, page.src, assembled.assets)) != null
|
|
328
308
|
) {
|
|
329
309
|
if (newVal !== val) entry.lines = [`:${name}: ${newVal}`]
|
|
330
310
|
} else if (~(val = entry.lines.join('\n').substring(name.length + 3)).indexOf(':')) {
|
|
@@ -366,62 +346,93 @@ function mergeAsciiDoc (
|
|
|
366
346
|
pageRoles = doc.getRoles()
|
|
367
347
|
}
|
|
368
348
|
if (roles.length) pageRoles = pageRoles.concat(roles[0] === 'page' ? roles.slice(1) : roles)
|
|
349
|
+
buffer.push(`:page-docname: ${docname}`)
|
|
350
|
+
if (component !== builder.currentComponentVersion.name) {
|
|
351
|
+
const thisComponentVersion =
|
|
352
|
+
component === componentVersion.name && version === componentVersion.version
|
|
353
|
+
? componentVersion
|
|
354
|
+
: contentCatalog.getComponentVersion(component, version)
|
|
355
|
+
if (thisComponentVersion) {
|
|
356
|
+
buffer.push(`:page-component-name: ${thisComponentVersion.name}`)
|
|
357
|
+
buffer.push(`:page-component-version:${thisComponentVersion.version ? ' ' + thisComponentVersion.version : ''}`)
|
|
358
|
+
buffer.push(':page-version: {page-component-version}')
|
|
359
|
+
buffer.push(`:page-component-display-version: ${thisComponentVersion.displayVersion}`)
|
|
360
|
+
buffer.push(`:page-component-title: ${thisComponentVersion.title}`)
|
|
361
|
+
builder.currentComponentVersion = thisComponentVersion
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
buffer.push(`:page-module: ${module_}`)
|
|
365
|
+
buffer.push(`:page-relative-src-path: ${relative}`)
|
|
366
|
+
buffer.push(`:page-origin-url: ${origin.url}`)
|
|
367
|
+
buffer.push(`:page-origin-start-path:${origin.startPath && ' '}${origin.startPath}`)
|
|
368
|
+
buffer.push(`:page-origin-refname: ${origin.branch || origin.tag}`)
|
|
369
|
+
buffer.push(`:page-origin-reftype: ${origin.branch ? 'branch' : 'tag'}`)
|
|
370
|
+
buffer.push(`:page-origin-refhash: ${origin.worktree ? '(worktree)' : origin.refhash}`)
|
|
369
371
|
let heading
|
|
370
372
|
if (pageStyle && (part && level === 1 ? (level = 0) : level) === 0) {
|
|
371
373
|
let htitleAsciiDoc = navtitleAsciiDoc
|
|
372
|
-
let notitle
|
|
373
374
|
if (pageStyle === 'preface') {
|
|
374
375
|
const hasPrefaceTitleAttr =
|
|
375
376
|
doc.isAttribute('preface-title') ||
|
|
376
377
|
doc.source_header_attributes['$key?']('preface-title') ||
|
|
377
378
|
doc.isAttributeLocked('preface-title')
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
let htitleOverride
|
|
380
|
+
if (hasPrefaceTitleAttr) {
|
|
381
|
+
htitleOverride = doc.getAttribute('preface-title', '')
|
|
382
|
+
} else if (encloseSections && !hasAssemblyNavtitleAttr) {
|
|
383
|
+
htitleOverride = overviewTitle
|
|
384
|
+
} else if (atDocumentRoot && (rootLevel ? true : !hasAssemblyNavtitleAttr)) {
|
|
385
|
+
htitleOverride = ''
|
|
386
|
+
}
|
|
387
|
+
const usePrefaceTitleAttr = hasPrefaceTitleAttr && atBookRoot
|
|
383
388
|
if (htitleOverride != null) {
|
|
384
|
-
const
|
|
389
|
+
const hasSectionsInAssembly = hasSections && sectionMergeStrategy !== 'discrete'
|
|
385
390
|
if (htitleOverride === '') {
|
|
386
|
-
|
|
391
|
+
nextSectionLevel = 2
|
|
392
|
+
sectionMergeStrategy = 'discrete'
|
|
393
|
+
if (builder.headerHasBlockAttrs) {
|
|
387
394
|
htitleAsciiDoc = '{empty}'
|
|
388
|
-
notitle = true
|
|
389
395
|
} else {
|
|
390
|
-
if (
|
|
396
|
+
if (usePrefaceTitleAttr) builder.header.push(':preface-title:')
|
|
391
397
|
htitleAsciiDoc = undefined
|
|
392
398
|
}
|
|
393
|
-
} else if (
|
|
399
|
+
} else if (usePrefaceTitleAttr && !(builder.headerHasBlockAttrs || hasSectionsInAssembly)) {
|
|
394
400
|
builder.header.push(`:preface-title: ${unconvertInlineAsciiDoc(htitleOverride)}`)
|
|
395
401
|
htitleAsciiDoc = undefined
|
|
396
402
|
} else {
|
|
397
403
|
htitleAsciiDoc = unconvertInlineAsciiDoc(htitleOverride)
|
|
398
404
|
}
|
|
399
405
|
}
|
|
406
|
+
} else if (encloseSections && atDocumentRoot && !hasAssemblyNavtitleAttr) {
|
|
407
|
+
htitleAsciiDoc = unconvertInlineAsciiDoc(overviewTitle)
|
|
400
408
|
}
|
|
401
409
|
if (htitleAsciiDoc) {
|
|
402
410
|
if (atDocumentRoot) {
|
|
403
411
|
// Q: should we use htitleAsciiDoc to generate ID if not {empty} instead of pageStyle
|
|
404
412
|
pageFragment = `#_${idSeparators.coordinate}${pageIdLeader}${pageStyle}`
|
|
405
413
|
builder.setDocid(pageId)
|
|
406
|
-
|
|
407
|
-
|
|
414
|
+
if (pageStyle === 'preface' && !atBookRoot) {
|
|
415
|
+
if (doc.hasAttribute('sectnums')) {
|
|
416
|
+
doc.source_header_attributes['$[]=']('sectnums', null)
|
|
417
|
+
buffer.push(':!sectnums:')
|
|
418
|
+
}
|
|
419
|
+
pageStyle = ''
|
|
420
|
+
}
|
|
408
421
|
}
|
|
409
422
|
heading = { title: htitleAsciiDoc, level: part ? 1 : 2 }
|
|
410
|
-
if (
|
|
423
|
+
if (htitleAsciiDoc === '{empty}') heading.notitle = true
|
|
411
424
|
nextSectionLevel = 2 // next section level is 2, even for special part
|
|
412
425
|
}
|
|
413
426
|
} else if (level) {
|
|
414
427
|
if (atDocumentRoot && rootLevel === 0 && navtitlePlain === componentVersion.title && !hasAssemblyNavtitleAttr) {
|
|
415
428
|
level--
|
|
416
429
|
} else {
|
|
417
|
-
pageFragment = `#${pageId}`
|
|
418
430
|
if (part && level === 1) level--
|
|
419
431
|
if ((heading = { title: navtitleAsciiDoc, level: level + 1 }).level > 6) {
|
|
420
432
|
Object.assign(heading, { level: 6, style: `discrete.h${heading.level}` })
|
|
421
433
|
}
|
|
422
434
|
}
|
|
423
435
|
} else if (atDocumentRoot && rootLevel === 0 && hasAssemblyNavtitleAttr) {
|
|
424
|
-
pageFragment = `#${pageId}`
|
|
425
436
|
heading = { title: navtitleAsciiDoc, level: (nextSectionLevel = part ? 1 : 2) }
|
|
426
437
|
} else if (atBookRoot) {
|
|
427
438
|
nextSectionLevel = undefined
|
|
@@ -434,11 +445,9 @@ function mergeAsciiDoc (
|
|
|
434
445
|
} else if (atDocumentRoot) {
|
|
435
446
|
builder.setDocid(pageId)
|
|
436
447
|
}
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
//if (overviewTitle === navtitle) overviewTitle = doc.getAttribute('overview-title', 'Overview')
|
|
441
|
-
const overviewTitle = doc.getAttribute('overview-title', 'Overview')
|
|
448
|
+
if (isRootPage || (atDocumentRoot && !heading)) assembled.pages.rootPageFragment = pageFragment
|
|
449
|
+
assembled.pages.set(page, pageFragment)
|
|
450
|
+
if (encloseSections && !(atDocumentRoot && heading)) {
|
|
442
451
|
const syntheticId = idSeparators.generateIdFromTitle(overviewTitle, idSeparators, pageIdLeader)
|
|
443
452
|
if (heading && buffer.length) buffer.push('')
|
|
444
453
|
let hlevel = level + (nextSectionLevel = 2)
|
|
@@ -451,7 +460,6 @@ function mergeAsciiDoc (
|
|
|
451
460
|
}
|
|
452
461
|
buffer.push(`${'='.repeat(hlevel)} ${overviewTitle}`)
|
|
453
462
|
}
|
|
454
|
-
assembled.pages.set(page, pageFragment)
|
|
455
463
|
if (hasSections) fixSectionLevels(doc.getSections(), nextSectionLevel)
|
|
456
464
|
const allBlocks = doc.findBy({ traverse_documents: true }, (it) =>
|
|
457
465
|
it.getContext() === 'document'
|
|
@@ -645,6 +653,7 @@ function mergeAsciiDoc (
|
|
|
645
653
|
)
|
|
646
654
|
if (resolvedAttributeEntries.length > 1) safePush(buffer, resolvedAttributeEntries)
|
|
647
655
|
}
|
|
656
|
+
if (typeof doc.restoreLogger === 'function') doc.restoreLogger()
|
|
648
657
|
} else if (level && !hash) {
|
|
649
658
|
const buffer = (builder.body ??= [])
|
|
650
659
|
if (atDocumentRoot && rootLevel === 0 && navtitlePlain === componentVersion.title) {
|
|
@@ -721,8 +730,7 @@ function processDocumentHeader (doc, lines, ignoreLines, isRootPage) {
|
|
|
721
730
|
}
|
|
722
731
|
assemblyHeaderAttributes.delete('%authors')
|
|
723
732
|
}
|
|
724
|
-
const
|
|
725
|
-
for (const name of assemblyHeaderAttributes) headerAttributes.$delete(name)
|
|
733
|
+
for (const name of assemblyHeaderAttributes) doc.source_header_attributes.$delete(name)
|
|
726
734
|
}
|
|
727
735
|
const doctitleIdx = doc.getHeader().getLineNumber() - 1
|
|
728
736
|
const end = doc.getBlocks()[0]?.getLineNumber() ?? lines.length
|
|
@@ -822,24 +830,10 @@ function fixSectionLevels (sections, expectedLevel) {
|
|
|
822
830
|
})
|
|
823
831
|
}
|
|
824
832
|
|
|
825
|
-
// NOTE: blank lines at top and bottom of document create mismatch when using line numbers to navigate source lines
|
|
826
|
-
// IMPORTANT: this must not leave behind lines the parser will drop!
|
|
827
|
-
// IDEA: another option is to capture initial lineno of reader and use as offset (but preseves those blank lines)
|
|
828
|
-
function trimAsciiDoc (buffer) {
|
|
829
|
-
return Buffer.from(
|
|
830
|
-
buffer
|
|
831
|
-
.toString()
|
|
832
|
-
.replace(/^(?:[ \t]*\r\n?|[ \t]*\n)+/, '')
|
|
833
|
-
.trimRight()
|
|
834
|
-
)
|
|
835
|
-
}
|
|
836
|
-
|
|
837
833
|
function safePush (onto, entries) {
|
|
838
834
|
try {
|
|
839
835
|
onto.push(...entries)
|
|
840
|
-
} catch
|
|
841
|
-
/* istanbul ignore if */
|
|
842
|
-
if (!(err instanceof RangeError)) throw err
|
|
836
|
+
} catch {
|
|
843
837
|
for (const e of entries) onto.push(e)
|
|
844
838
|
}
|
|
845
839
|
}
|
|
@@ -18,6 +18,7 @@ function produceAssemblyFiles (
|
|
|
18
18
|
doctype: assemblyConfig.doctype,
|
|
19
19
|
insertStartPage: assemblyConfig.insertStartPage,
|
|
20
20
|
rootLevel: assemblyConfig.rootLevel,
|
|
21
|
+
rootPageStyle: assemblyConfig.rootPageStyle,
|
|
21
22
|
sectionMergeStrategy: assemblyConfig.sectionMergeStrategy,
|
|
22
23
|
navigation: componentVersion.navigation,
|
|
23
24
|
xmlIds: assemblyConfig.xmlIds,
|
|
@@ -130,7 +131,7 @@ function includedInNav (items, url) {
|
|
|
130
131
|
|
|
131
132
|
function resolveStartPage (contentCatalog, componentVersion, insertStartPage, outlineRoot) {
|
|
132
133
|
const { name: componentName, version } = componentVersion
|
|
133
|
-
|
|
134
|
+
const startPage =
|
|
134
135
|
'startPage' in componentVersion
|
|
135
136
|
? componentVersion.startPage
|
|
136
137
|
: contentCatalog.resolvePage('index.adoc', { component: componentName, version })
|
|
@@ -139,22 +140,19 @@ function resolveStartPage (contentCatalog, componentVersion, insertStartPage, ou
|
|
|
139
140
|
const navtitle = startPage.asciidoc?.navtitle || outlineRoot.content
|
|
140
141
|
Object.assign(outlineRoot, { navtitle, url: startPage.pub.url, urlType: 'internal', roles: ['page'] })
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
startPage = contentCatalog.createFile({
|
|
144
|
-
src: {
|
|
145
|
-
component: componentName,
|
|
146
|
-
version,
|
|
147
|
-
componentVersion,
|
|
148
|
-
module: 'ROOT',
|
|
149
|
-
family: 'page',
|
|
150
|
-
relative: 'index.adoc',
|
|
151
|
-
origin: componentVersion.origins?.values().next().value,
|
|
152
|
-
},
|
|
153
|
-
})
|
|
154
|
-
// FIXME remove once upgrading to Antora 3.2.0
|
|
155
|
-
startPage.path = ['modules', startPage.src.module, startPage.src.family + 's', startPage.src.relative].join('/')
|
|
143
|
+
return startPage
|
|
156
144
|
}
|
|
157
|
-
return
|
|
145
|
+
return contentCatalog.createFile({
|
|
146
|
+
src: {
|
|
147
|
+
component: componentName,
|
|
148
|
+
version,
|
|
149
|
+
componentVersion,
|
|
150
|
+
module: 'ROOT',
|
|
151
|
+
family: 'page',
|
|
152
|
+
relative: 'index.adoc',
|
|
153
|
+
origin: componentVersion.origins?.values().next().value,
|
|
154
|
+
},
|
|
155
|
+
})
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
function prepareOutlines (navigation, rootEntry, rootLevel) {
|
|
@@ -13,7 +13,7 @@ function identifyMutableAttributes (loadAsciiDoc, contentCatalog, referencePage,
|
|
|
13
13
|
Object.assign({}, referencePage, { contents: Buffer.alloc(0), mediaType: 'text/asciidoc' })
|
|
14
14
|
),
|
|
15
15
|
contentCatalog,
|
|
16
|
-
asciidocConfig
|
|
16
|
+
Object.assign({}, asciidocConfig, { extensions: [], headerOnly: true })
|
|
17
17
|
)
|
|
18
18
|
const immutableAttributeNames = doc.attribute_overrides.$keys()['$+'](['doctype'])
|
|
19
19
|
return Object.entries(doc.getAttributes()).reduce((accum, [name, val]) => {
|
package/lib/util/rewriter.js
CHANGED
|
@@ -86,7 +86,7 @@ function rewriteXref (
|
|
|
86
86
|
}
|
|
87
87
|
if (sourceLocation) {
|
|
88
88
|
const msg = `Cannot create external ${family} reference in assembly because site URL is unknown: ${rawTarget}`
|
|
89
|
-
doc.
|
|
89
|
+
doc.getLogger().warn(doc.createLogMessage(msg, { source_location: sourceLocation }))
|
|
90
90
|
}
|
|
91
91
|
} else if (~target.indexOf(':')) {
|
|
92
92
|
defaultText = rawTarget // use explicit text so AsciiDoc processor displays it correctly
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/assembler",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"description": "A JavaScript library that merges AsciiDoc content from multiple pages in an Antora site into assembly files and delegates to an exporter to convert those files to another format, such as PDF.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "OpenDevise Inc. (https://opendevise.com)",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"js-yaml": "~5.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@antora/asciidoc-loader": "3.2.0-rc.
|
|
46
|
-
"@antora/navigation-builder": "3.2.0-rc.
|
|
47
|
-
"@antora/site-publisher": "3.2.0-rc.
|
|
45
|
+
"@antora/asciidoc-loader": "3.2.0-rc.3",
|
|
46
|
+
"@antora/navigation-builder": "3.2.0-rc.3",
|
|
47
|
+
"@antora/site-publisher": "3.2.0-rc.3"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=20.0.0"
|