@antora/assembler 1.0.0-beta.12 → 1.0.0-beta.14
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
CHANGED
|
@@ -16,8 +16,6 @@ const PACKAGE_NAME = require('../package.json').name
|
|
|
16
16
|
const NEWLINE_RX = /(?:\r?\n)+/
|
|
17
17
|
|
|
18
18
|
async function assembleContent (playbook, contentCatalog, converter, { configSource, navigationCatalog }) {
|
|
19
|
-
const assemblerConfig = await loadConfig(playbook, configSource)
|
|
20
|
-
if (!assemblerConfig) return [] // TODO consider removing and doing this another way
|
|
21
19
|
const context = isBound(this)
|
|
22
20
|
? this
|
|
23
21
|
: {
|
|
@@ -25,6 +23,8 @@ async function assembleContent (playbook, contentCatalog, converter, { configSou
|
|
|
25
23
|
getLogger: invariably.void,
|
|
26
24
|
getVariables: invariably.new,
|
|
27
25
|
}
|
|
26
|
+
const assemblerConfig = await loadConfig.call(context, playbook, configSource)
|
|
27
|
+
if (assemblerConfig.enabled === false) return []
|
|
28
28
|
const generatorFunctions = context.getFunctions()
|
|
29
29
|
const { loadAsciiDoc = require('@antora/asciidoc-loader') } = generatorFunctions
|
|
30
30
|
const {
|
package/lib/load-config.js
CHANGED
|
@@ -5,6 +5,8 @@ const fsp = require('node:fs/promises')
|
|
|
5
5
|
const os = require('node:os')
|
|
6
6
|
const yaml = require('js-yaml')
|
|
7
7
|
|
|
8
|
+
const PACKAGE_NAME = require('../package.json').name
|
|
9
|
+
|
|
8
10
|
const ASSEMBLY_KEYS = [
|
|
9
11
|
'rootLevel',
|
|
10
12
|
'insertStartPage',
|
|
@@ -13,25 +15,34 @@ const ASSEMBLY_KEYS = [
|
|
|
13
15
|
'dropExplicitXrefText',
|
|
14
16
|
]
|
|
15
17
|
|
|
16
|
-
function loadConfig (playbook, configSource
|
|
18
|
+
function loadConfig (playbook, configSource) {
|
|
19
|
+
let resolvedConfigSource
|
|
17
20
|
return (
|
|
18
|
-
configSource
|
|
21
|
+
configSource?.constructor === Object
|
|
19
22
|
? Promise.resolve(configSource)
|
|
20
23
|
: fsp
|
|
21
|
-
.access((
|
|
24
|
+
.access((resolvedConfigSource = expandPath(configSource ?? './antora-assembler.yml', { dot: playbook.dir })))
|
|
22
25
|
.then(
|
|
23
26
|
() => true,
|
|
24
27
|
() => false
|
|
25
28
|
)
|
|
26
|
-
.then((exists) =>
|
|
27
|
-
exists
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
.then((exists) => {
|
|
30
|
+
if (!exists) {
|
|
31
|
+
let logger
|
|
32
|
+
if (configSource && (logger = this?.getLogger?.(PACKAGE_NAME))) {
|
|
33
|
+
const ctx = { file: { path: configSource } }
|
|
34
|
+
logger.warn(ctx, 'Could not resolve config file; reverting to default settings')
|
|
35
|
+
}
|
|
36
|
+
return {}
|
|
37
|
+
}
|
|
38
|
+
return fsp
|
|
39
|
+
.readFile(resolvedConfigSource)
|
|
40
|
+
.then((data) =>
|
|
41
|
+
Object.assign(camelCaseKeys(yaml.load(data), ['asciidoc']), { file: resolvedConfigSource })
|
|
42
|
+
)
|
|
43
|
+
})
|
|
33
44
|
).then((config) => {
|
|
34
|
-
if (config.enabled === false) return
|
|
45
|
+
if (config.enabled === false) return config
|
|
35
46
|
let asciidocAttrs
|
|
36
47
|
if (!config.asciidoc) {
|
|
37
48
|
config.asciidoc = { attributes: (asciidocAttrs = {}) }
|
|
@@ -820,7 +820,7 @@ function generateId (componentSrc, componentVersion, coordinateSep, scopeSep, as
|
|
|
820
820
|
if (component !== componentVersion.name) {
|
|
821
821
|
id = [component, mod === 'ROOT' ? '' : mod, id].join(coordinateSep)
|
|
822
822
|
} else if (mod !== 'ROOT') {
|
|
823
|
-
if (asXrefTarget && coordinateSep === ':' && /(?:pass|stem)$/.test(mod) && /^[a-z](?:,[a-z-])
|
|
823
|
+
if (asXrefTarget && coordinateSep === ':' && /(?:pass|stem)$/.test(mod) && /^[a-z]+(?:,[a-z-]+)*$/.test(id)) {
|
|
824
824
|
mod = mod.replace(/(?:pass|stem)$/, '\\$&')
|
|
825
825
|
}
|
|
826
826
|
id = mod + coordinateSep + id
|
|
@@ -64,7 +64,7 @@ function produceAssemblyFiles (loadAsciiDoc, contentCatalog, assemblerConfig, re
|
|
|
64
64
|
if (linkRefStyle === 'absolute' && siteRoot?.url == null) linkRefStyle = 'root-relative'
|
|
65
65
|
if (linkRefStyle === 'root-relative' && siteRoot?.path == null) linkRefStyle = 'relative'
|
|
66
66
|
assemblyModel.linkReferenceStyle = linkRefStyle
|
|
67
|
-
} else {
|
|
67
|
+
} else if (assemblyModel.filetype !== 'pdf') {
|
|
68
68
|
assemblyModel.linkReferenceStyle = 'absolute'
|
|
69
69
|
}
|
|
70
70
|
const auxiliaryImages = new Set()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/assembler",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
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)",
|