@antora/assembler 1.0.0-rc.10 → 1.0.0-rc.12
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.
|
@@ -18,12 +18,13 @@ const ATTR_ENTRY_RX = /^:(!?[\p{Alpha}0-9_][^:]*):(?: |$)/u
|
|
|
18
18
|
const BUILT_IN_NAMED_ENTITIES = { amp: '&', apos: "'", gt: '>', lt: '<', nbsp: ' ', quot: '"' }
|
|
19
19
|
const CHAR_REF_RX = /&(?:([a-z][a-z]+\d{0,2})|#(?:(\d{2,6})|x([a-z\d]{2,5})));/g
|
|
20
20
|
const DISCARD_ATTRIBUTE_NAMES = [
|
|
21
|
+
'assembly-docname',
|
|
22
|
+
'assembly-doctitle',
|
|
21
23
|
'assembly-doctype',
|
|
22
24
|
'assembly-header-attributes',
|
|
23
25
|
'assembly-overview-title',
|
|
24
26
|
'assembly-navtitle',
|
|
25
27
|
'assembly-root-title',
|
|
26
|
-
'assembly-slug',
|
|
27
28
|
'assembly-style',
|
|
28
29
|
'doctype',
|
|
29
30
|
'leveloffset',
|
|
@@ -88,7 +89,9 @@ function produceAssemblyFile (
|
|
|
88
89
|
assemblyModel
|
|
89
90
|
)
|
|
90
91
|
const stem =
|
|
91
|
-
(builder.
|
|
92
|
+
(builder.docname
|
|
93
|
+
? sanitizeDocname(builder.docname)
|
|
94
|
+
: generateDocname(rootLevel === 0 ? 'index' : builder.baseDoctitle)) ||
|
|
92
95
|
'export-' + (assemblyModel.stemSeq = (assemblyModel.exportSeq ?? 0) + 1)
|
|
93
96
|
const downloadStem = [component, version, stem === 'index' ? '' : stem].filter((it) => it).join('-')
|
|
94
97
|
const file = contentCatalog.createFile({
|
|
@@ -147,7 +150,7 @@ function buildAssemblyHeader (componentVersion, navtitle, assemblyModel) {
|
|
|
147
150
|
const { name: componentName, version, displayVersion, title } = componentVersion
|
|
148
151
|
const navtitleAsciiDoc = unconvertInlineAsciiDoc(navtitle)
|
|
149
152
|
const navtitlePlain = sanitize(navtitle)
|
|
150
|
-
const doctitleQualifier = assemblyModel.rootLevel === 0 ?
|
|
153
|
+
const doctitleQualifier = assemblyModel.rootLevel === 0 ? undefined : title
|
|
151
154
|
const versioned = !!(version && version !== 'master')
|
|
152
155
|
return {
|
|
153
156
|
header: [
|
|
@@ -168,10 +171,10 @@ function buildAssemblyHeader (componentVersion, navtitle, assemblyModel) {
|
|
|
168
171
|
setAuthor (author) {
|
|
169
172
|
this.header.splice(1, 0, author)
|
|
170
173
|
},
|
|
171
|
-
|
|
174
|
+
updateDoctitle (doctitle, doctitleAsciiDoc, doctitlePlain, useQualifier = true) {
|
|
172
175
|
this.baseDoctitle = doctitle
|
|
173
176
|
this.baseDoctitlePlain = doctitlePlain
|
|
174
|
-
const qualifyDoctitle = this.doctitleQualifier
|
|
177
|
+
const qualifyDoctitle = useQualifier && !!this.doctitleQualifier && this.doctitleQualifier !== doctitlePlain
|
|
175
178
|
this.header[0] = `= ${qualifyDoctitle ? this.doctitleQualifier + ': ' : ''}${doctitleAsciiDoc}`
|
|
176
179
|
},
|
|
177
180
|
matchesDoctitle (candidate) {
|
|
@@ -229,15 +232,20 @@ function mergeAsciiDoc (
|
|
|
229
232
|
return builder
|
|
230
233
|
}
|
|
231
234
|
const assembled = pagesInOutline.assembled
|
|
235
|
+
const atStartOfBody = !builder.body?.length
|
|
236
|
+
const isRootEntry = atStartOfBody && !level
|
|
232
237
|
// FIXME: ideally, resource ID would be stored in navigation so we can look up the page more efficiently
|
|
233
238
|
const page = urlType === 'internal' && !unresolved ? pagesInOutline.get(pathname) : undefined
|
|
234
|
-
let navtitle = outlineEntry.
|
|
239
|
+
let navtitle = outlineEntry.content
|
|
240
|
+
if (isRootEntry && 'navtitle' in outlineEntry) {
|
|
241
|
+
navtitle = outlineEntry.navtitle
|
|
242
|
+
} else if (page && hash) {
|
|
243
|
+
navtitle = page.asciidoc.navtitle
|
|
244
|
+
}
|
|
235
245
|
let navtitleAsciiDoc = unconvertInlineAsciiDoc(navtitle)
|
|
236
246
|
let navtitlePlain = sanitize(navtitle)
|
|
237
|
-
const { doctype, filetype, linkReferenceStyle, pubRoot, siteRoot, logger, rootPageStyle } = assemblyModel
|
|
247
|
+
const { doctype, filetype, linkReferenceStyle, pubRoot, siteRoot, logger, rootLevel, rootPageStyle } = assemblyModel
|
|
238
248
|
let sectionMergeStrategy = assemblyModel.sectionMergeStrategy
|
|
239
|
-
const atStartOfBody = !builder.body?.length
|
|
240
|
-
const isRootEntry = atStartOfBody && !level
|
|
241
249
|
let atBookRoot = isRootEntry && doctype === 'book' && (supportsParts = true)
|
|
242
250
|
const hasItems = items.length > 0
|
|
243
251
|
if (page && !assembled.pages.has(page)) {
|
|
@@ -256,22 +264,32 @@ function mergeAsciiDoc (
|
|
|
256
264
|
doc.source_header_attributes ??= toHash()
|
|
257
265
|
const isRootPage = isRootEntry
|
|
258
266
|
const { component, version, module: module_, relative, origin } = page.src
|
|
259
|
-
const doctypeOverride = doc.getAttribute('assembly-doctype')
|
|
260
|
-
if (doctypeOverride) {
|
|
261
|
-
if (doctypeOverride !== doctype) builder.setDoctype(doctypeOverride)
|
|
262
|
-
if (doctypeOverride !== 'book') atBookRoot = supportsParts = false
|
|
263
|
-
}
|
|
264
|
-
if (isRootPage && doc.hasAttribute('assembly-slug')) builder.slug = doc.getAttribute('assembly-slug')
|
|
265
267
|
let hasAssemblyNavtitleAttr
|
|
266
268
|
if ((hasAssemblyNavtitleAttr = !!doc.getAttribute('assembly-navtitle'))) {
|
|
267
|
-
navtitleAsciiDoc = doc.getAttribute('assembly-navtitle')
|
|
268
|
-
navtitlePlain = sanitize((navtitle = doc.$apply_reftext_subs(navtitleAsciiDoc)))
|
|
269
|
-
if (isRootPage) builder.setDoctitle(navtitle, navtitleAsciiDoc, navtitlePlain)
|
|
269
|
+
navtitleAsciiDoc = unconvertInlineAsciiDoc(doc.getAttribute('assembly-navtitle'))
|
|
270
|
+
navtitlePlain = sanitize((navtitle = doc.$sub_attributes(doc.$apply_reftext_subs(navtitleAsciiDoc))))
|
|
270
271
|
}
|
|
271
|
-
|
|
272
|
+
if (isRootPage) {
|
|
273
|
+
const doctypeOverride = doc.getAttribute('assembly-doctype')
|
|
274
|
+
if (doctypeOverride && doctypeOverride !== doctype) {
|
|
275
|
+
builder.setDoctype(doctypeOverride)
|
|
276
|
+
if (doctypeOverride !== 'book') atBookRoot = supportsParts = false
|
|
277
|
+
}
|
|
278
|
+
if (doc.hasAttribute('assembly-docname')) builder.docname = doc.getAttribute('assembly-docname')
|
|
279
|
+
const doctitleOverride = doc.getAttribute('assembly-doctitle')
|
|
280
|
+
if (doctitleOverride) {
|
|
281
|
+
let doctitle
|
|
282
|
+
const doctitleAsciiDoc = unconvertInlineAsciiDoc(doctitleOverride)
|
|
283
|
+
const doctitlePlain = sanitize((doctitle = doc.$sub_attributes(doc.$apply_reftext_subs(doctitleAsciiDoc))))
|
|
284
|
+
builder.updateDoctitle(doctitle, doctitleAsciiDoc, doctitlePlain, false)
|
|
285
|
+
} else if (hasAssemblyNavtitleAttr && rootLevel) {
|
|
286
|
+
builder.updateDoctitle(navtitle, navtitleAsciiDoc, navtitlePlain)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const overviewTitle = doc.getAttribute('assembly-overview-title') || 'Overview'
|
|
272
290
|
let overviewTitleAsciiDoc
|
|
273
291
|
// NOTE: in Antora, docname is relative src path from module without file extension
|
|
274
|
-
const
|
|
292
|
+
const pageDocname = doc.getAttribute('docname')
|
|
275
293
|
const pageId = generateScopedId(page.src, componentVersion, idSeparators, filetype)
|
|
276
294
|
const pageIdLeader = pageId + idSeparators.scope
|
|
277
295
|
let pageFragment = `#${pageId}`
|
|
@@ -299,6 +317,7 @@ function mergeAsciiDoc (
|
|
|
299
317
|
const ignoreLines = []
|
|
300
318
|
const buffer = (builder.body ??= [])
|
|
301
319
|
if (buffer.length) buffer.push('')
|
|
320
|
+
let headerHasBlockAttrs
|
|
302
321
|
if (doc.hasHeader()) {
|
|
303
322
|
for (const entry of processPageHeader(doc, lines, ignoreLines, isRootPage)) {
|
|
304
323
|
if (entry.type === 'author_line') {
|
|
@@ -315,8 +334,8 @@ function mergeAsciiDoc (
|
|
|
315
334
|
(val = doc.getAttribute(name)) &&
|
|
316
335
|
(newVal = rewriteImageAttr(val, contentCatalog, assemblyModel, page.src, assembled.assets)) != null
|
|
317
336
|
) {
|
|
318
|
-
if (newVal !== val) entry.
|
|
319
|
-
} else if (~(val = entry.
|
|
337
|
+
if (newVal !== val) entry.value = newVal
|
|
338
|
+
} else if (~(val = entry.value).indexOf(':')) {
|
|
320
339
|
newVal = val
|
|
321
340
|
if (~newVal.indexOf('image:')) {
|
|
322
341
|
newVal = rewriteInlineImages(
|
|
@@ -343,19 +362,19 @@ function mergeAsciiDoc (
|
|
|
343
362
|
{ file: relative, lineno: entry.lineno }
|
|
344
363
|
)
|
|
345
364
|
}
|
|
346
|
-
if (newVal !== val) entry.
|
|
365
|
+
if (newVal !== val) entry.value = newVal
|
|
347
366
|
}
|
|
348
367
|
}
|
|
349
368
|
;(entry.promote ? builder.header : buffer).push(...entry.lines)
|
|
350
369
|
} else {
|
|
351
|
-
if (entry.type === 'attrlist')
|
|
370
|
+
if (entry.type === 'attrlist') headerHasBlockAttrs = true
|
|
352
371
|
buffer.push(...entry.lines)
|
|
353
372
|
}
|
|
354
373
|
}
|
|
355
374
|
pageRoles = doc.getRoles()
|
|
356
375
|
}
|
|
357
376
|
if (roles.length) pageRoles = pageRoles.concat(roles[0] === 'page' ? roles.slice(1) : roles)
|
|
358
|
-
buffer.push(`:page-docname: ${
|
|
377
|
+
buffer.push(`:page-docname: ${pageDocname}`)
|
|
359
378
|
if (component !== builder.currentComponentVersion.name) {
|
|
360
379
|
const thisComponentVersion =
|
|
361
380
|
component === componentVersion.name && version === componentVersion.version
|
|
@@ -372,13 +391,22 @@ function mergeAsciiDoc (
|
|
|
372
391
|
}
|
|
373
392
|
buffer.push(`:page-module: ${module_}`)
|
|
374
393
|
buffer.push(`:page-relative-src-path: ${relative}`)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
394
|
+
if (origin) {
|
|
395
|
+
buffer.push(`:page-origin-url: ${origin.url}`)
|
|
396
|
+
buffer.push(`:page-origin-start-path:${origin.startPath && ' '}${origin.startPath}`)
|
|
397
|
+
buffer.push(`:page-origin-refname: ${origin.branch || origin.tag}`)
|
|
398
|
+
buffer.push(`:page-origin-reftype: ${origin.branch ? 'branch' : 'tag'}`)
|
|
399
|
+
buffer.push(`:page-origin-refhash: ${origin.worktree ? '(worktree)' : origin.refhash}`)
|
|
400
|
+
} else {
|
|
401
|
+
buffer.push(':!page-origin-url:')
|
|
402
|
+
buffer.push(':!page-origin-start-path:')
|
|
403
|
+
buffer.push(':!page-origin-refname:')
|
|
404
|
+
buffer.push(':!page-origin-reftype:')
|
|
405
|
+
buffer.push(':!page-origin-refhash:')
|
|
406
|
+
}
|
|
407
|
+
buffer.push(`:page-url: ${page.pub.url}`)
|
|
380
408
|
let heading
|
|
381
|
-
if (pageStyle != null
|
|
409
|
+
if (isRootPage && pageStyle != null) {
|
|
382
410
|
let htitleAsciiDoc, htitleOverride
|
|
383
411
|
if (pageStyle === 'preface') {
|
|
384
412
|
const hasPrefaceTitleAttr =
|
|
@@ -398,7 +426,7 @@ function mergeAsciiDoc (
|
|
|
398
426
|
}
|
|
399
427
|
if (htitleOverride === '') {
|
|
400
428
|
nextSectionLevel = 2
|
|
401
|
-
if (
|
|
429
|
+
if (headerHasBlockAttrs) {
|
|
402
430
|
htitleAsciiDoc = ''
|
|
403
431
|
} else {
|
|
404
432
|
sectionMergeStrategy = 'discrete'
|
|
@@ -410,7 +438,7 @@ function mergeAsciiDoc (
|
|
|
410
438
|
htitleAsciiDoc = htitleOverride == null ? navtitleAsciiDoc : unconvertInlineAsciiDoc(htitleOverride)
|
|
411
439
|
if (htitleOverride === overviewTitle) overviewTitleAsciiDoc = htitleAsciiDoc // optimization
|
|
412
440
|
if (atBookRoot && hasPrefaceTitleAttr) {
|
|
413
|
-
if (!
|
|
441
|
+
if (!headerHasBlockAttrs && (sectionMergeStrategy === 'discrete' || !hasSections)) {
|
|
414
442
|
builder.header.push(`:preface-title: ${htitleAsciiDoc}`)
|
|
415
443
|
htitleAsciiDoc = undefined
|
|
416
444
|
}
|
|
@@ -445,7 +473,7 @@ function mergeAsciiDoc (
|
|
|
445
473
|
heading = { title: navtitleAsciiDoc, hlevel: level-- } // NOTE: level will always come in at 1
|
|
446
474
|
nextSectionLevel = pageStyle === 'part' ? 1 : 2
|
|
447
475
|
} else if (level) {
|
|
448
|
-
if (atStartOfBody &&
|
|
476
|
+
if (atStartOfBody && pageStyle == null && !headerHasBlockAttrs && builder.matchesDoctitle(navtitlePlain)) {
|
|
449
477
|
level--
|
|
450
478
|
} else if ((heading = { title: navtitleAsciiDoc, hlevel: level + 1 }).hlevel > 6) {
|
|
451
479
|
Object.assign(heading, { hlevel: 6, style: `discrete.h${heading.hlevel}` })
|
|
@@ -455,14 +483,14 @@ function mergeAsciiDoc (
|
|
|
455
483
|
const rolesAttr = pageRoles.reduce((str, it) => str + '.' + it, '')
|
|
456
484
|
const notitle = (heading.title ||= '{empty}') === '{empty}'
|
|
457
485
|
// remove conditional if we always want to promote ID of root page to docid
|
|
458
|
-
if (notitle) {
|
|
486
|
+
if (atStartOfBody && notitle) {
|
|
459
487
|
builder.setDocid(pageId)
|
|
460
488
|
pageFragment = '#' + idSeparators.generateIdFromTitle('', idSeparators, pageIdLeader)
|
|
461
489
|
}
|
|
462
490
|
const style = heading.style ?? (pageStyle === 'part' || pageStyle === 'section' ? '' : (pageStyle ?? ''))
|
|
463
491
|
buffer.push(`[${style}${pageFragment}${rolesAttr}${notitle ? '%notitle' : ''}]`)
|
|
464
492
|
buffer.push(`${'='.repeat(heading.hlevel)} ${heading.title}`)
|
|
465
|
-
if (notitle || !supportsSections) sectionMergeStrategy = 'discrete'
|
|
493
|
+
if ((notitle && pageStyle != null) || !supportsSections) sectionMergeStrategy = 'discrete'
|
|
466
494
|
} else if (atStartOfBody) {
|
|
467
495
|
builder.setDocid(pageId)
|
|
468
496
|
}
|
|
@@ -799,6 +827,14 @@ function processPageHeader (doc, lines, ignoreLines, isRootPage) {
|
|
|
799
827
|
} else {
|
|
800
828
|
if (line.endsWith(' \\')) open = ':'
|
|
801
829
|
entries.push((current = { type: 'attribute_entry', name, negated, lines: [], lineno: idx + 1 }))
|
|
830
|
+
Object.defineProperty(current, 'value', {
|
|
831
|
+
get () {
|
|
832
|
+
return this.lines.join('\n').substring(this.name.length + 3)
|
|
833
|
+
},
|
|
834
|
+
set (newValue) {
|
|
835
|
+
this.lines = `:${this.name}: ${newValue}`.split('\n')
|
|
836
|
+
},
|
|
837
|
+
})
|
|
802
838
|
current.lines.push(negated ? `:!${name}:` : line)
|
|
803
839
|
current.appendLine = Array.prototype.push.bind(negated ? [] : current.lines)
|
|
804
840
|
if (assemblyHeaderAttributes.has(name)) current.promote = true
|
|
@@ -824,9 +860,9 @@ function processPageHeader (doc, lines, ignoreLines, isRootPage) {
|
|
|
824
860
|
return entries
|
|
825
861
|
}
|
|
826
862
|
|
|
827
|
-
function
|
|
863
|
+
function generateDocname (string) {
|
|
828
864
|
if (string === 'index') return string
|
|
829
|
-
return
|
|
865
|
+
return sanitizeDocname(
|
|
830
866
|
string
|
|
831
867
|
.toLowerCase()
|
|
832
868
|
.replace(/<[^>]+>/g, '')
|
|
@@ -839,8 +875,8 @@ function generateSlug (string) {
|
|
|
839
875
|
)
|
|
840
876
|
}
|
|
841
877
|
|
|
842
|
-
function
|
|
843
|
-
return
|
|
878
|
+
function sanitizeDocname (docname) {
|
|
879
|
+
return docname.replace(/[^\p{Alpha}0-9_.-]/gu, '-').replace(/^-+|-+$|(-)-+/g, '$1')
|
|
844
880
|
}
|
|
845
881
|
|
|
846
882
|
function fixSectionLevels (sections, expectedLevel) {
|
|
@@ -39,7 +39,7 @@ function produceAssemblyFiles (
|
|
|
39
39
|
const { attributes: assemblyAttributes, logger, navigation, rootLevel } = assemblyModel
|
|
40
40
|
if (!navigation) return accum
|
|
41
41
|
const contextualLogger = logger ? { warn: logger.warn.bind(logger, configMdc) } : undefined
|
|
42
|
-
const { name: componentName, version
|
|
42
|
+
const { name: componentName, version } = componentVersion
|
|
43
43
|
const asciidocConfig = getAsciiDocConfigWithAsciidoctorReducerExtension(componentVersion, reducerExtension)
|
|
44
44
|
let sourceHighlighter
|
|
45
45
|
if ('source-highlighter' in assemblyAttributes) {
|
|
@@ -83,10 +83,9 @@ function produceAssemblyFiles (
|
|
|
83
83
|
} else if (!(assemblyModel.filetype === 'pdf' && assemblyModel.linkReferenceStyle === 'relative')) {
|
|
84
84
|
assemblyModel.linkReferenceStyle = 'absolute'
|
|
85
85
|
}
|
|
86
|
-
const outlineRoot =
|
|
87
|
-
const startPage = resolveStartPage(contentCatalog, componentVersion, assemblyModel.insertStartPage, outlineRoot)
|
|
86
|
+
const [startPage, outlineRoot] = resolveStartPage(contentCatalog, componentVersion, assemblyModel.insertStartPage)
|
|
88
87
|
const mutableAttributes = identifyMutableAttributes(loadAsciiDoc, contentCatalog, startPage, mergedAsciiDocConfig)
|
|
89
|
-
prepareOutlines(navigation, outlineRoot, rootLevel).
|
|
88
|
+
prepareOutlines(navigation, outlineRoot, rootLevel).forEach((outline) => {
|
|
90
89
|
const assemblyFile = produceAssemblyFile(
|
|
91
90
|
loadAsciiDoc,
|
|
92
91
|
contentCatalog,
|
|
@@ -97,15 +96,15 @@ function produceAssemblyFiles (
|
|
|
97
96
|
mutableAttributes,
|
|
98
97
|
assemblyModel
|
|
99
98
|
)
|
|
100
|
-
if (!assemblyFile) return
|
|
99
|
+
if (!assemblyFile) return
|
|
101
100
|
// NOTE restore source highlighter for conversion if defined in Assembler config
|
|
102
101
|
if (sourceHighlighter !== undefined) {
|
|
103
102
|
assemblyFile.asciidoc.attributes['source-highlighter'] = sourceHighlighter
|
|
104
103
|
} else if (assemblyModel.filetype !== 'html') {
|
|
105
104
|
delete assemblyFile.asciidoc.attributes['source-highlighter']
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
}
|
|
106
|
+
accum.push(assemblyFile)
|
|
107
|
+
})
|
|
109
108
|
return accum
|
|
110
109
|
}, [])
|
|
111
110
|
}
|
|
@@ -129,53 +128,67 @@ function includedInNav (items, url) {
|
|
|
129
128
|
return items.find((it) => it.url === url || includedInNav(it.items || [], url))
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
function resolveStartPage (contentCatalog, componentVersion, insertStartPage
|
|
133
|
-
const { name: componentName, version } = componentVersion
|
|
134
|
-
const
|
|
131
|
+
function resolveStartPage (contentCatalog, componentVersion, insertStartPage) {
|
|
132
|
+
const { name: componentName, version, title } = componentVersion
|
|
133
|
+
const outlineRoot = { content: title }
|
|
134
|
+
let startPage =
|
|
135
135
|
'startPage' in componentVersion
|
|
136
136
|
? componentVersion.startPage
|
|
137
137
|
: contentCatalog.resolvePage('index.adoc', { component: componentName, version })
|
|
138
138
|
if (startPage && startPage.src.component === componentName && startPage.src.version === version) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
139
|
+
const navtitle = startPage.asciidoc?.navtitle ?? outlineRoot.content
|
|
140
|
+
Object.defineProperty(outlineRoot, 'startPageEntry', {
|
|
141
|
+
value: { navtitle, url: startPage.pub.url, urlType: 'internal', roles: ['page'] },
|
|
142
|
+
})
|
|
143
|
+
if (insertStartPage) Object.defineProperty(outlineRoot.startPageEntry, 'insert', { value: true })
|
|
144
|
+
} else {
|
|
145
|
+
startPage = 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
|
+
})
|
|
144
156
|
}
|
|
145
|
-
return
|
|
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
|
-
})
|
|
157
|
+
return [startPage, outlineRoot]
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
function prepareOutlines (navigation, rootEntry, rootLevel) {
|
|
159
|
-
const
|
|
161
|
+
const startPageEntry = rootEntry.startPageEntry
|
|
162
|
+
const singleListWithTitle = navigation.length === 1 && 'content' in navigation[0] ? navigation[0] : undefined
|
|
163
|
+
if (singleListWithTitle) {
|
|
164
|
+
const { content, url, urlType } = singleListWithTitle
|
|
165
|
+
if (urlType === 'internal') {
|
|
166
|
+
if (startPageEntry && url === startPageEntry.url) {
|
|
167
|
+
if (!startPageEntry.insert) Object.defineProperty(startPageEntry, 'insert', { value: true })
|
|
168
|
+
//if (!(content === startPageEntry.content || content === startPageEntry.navtitle)) {
|
|
169
|
+
// startPageEntry.content = content
|
|
170
|
+
//}
|
|
171
|
+
startPageEntry.roles = singleListWithTitle.roles
|
|
172
|
+
navigation = [{ items: singleListWithTitle.items }]
|
|
173
|
+
}
|
|
174
|
+
} else if (content === rootEntry.content) {
|
|
175
|
+
delete Object.assign(rootEntry, singleListWithTitle).items
|
|
176
|
+
navigation = [{ items: singleListWithTitle.items }]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
160
179
|
const items = navigation.reduce((accum, it) => {
|
|
161
|
-
if (
|
|
162
|
-
it.items && accum.push(...it.items)
|
|
163
|
-
} else {
|
|
180
|
+
if ('content' in it) {
|
|
164
181
|
accum.push(it)
|
|
182
|
+
} else if (it.items) {
|
|
183
|
+
accum.push(...it.items)
|
|
165
184
|
}
|
|
166
185
|
return accum
|
|
167
186
|
}, [])
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
return [Object.assign(rootEntry, { index: true, items })]
|
|
173
|
-
}
|
|
174
|
-
if (rootEntry.url && !includedInNav(items, rootEntry.url)) {
|
|
175
|
-
rootEntry.content = singleEntry && rootEntry.url === navigation[0].url ? navigation[0].content : rootEntry.navtitle
|
|
176
|
-
items.unshift(rootEntry)
|
|
187
|
+
if (startPageEntry?.insert && !includedInNav(items, startPageEntry.url)) {
|
|
188
|
+
Object.assign(rootEntry, startPageEntry)
|
|
189
|
+
if (rootLevel !== 0) items.unshift(Object.assign(rootEntry, { content: rootEntry.navtitle }))
|
|
177
190
|
}
|
|
178
|
-
return items
|
|
191
|
+
return rootLevel === 0 ? [Object.assign(rootEntry, { items })] : items
|
|
179
192
|
}
|
|
180
193
|
|
|
181
194
|
function extractUrlPath (url) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const ATTRIBUTE_REFERENCE_RX = /\{[
|
|
3
|
+
const ATTRIBUTE_REFERENCE_RX = /\{[A-Za-z0-9_][A-Za-z0-9_-]*\}/g
|
|
4
4
|
const STRICT_WORD_CHAR_RX = /[\p{L}\d_]/u
|
|
5
5
|
const WORD_CHAR_RX = /[\p{L}\d_;}:<>]/u
|
|
6
6
|
const XML_SPECIAL_CHARS = { '<': '<', '>': '>', '&': '&' }
|
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.12",
|
|
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)",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@antora/expand-path-helper": "~3.0",
|
|
40
40
|
"@antora/run-command-helper": "~1.1",
|
|
41
41
|
"@asciidoctor/reducer": "~1.1",
|
|
42
|
-
"js-yaml": "~5.
|
|
42
|
+
"js-yaml": "~5.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@antora/asciidoc-loader": "3.2
|
|
46
|
-
"@antora/navigation-builder": "3.2
|
|
47
|
-
"@antora/site-publisher": "3.2
|
|
45
|
+
"@antora/asciidoc-loader": "~3.2",
|
|
46
|
+
"@antora/navigation-builder": "~3.2",
|
|
47
|
+
"@antora/site-publisher": "~3.2"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=20.0.0"
|