hdoc-tools 0.60.1 → 0.62.0

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.
Files changed (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +89 -75
  3. package/hdoc-build-db.js +275 -275
  4. package/hdoc-build-embeddings.js +202 -202
  5. package/hdoc-build-pdf.js +232 -232
  6. package/hdoc-build.js +14 -6
  7. package/hdoc-bump.js +4 -2
  8. package/hdoc-content-routes.js +143 -83
  9. package/hdoc-create.js +110 -108
  10. package/hdoc-db.js +114 -114
  11. package/hdoc-help.js +60 -60
  12. package/hdoc-init.js +103 -68
  13. package/hdoc-install-browser.js +145 -145
  14. package/hdoc-mermaid.js +204 -204
  15. package/hdoc-module.js +1102 -1079
  16. package/hdoc-serve.js +13 -7
  17. package/hdoc-stats.js +9 -9
  18. package/hdoc-validate-config.js +355 -329
  19. package/hdoc-validate-interbook.js +321 -0
  20. package/hdoc-validate.js +1231 -1158
  21. package/hdoc-ver.js +4 -2
  22. package/hdoc.js +12 -11
  23. package/npm-shrinkwrap.json +2 -2
  24. package/package.json +13 -2
  25. package/schemas/hdocbook-project.schema.json +20 -0
  26. package/schemas/hdocbook.schema.json +6 -2
  27. package/templates/doc-header-non-git.html +19 -19
  28. package/templates/doc-header.html +26 -26
  29. package/templates/init/.github/workflows/hdocbuild_onpull.yml +16 -16
  30. package/templates/init/.github/workflows/hdocbuild_onpush.yml +15 -15
  31. package/templates/init/LICENSE +21 -21
  32. package/templates/init/README.md +9 -9
  33. package/templates/init/_hdocbook/index.md +4 -4
  34. package/templates/init/gitignore +8 -8
  35. package/templates/init/resources/README.md +2 -2
  36. package/templates/pdf/css/custom-block.css +90 -90
  37. package/templates/pdf/css/fonts.css +221 -221
  38. package/templates/pdf/css/hdocs-pdf.css +495 -495
  39. package/templates/pdf/css/vars.css +404 -404
  40. package/templates/pdf/template-footer.html +19 -19
  41. package/templates/pdf/template-header.html +37 -37
  42. package/templates/pdf/template.html +20 -20
  43. package/templates/pdf-header-non-git.html +12 -12
  44. package/templates/pdf-header.html +16 -16
  45. package/ui/content/invalid-hdocbook-json.html +6 -6
  46. package/ui/content/invalid-hdocbook-json.md +7 -7
  47. package/ui/css/theme-default/styles/components/content.css +124 -124
  48. package/ui/css/theme-default/styles/components/sidebar.css +182 -182
  49. package/ui/css/theme-default/styles/htldoc.layouts.css +310 -310
  50. package/ui/index.html +419 -419
  51. package/ui/js/doc.hornbill.js +31 -44
  52. package/ui/js/mermaid-theme.json +27 -0
  53. package/hdoc-build-onyx.js +0 -134
  54. package/templates/mermaid-theme.yaml +0 -28
  55. package/templates/pdf/fonts/inter-cyrillic copy.woff2 +0 -0
package/hdoc-serve.js CHANGED
@@ -4,9 +4,8 @@
4
4
  const fs = require("node:fs");
5
5
  const path = require("node:path");
6
6
  const hdoc = require(path.join(__dirname, "hdoc-module.js"));
7
- const { create_content_handler, build_nav_inline } = require(
8
- path.join(__dirname, "hdoc-content-routes.js"),
9
- );
7
+ const { create_content_handler, build_nav_inline, resolve_within_root } =
8
+ require(path.join(__dirname, "hdoc-content-routes.js"));
10
9
 
11
10
  let port = 3000;
12
11
  let docId;
@@ -47,9 +46,12 @@
47
46
  "hdocbook-project.json",
48
47
  );
49
48
 
50
- // Load the hdocbook config file
49
+ // Load the hdocbook config file (readFileSync, not require — no module
50
+ // cache, and the content routes re-read it per request anyway)
51
51
  try {
52
- hdocbook_project = require(hdocbook_project_config_path);
52
+ hdocbook_project = JSON.parse(
53
+ fs.readFileSync(hdocbook_project_config_path, "utf8"),
54
+ );
53
55
  } catch (e) {
54
56
  console.error(`\nFailed to load hdocbook-project.json:\n${e}\n`);
55
57
  process.exit(1);
@@ -72,7 +74,7 @@
72
74
 
73
75
  // Pull in the book config file
74
76
  try {
75
- hdocbook_config = require(hdocbook_path);
77
+ hdocbook_config = JSON.parse(fs.readFileSync(hdocbook_path, "utf8"));
76
78
  } catch (e) {
77
79
  console.error(`\nFailed to load hdocbook.json:${e}\n`);
78
80
  process.exit(1);
@@ -93,7 +95,11 @@
93
95
  // Catch all
94
96
  app.get("/{*splat}", (req, res) => {
95
97
 
96
- const ui_file_path = path.join(ui_path, req.url);
98
+ const ui_file_path = resolve_within_root(ui_path, req.url);
99
+ if (ui_file_path === null) {
100
+ content.send_content_resource_404(req, res);
101
+ return;
102
+ }
97
103
 
98
104
  // To support the SPA application behavior, if there is no file extension present, then
99
105
  // we simply return the /index.html file content to the client
package/hdoc-stats.js CHANGED
@@ -5,9 +5,10 @@
5
5
  const hdoc = require(path.join(__dirname, "hdoc-module.js"));
6
6
 
7
7
 
8
- // Regex to remove Hornbill-specific tags
8
+ // Regex to remove Hornbill admonition markers (::: note etc — see
9
+ // custom_modules/tips.js) so the marker keywords don't inflate word counts.
9
10
  const hbMDTagRegex =
10
- /(:{3}[ ]note)|(:{3}[ ]tip)|(:{3}[ ]important)|(:{3}[ ]caution)|(:{3}[ ]warning)|(:{3})/g;
11
+ /(:{3}[ ]note)|(:{3}[ ]tip)|(:{3}[ ]important)|(:{3}[ ]info)|(:{3}[ ]caution)|(:{3}[ ]warning)|(:{3})/g;
11
12
 
12
13
  const stats = {
13
14
  totalMDFiles: 0,
@@ -42,15 +43,12 @@
42
43
  }
43
44
  };
44
45
 
45
- const dreeOptions = {
46
- descendants: true,
46
+ // Options for hdoc.scan_dir (see hdoc-module.js for the supported keys)
47
+ const scanOptions = {
47
48
  depth: 10,
48
49
  extensions: ["md", "html", "htm"],
49
- hash: false,
50
50
  normalize: true,
51
- size: true,
52
51
  sizeInBytes: true,
53
- stat: false,
54
52
  symbolicLinks: false,
55
53
  };
56
54
 
@@ -105,12 +103,14 @@
105
103
  });
106
104
 
107
105
  // Scan content path directory, send file info to callback for processing
108
- hdoc.scan_dir(bookPath, dreeOptions, fileCallback);
106
+ hdoc.scan_dir(bookPath, scanOptions, fileCallback);
109
107
  for (const element of markdownFiles) {
110
108
  // Load markdown file
111
109
  const md_txt = fs.readFileSync(element.path, "utf8");
112
110
 
113
- const html_txt = md.render(md_txt.toString());
111
+ const html_txt = md.render(
112
+ md_txt.toString().replace(hbMDTagRegex, ""),
113
+ );
114
114
  const text = hdoc.html_to_text(html_txt);
115
115
 
116
116
  // Do the wordcount and add to status