hdoc-tools 0.62.3 → 0.62.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.
@@ -61,6 +61,30 @@
61
61
 
62
62
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
63
63
 
64
+ // @puppeteer/browsers mkdirs <cacheDir>/<browser> non-recursively, so the
65
+ // cache dir must exist first — on a fresh checkout it does not. A dangling
66
+ // symlink (e.g. left behind after the package dir it pointed at was removed)
67
+ // is worse: mkdir through it fails ENOENT forever, so drop it first.
68
+ try {
69
+ fs.lstatSync(cacheDir);
70
+ try {
71
+ fs.statSync(cacheDir); // resolves the link target
72
+ } catch {
73
+ log(`Removing dangling cache dir link: ${cacheDir}`);
74
+ fs.unlinkSync(cacheDir);
75
+ }
76
+ } catch {
77
+ /* nothing there yet */
78
+ }
79
+ try {
80
+ fs.mkdirSync(cacheDir, { recursive: true });
81
+ } catch (err) {
82
+ console.error(
83
+ `${RED}Unable to create browser cache dir ${cacheDir}: ${err.message}${RESET}`,
84
+ );
85
+ process.exit(1);
86
+ }
87
+
64
88
  const rmrf = (target) => {
65
89
  try {
66
90
  fs.rmSync(target, { recursive: true, force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.62.3",
3
+ "version": "0.62.4",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -462,6 +462,23 @@ code {
462
462
  font-size: 0.9em;
463
463
  }
464
464
 
465
+ /* A PDF page cannot be scrolled, so a code block that overflows its box is
466
+ simply clipped at the page edge and the rest of the line is lost. Wrap
467
+ instead: pre-wrap keeps the authored newlines/indentation while allowing
468
+ long lines (curl one-liners, long endpoint URLs) to break. anywhere is
469
+ needed because break-word will not split an unbroken token such as a URL
470
+ or a base64 blob. .hljs is included because the highlight.js theme sets
471
+ overflow-x: auto on it, which is meaningless in print. */
472
+ pre,
473
+ pre code,
474
+ .hljs {
475
+ white-space: pre-wrap;
476
+ overflow-wrap: anywhere;
477
+ word-break: normal;
478
+ overflow-x: visible;
479
+ max-width: 100%;
480
+ }
481
+
465
482
  /* From Bootstrap 5, text color decorations */
466
483
  .text-primary {
467
484
  color: #0d6efd !important;
@@ -6,6 +6,12 @@
6
6
  <link rel="stylesheet"
7
7
  href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/base16/humanoid-light.min.css">
8
8
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
9
+ <!-- highlight.min.js is the "common" bundle only (~37 languages) and does NOT
10
+ include PowerShell, so language-powershell blocks rendered as plain black
11
+ text in PDFs while go/js/php/python/sh (all common) were coloured.
12
+ Register the extra grammar explicitly - keep the version in lockstep with
13
+ the core bundle above. -->
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/powershell.min.js"></script>
9
15
  </head>
10
16
 
11
17
  <body>
@@ -13,9 +13,15 @@
13
13
  position:relative;
14
14
  }
15
15
 
16
+ /* The container is a flex row holding the content pane and the TOC. The
17
+ content pane does all the flexing (basis 0, min-width 0 so wide content -
18
+ tables, code blocks - cannot force it wider); the TOC keeps a fixed,
19
+ non-shrinking basis. Giving both children a width made the row
20
+ over-committed, so both shrank pro-rata and the TOC collapsed to ~118px. */
16
21
  .DocContent .injected-document-content
17
22
  {
18
- width: 100%;
23
+ flex: 1 1 0;
24
+ min-width: 0;
19
25
  }
20
26
 
21
27
  .DocContent .injected-document-toc
@@ -23,7 +29,7 @@
23
29
  height: fit-content;
24
30
  display:none;
25
31
  margin:0 0 0 50px;
26
- width:400px;
32
+ flex: 0 0 clamp(260px, 26%, 400px);
27
33
  }
28
34
 
29
35
  .DocContent .injected-document-toc .H2{
@@ -87,12 +93,9 @@
87
93
  display:inline-block;
88
94
  }
89
95
 
90
- /* if have toc layout and greater than 1500px then limit doc content to 900px to make room for toc */
91
- .DocContent.article-toc .injected-document-content
92
- {
93
- width: 900px;
94
- }
95
-
96
+ /* Room for the TOC comes from its own flex basis now - a width here would be
97
+ ignored anyway (flex-basis 0 on the content pane wins over width). */
98
+
96
99
  }
97
100
 
98
101
  /* style overrides to apply on screens that are 1920px and wider */
@@ -93,6 +93,33 @@ Uses some ES6 features so won't work in IE without shims:
93
93
  if (typeof highlightJsBadgeAutoLoad !== 'boolean')
94
94
  var highlightJsBadgeAutoLoad = false;
95
95
 
96
+ //-- LOCAL FIX: display names for the badge label, so a fence written as ```md shows "Markdown".
97
+ //-- highlight.js 11 grammars carry a cased `name` and are preferred when present, but the pack
98
+ //-- vendored here is a v9 build whose grammars have aliases and no name at all - hence this
99
+ //-- table. Keyed by alias as well as canonical name, because the badge label is whatever the
100
+ //-- author typed in the fence. Anything missing falls through and displays unchanged.
101
+ var HDOC_LANG_DISPLAY_NAMES = {
102
+ apache: "Apache", apacheconf: "Apache",
103
+ bash: "Bash", sh: "Bash", zsh: "Bash", shell: "Shell", console: "Shell Session",
104
+ bat: "DOS Batch", cmd: "DOS Batch", dos: "DOS Batch",
105
+ c: "C", cpp: "C++", cs: "C#", csharp: "C#", objectivec: "Objective-C",
106
+ css: "CSS", scss: "SCSS", less: "Less",
107
+ dart: "Dart", diff: "Diff", patch: "Diff", dns: "DNS Zone",
108
+ dockerfile: "Dockerfile", docker: "Dockerfile",
109
+ fsharp: "F#", go: "Go", golang: "Go", graphql: "GraphQL",
110
+ html: "HTML", xml: "XML", svg: "SVG", http: "HTTP",
111
+ ini: "INI", toml: "TOML", java: "Java",
112
+ js: "JavaScript", javascript: "JavaScript", json: "JSON",
113
+ kotlin: "Kotlin", lua: "Lua", makefile: "Makefile", md: "Markdown", markdown: "Markdown",
114
+ nginx: "Nginx", perl: "Perl", php: "PHP",
115
+ powershell: "PowerShell", ps: "PowerShell", ps1: "PowerShell", pwsh: "PowerShell",
116
+ python: "Python", py: "Python", r: "R", ruby: "Ruby", rb: "Ruby", rust: "Rust",
117
+ scala: "Scala", sql: "SQL", pgsql: "PostgreSQL", postgresql: "PostgreSQL",
118
+ swift: "Swift", ts: "TypeScript", typescript: "TypeScript",
119
+ vbnet: "VB.NET", vbscript: "VBScript", yaml: "YAML", yml: "YAML",
120
+ plaintext: "Plain Text", text: "Text"
121
+ };
122
+
96
123
  function highlightJsBadge(opt) {
97
124
  var options = {
98
125
  // the selector for the badge template
@@ -198,10 +225,24 @@ function highlightJsBadge(opt) {
198
225
  lang = "typescript";
199
226
  else if (lang == "fox")
200
227
  lang = "foxpro";
201
- else if (lang == "txt")
228
+ else if (lang == "txt")
202
229
  lang = "text"
203
230
 
204
-
231
+ //-- LOCAL FIX: show a full display name rather than whatever alias the author wrote
232
+ //-- in the fence - "Markdown" not "md", "C#" not "cs", "Bash" not "sh". A
233
+ //-- highlight.js 11 grammar carries its own cased `name` and is authoritative, so
234
+ //-- this keeps working if the pack is ever upgraded; the v9 pack vendored here has
235
+ //-- no such property, so the table above supplies it. Unknown languages fall through
236
+ //-- to the overrides above unchanged.
237
+ var langDef = (window.hljs && typeof window.hljs.getLanguage === "function")
238
+ ? window.hljs.getLanguage(lang)
239
+ : null;
240
+
241
+ if (langDef && langDef.name)
242
+ lang = langDef.name;
243
+ else if (HDOC_LANG_DISPLAY_NAMES[lang])
244
+ lang = HDOC_LANG_DISPLAY_NAMES[lang];
245
+
205
246
  var html = hudText.replace("{{language}}", lang)
206
247
  .replace("{{copyIconClass}}",options.copyIconClass)
207
248
  .trim();
@@ -305,28 +346,22 @@ function highlightJsBadge(opt) {
305
346
  " .code-badge-pre {",
306
347
  " position: relative;",
307
348
  " }",
349
+ " /* Rendered as a full-width header bar above the code, not",
350
+ " absolutely positioned over it - overlapping the first line",
351
+ " made both the badge and the code unreadable. */",
308
352
  " .code-badge {",
309
353
  " display: flex;",
310
354
  " flex-direction: row;",
355
+ " align-items: center;",
356
+ " justify-content: space-between;",
311
357
  " white-space: normal;",
312
- " background: transparent;",
313
358
  " background: #333;",
314
359
  " color: white;",
315
360
  " font-size: 0.875em;",
316
- " opacity: 0.5;",
317
- " transition: opacity linear 0.5s;",
318
- " border-radius: 0 0 0 7px;",
361
+ " border-radius: 7px 7px 0 0;",
319
362
  " padding: 5px 8px 5px 8px;",
320
- " position: absolute;",
321
- " right: 0;",
322
- " top: 0;",
323
- " }",
324
- " .code-badge.active {",
325
- " opacity: 0.8;",
326
- " }",
327
- "",
328
- " .code-badge:hover {",
329
- " opacity: .95;",
363
+ " width: 100%;",
364
+ " box-sizing: border-box;",
330
365
  " }",
331
366
  "",
332
367
  " .code-badge a,",
@@ -396,23 +431,16 @@ if (highlightJsBadgeAutoLoad)
396
431
  .code-badge {
397
432
  display: flex;
398
433
  flex-direction: row;
434
+ align-items: center;
435
+ justify-content: space-between;
399
436
  white-space: normal;
400
- background: transparent;
401
437
  background: #333;
402
438
  color: white;
403
439
  font-size: 0.875em;
404
- opacity: 0.5;
405
- border-radius: 0 0 0 7px;
440
+ border-radius: 7px 7px 0 0;
406
441
  padding: 5px 8px 5px 8px;
407
- position: absolute;
408
- right: 0;
409
- top: 0;
410
- }
411
- .code-badge.active {
412
- opacity: 0.8;
413
- }
414
- .code-badge:hover {
415
- opacity: .95;
442
+ width: 100%;
443
+ box-sizing: border-box;
416
444
  }
417
445
  .code-badge a,
418
446
  .code-badge a:hover {