@neo4j-antora/pdf-generator 0.1.3 → 0.1.4
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/package.json +1 -1
- package/scripts/convert.js +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-antora/pdf-generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Generates a PDF export from an Antora docset, styled to match the real Neo4j docs site, via @antora/assembler + @antora/pdf-extension and asciidoctor-web-pdf",
|
|
5
5
|
"main": "extension.js",
|
|
6
6
|
"files": [
|
package/scripts/convert.js
CHANGED
|
@@ -107,6 +107,24 @@ const extraArgs = [
|
|
|
107
107
|
'--extension', REMOTE_INCLUDE_ADAPTER,
|
|
108
108
|
'--extension', MACROS_ADAPTER,
|
|
109
109
|
]
|
|
110
|
+
// Reading from stdin (this is piped the merged .adoc, not a real file - see
|
|
111
|
+
// below), asciidoctor-web-pdf invents a fictive input path rooted at
|
|
112
|
+
// `--base-dir`/`-B` if given, else its own cwd (lib/cli.js's
|
|
113
|
+
// _convertFromStdin), and writes its temporary intermediate HTML file next
|
|
114
|
+
// to THAT path (lib/converter.js's getTemporaryHtmlFile), not next to the
|
|
115
|
+
// real docdir the assembler passes via `-a docdir=...`. Without `-B`, that
|
|
116
|
+
// temp HTML ends up sitting in whatever directory this script itself was
|
|
117
|
+
// invoked from (the docset's own root, since that's antora's cwd) - one or
|
|
118
|
+
// more levels away from `-a docdir`/`-a imagesoutdir`. Every image target,
|
|
119
|
+
// resolved correctly as relative to the real docdir (e.g. `../_images/
|
|
120
|
+
// foo.png`), then resolves relative to the WRONG directory when the
|
|
121
|
+
// browser loads that temp HTML via file://, so every image in the PDF is
|
|
122
|
+
// silently broken. Passing the same docdir here as `-B` puts the temp HTML
|
|
123
|
+
// file where the image paths actually expect it to be.
|
|
124
|
+
const docdirIdx = args.findIndex((arg) => arg.startsWith('docdir='))
|
|
125
|
+
if (docdirIdx > 0 && args[docdirIdx - 1] === '-a') {
|
|
126
|
+
extraArgs.push('-B', args[docdirIdx].slice('docdir='.length))
|
|
127
|
+
}
|
|
110
128
|
const finalArgs =
|
|
111
129
|
stdinMarkerIdx === -1
|
|
112
130
|
? [...args, ...extraArgs]
|