@neo4j-antora/pdf-generator 0.1.6 → 0.1.8

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.6",
3
+ "version": "0.1.8",
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": [
@@ -28,5 +28,10 @@
28
28
  "@neo4j-documentation/macros": "1.0.4",
29
29
  "@neo4j-documentation/remote-include": "1.0.0",
30
30
  "node-html-parser": "9.0.4"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/neo4j/docs-tools.git",
35
+ "directory": "pdf-generator"
31
36
  }
32
37
  }
@@ -192,7 +192,7 @@ body.book {
192
192
  line-height: 1.4;
193
193
  }
194
194
  #toc a {
195
- display: flex;
195
+ display: block;
196
196
  color: var(--brand-text);
197
197
  text-decoration: none;
198
198
  font-size: 10.5pt;
@@ -354,6 +354,32 @@ tr { break-inside: avoid; }
354
354
  .admonitionblock.note td.content > .title,
355
355
  .admonitionblock.tip td.content > .title { color: var(--brand-primary-strong); }
356
356
 
357
+ /* quoteblocks - includes a page's own [abstract]/{description} block (every page
358
+ authors `[abstract]\n{description}` right after its own title), which Asciidoctor
359
+ renders as a plain, unstyled quoteblock - this theme never styled quoteblocks at all,
360
+ so it rendered as nothing but the renderer's own default blockquote indent, no visual
361
+ distinction from body text. Styled as a neutral callout box, same visual language as a
362
+ plain (non-colored) admonition above, matching how the real site styles this exact
363
+ block (#preamble .abstract) as a distinct box rather than a plain paragraph. */
364
+ .quoteblock { break-inside: avoid-page; margin: 1em 0; }
365
+ .quoteblock blockquote {
366
+ margin: 0;
367
+ border-left: 3pt solid var(--brand-border-strong);
368
+ padding: 8pt 12pt;
369
+ background: var(--brand-bg-strong);
370
+ font-style: italic;
371
+ color: var(--brand-text-weak);
372
+ }
373
+ .quoteblock blockquote .paragraph:last-child { margin-bottom: 0; }
374
+ .quoteblock .attribution {
375
+ margin-top: 6pt;
376
+ font-size: 9.5pt;
377
+ font-style: normal;
378
+ color: var(--brand-text-weaker);
379
+ text-align: right;
380
+ }
381
+ .quoteblock .attribution cite { font-style: italic; }
382
+
357
383
  /* lists */
358
384
  .ulist, .olist, .dlist { margin: 0.5em 0; }
359
385
 
@@ -144,18 +144,29 @@ const PUPPETEER_TIMEOUT_ENV = {
144
144
  // this can't just be a relative value in the playbook/assembler config.
145
145
  const args = process.argv.slice(2)
146
146
  const stdinMarkerIdx = args.lastIndexOf('-')
147
- // @antora/assembler already passes the real `site.url` from the docset's own
148
- // publish.yml (the same canonical production URL reusable-docs-build.yml's
149
- // HTML build uses, e.g. https://neo4j.com/docs) as a plain `-a` flag here -
150
- // absolute-links-postprocessor.js needs just its origin (scheme + host) to
151
- // rewrite a root-relative href into a full URL. Reading it back out of these
152
- // args rather than hardcoding the origin separately means it can't drift
153
- // from whatever value a docset's own playbook actually declares.
154
- function siteOrigin () {
155
- const idx = args.findIndex((arg) => arg.startsWith('site-url='))
156
- if (idx === -1) return null
147
+ // reusable-docs-pdf-build.yml sets DOCS_PUBLISH_URL as this job's own env - the
148
+ // exact same value reusable-docs-build.yml's own HTML build resolves (dev
149
+ // sandbox vs prod) - which reaches this child process for free (plain env var
150
+ // inheritance), rather than needing to round-trip it through Antora's own CLI
151
+ // args: Antora's top-level command has no generic attribute-override flag the
152
+ // way plain asciidoctor does, so there's no "-a" to read it back out of here.
153
+ //
154
+ // A root-relative href (from neo4j-docs-base-uri - see
155
+ // absolute-links-postprocessor.js's own comment) always starts with the literal
156
+ // "/docs" - true site-root-relative on production, where DOCS_PUBLISH_URL's own
157
+ // path is just "/docs", but not on a sandbox/dev deployment, whose
158
+ // DOCS_PUBLISH_URL has a longer path that merely *ends* in that same "/docs"
159
+ // segment (e.g. ".../sandbox/restructure/docs"). Stripping that one trailing
160
+ // segment before prepending gives the prefix that's correct in both cases - the
161
+ // href's own "/docs" fills back in whichever one was removed:
162
+ // prod: https://neo4j.com/docs -> https://neo4j.com
163
+ // sandbox: https://development.neo4j.dev/docs/sandbox/restructure/docs
164
+ // -> https://development.neo4j.dev/docs/sandbox/restructure
165
+ function linkPrefix () {
166
+ if (!process.env.DOCS_PUBLISH_URL) return null
157
167
  try {
158
- return new URL(args[idx].slice('site-url='.length)).origin
168
+ const url = new URL(process.env.DOCS_PUBLISH_URL)
169
+ return url.origin + url.pathname.replace(/\/docs\/?$/, '')
159
170
  } catch {
160
171
  return null
161
172
  }
@@ -176,8 +187,8 @@ const extraArgs = [
176
187
  '--extension', COLOPHON_POSTPROCESSOR,
177
188
  '--extension', ABSOLUTE_LINKS_POSTPROCESSOR,
178
189
  ]
179
- const origin = siteOrigin()
180
- if (origin) extraArgs.push('-a', `absolute-link-origin=${origin}`)
190
+ const prefix = linkPrefix()
191
+ if (prefix) extraArgs.push('-a', `absolute-link-prefix=${prefix}`)
181
192
  if (mathjaxAvailable()) extraArgs.push('--extension', MATHJAX_ADAPTER)
182
193
  // Reading from stdin (this is piped the merged .adoc, not a real file - see
183
194
  // below), asciidoctor-web-pdf invents a fictive input path rooted at
@@ -29,13 +29,13 @@ const { Postprocessor } = require('asciidoctor')
29
29
  class AbsoluteLinksPostprocessor extends Postprocessor {
30
30
  process (document, output) {
31
31
  if (!output.includes('href="/')) return output
32
- // convert.js reads this back out of the docset's own publish.yml site.url
33
- // (the same canonical production URL reusable-docs-build.yml's HTML build
34
- // uses) and passes it on as this attribute - see its own siteOrigin()
35
- // comment. Falls back to the real production origin if that ever isn't
36
- // available, rather than leaving a root-relative, unusable link in a
37
- // downloaded, standalone PDF.
38
- const origin = document.getAttribute('absolute-link-origin') || 'https://neo4j.com'
32
+ // reusable-docs-pdf-build.yml passes DOCS_PUBLISH_URL through (the exact
33
+ // value its HTML build equivalent resolves - dev sandbox vs prod), and
34
+ // convert.js turns it into this attribute - see its own linkPrefix()
35
+ // comment for why this is more than just an origin. Falls back to the
36
+ // real production origin if that ever isn't available, rather than
37
+ // leaving a root-relative, unusable link in a downloaded, standalone PDF.
38
+ const prefix = document.getAttribute('absolute-link-prefix') || 'https://neo4j.com'
39
39
  const root = parseHTML(output)
40
40
  root.querySelectorAll('a[href]').forEach((a) => {
41
41
  const href = a.getAttribute('href')
@@ -43,7 +43,7 @@ class AbsoluteLinksPostprocessor extends Postprocessor {
43
43
  // a different origin entirely) and everything else (full URLs,
44
44
  // same-page "#fragment"s, "mailto:", ...) untouched.
45
45
  if (href.startsWith('/') && !href.startsWith('//')) {
46
- a.setAttribute('href', origin + href)
46
+ a.setAttribute('href', prefix + href)
47
47
  }
48
48
  })
49
49
  return root.toString()