hdoc-tools 0.26.3 → 0.27.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.
package/README.md CHANGED
@@ -47,6 +47,8 @@ If the -v switch is provided, then a more verbose output is provided, which incl
47
47
 
48
48
  Use the --set-version argument to set the version number of the built book.
49
49
 
50
+ Use the --no-color argument to remove any color control characters from the output.
51
+
50
52
  ### validate
51
53
 
52
54
  Performs a minimum local build of the book, then validates the links and static content are present and correct.
@@ -55,6 +57,8 @@ If the -v switch is provided, then a more verbose output is provided, which incl
55
57
 
56
58
  Use the --set-version argument to set the version number of the built book.
57
59
 
60
+ Use the --no-color argument to remove any color control characters from the output.
61
+
58
62
  ### serve
59
63
 
60
64
  Starts a local web server on port 3000, serving the book content.
package/hdoc-help.js CHANGED
@@ -1,48 +1,48 @@
1
- (() => {
2
- exports.run = () => {
3
- // STEVE: The purpose of this function is to output information about hdoc arguments
4
- const helpText = `
5
- Command Line Usage
6
-
7
- hdoc <command> [switches]
8
-
9
- Commands
10
-
11
- - build
12
- Performs a local build of the book, and outputs as a ZIP file. Use non-mandatory argument '--set-version 1.2.3' to set the version number of the built book
13
-
14
- - createDocs
15
- Creates folder structure and markdown documents as defined in the HDocBook navigation item links
16
-
17
- - help
18
- Outputs available arguments and switches
19
-
20
- - init
21
- Initializes a new HDocBook project from a template, using runtime input variables
22
-
23
- - serve
24
- Starts a local web server on port 3000, serving the content. Supports a -port N to use a different port
25
-
26
- - stats
27
- Returns statistics regarding the book you are working on. Supports a -v switch for verbose output.
28
- The book statistics do not include counts for any externally hosted content injected into the book content using the [[INCLUDE]] tags.
29
-
30
- - validate
31
- Validates the book content
32
-
33
- - bump
34
- Updates the semantic version number of the current book. If no options are specified, then the default of patch is applied:
35
- - major - updates the major version of the book. i.e. - 1.4.5 would become 2.0.0
36
- - minor - updates the minor version of the book. i.e. - 1.4.5 would become 1.5.0
37
- - patch (default) - updates the patch version of the book. i.e. - 1.4.5 would become 1.4.6
38
-
39
- - ver
40
- Returns the version of the current book
41
-
42
- Example
43
-
44
- hdoc stats -v
45
- `;
46
- console.log(helpText);
47
- };
48
- })();
1
+ (() => {
2
+ exports.run = () => {
3
+ // STEVE: The purpose of this function is to output information about hdoc arguments
4
+ const helpText = `
5
+ Command Line Usage
6
+
7
+ hdoc <command> [switches]
8
+
9
+ Commands
10
+
11
+ - build
12
+ Performs a local build of the book, and outputs as a ZIP file. Use the '--set-version 1.2.3' argument to set the version number of the built book. Use the '--no-color' argument to remove any color control characters from the output.
13
+
14
+ - createDocs
15
+ Creates folder structure and markdown documents as defined in the HDocBook navigation item links
16
+
17
+ - help
18
+ Outputs available arguments and switches
19
+
20
+ - init
21
+ Initializes a new HDocBook project from a template, using runtime input variables
22
+
23
+ - serve
24
+ Starts a local web server on port 3000, serving the content. Supports a -port N to use a different port
25
+
26
+ - stats
27
+ Returns statistics regarding the book you are working on. Supports a -v switch for verbose output.
28
+ The book statistics do not include counts for any externally hosted content injected into the book content using the [[INCLUDE]] tags.
29
+
30
+ - validate
31
+ Validates the book content. Use the '--set-version 1.2.3' argument to set the version number of the built book. Use the '--no-color' argument to remove any color control characters from the output.
32
+
33
+ - bump
34
+ Updates the semantic version number of the current book. If no options are specified, then the default of patch is applied:
35
+ - major - updates the major version of the book. i.e. - 1.4.5 would become 2.0.0
36
+ - minor - updates the minor version of the book. i.e. - 1.4.5 would become 1.5.0
37
+ - patch (default) - updates the patch version of the book. i.e. - 1.4.5 would become 1.4.6
38
+
39
+ - ver
40
+ Returns the version of the current book
41
+
42
+ Example
43
+
44
+ hdoc stats -v
45
+ `;
46
+ console.log(helpText);
47
+ };
48
+ })();
package/hdoc-validate.js CHANGED
@@ -415,6 +415,9 @@ const e = require("express");
415
415
  };
416
416
 
417
417
  const isHashAnchor = (html_file, hash_anchor, full_hash_anchor_link = "") => {
418
+ const markdown_paths = getMDPathFromHtmlPath(html_file);
419
+ const markdown_content = fs.readFileSync(markdown_paths.markdownPath, 'utf8');
420
+
418
421
  try {
419
422
  const file_content = fs.readFileSync(html_file.path, {
420
423
  encoding: "utf-8",
@@ -425,9 +428,8 @@ const e = require("express");
425
428
  if (
426
429
  !file_content.includes(`<div id="hb-doc-anchor-${clean_hash_anchor}"`)
427
430
  ) {
428
- errors[html_file.relativePath].push(
429
- `Target hash anchor is not present in page content: ${full_hash_anchor_link !== "" ? full_hash_anchor_link : hash_anchor}`,
430
- );
431
+ const error_message = processErrorMessage(`Target hash anchor is not present in page content: ${full_hash_anchor_link !== "" ? full_hash_anchor_link : hash_anchor}`, markdown_paths.relativePath, markdown_content, full_hash_anchor_link);
432
+ errors[html_file.relativePath].push( error_message );
431
433
  }
432
434
  } catch (e) {
433
435
  errors[html_file.relativePath].push(e);
@@ -688,7 +690,7 @@ const e = require("express");
688
690
  // Check for hash anchor
689
691
  if (hash_anchor !== null) {
690
692
  isHashAnchor(
691
- { path: html_file_path, relativePath: html_path.relativePath },
693
+ { path: html_file_path, relativePath: html_path.relativePath, extension: html_path.extension },
692
694
  hash_anchor,
693
695
  relative_path,
694
696
  );
package/hdoc.js CHANGED
@@ -7,12 +7,18 @@
7
7
 
8
8
  const packageFile = path.join(__dirname, "package.json");
9
9
 
10
+ let console_color = true;
11
+
10
12
  const { info, error } = console;
11
13
  console.info = (arg) => {
12
- info.call(console, `\x1b[33m${arg}\x1b[0m`);
14
+ if (console_color)
15
+ info.call(console, `\x1b[33m${arg}\x1b[0m`);
16
+ else info.call(console, arg);
13
17
  };
14
18
  console.error = (arg) => {
15
- error.call(console, `\x1b[31m${arg}\x1b[0m`);
19
+ if (console_color)
20
+ error.call(console, `\x1b[31m${arg}\x1b[0m`);
21
+ else error.call(console, arg);
16
22
  };
17
23
 
18
24
  const getHdocPackageVersion = (packagePath) => {
@@ -84,6 +90,8 @@
84
90
  }
85
91
  } else if (process.argv[x].toLowerCase() === "-e") {
86
92
  gen_exclude = true;
93
+ } else if (process.argv[x].toLowerCase() === "--no-color") {
94
+ console_color = false;
87
95
  }
88
96
  }
89
97
  source_path = trueCasePathSync(source_path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.26.3",
3
+ "version": "0.27.0",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {