@neo4j-antora/pdf-generator 0.1.3 → 0.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-antora/pdf-generator",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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": [
@@ -210,6 +210,20 @@ pre, code, kbd, tt {
210
210
  margin-bottom: 4pt;
211
211
  }
212
212
 
213
+ /* images */
214
+ /* An image with no explicit width renders at its own native pixel size - fine in a
215
+ browser's normal flow, but this page has a fixed content width (see @page above),
216
+ so a wide source image (e.g. a diagram sized for a wide screen) overflows the page's
217
+ right margin and gets cut off rather than shrinking to fit, the way most real sites'
218
+ own CSS already handles for free. Applies to the bare <img> tag directly rather than
219
+ a wrapper class, since that covers both Asciidoctor's block (.imageblock) and inline
220
+ (.image) image markup the same way. An image with an explicit width: attribute in
221
+ its own image::[] macro still honours that (this only caps it, never upscales). */
222
+ img {
223
+ max-width: 100%;
224
+ height: auto;
225
+ }
226
+
213
227
  /* tables */
214
228
  table.tableblock {
215
229
  border-collapse: collapse;
@@ -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]