hdoc-tools 0.9.56 → 0.10.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/hdoc-validate.js CHANGED
@@ -27,7 +27,8 @@
27
27
  md_to_validate = [],
28
28
  exclude_links = {},
29
29
  exclude_spellcheck = {},
30
- exclude_h1_count = {};
30
+ exclude_h1_count = {},
31
+ exclude_spellcheck_output = [];
31
32
 
32
33
  const excludeLink = async function (url) {
33
34
  if (exclude_links[url]) return true;
@@ -69,16 +70,22 @@
69
70
  }
70
71
  }
71
72
  if (Object.keys(spelling_errors).length) {
73
+ let exclude_output = {
74
+ document_path: sourceFile.relativePath.replace(path.extname(sourceFile.relativePath), ''),
75
+ words: []
76
+ };
72
77
  for (const word in spelling_errors) {
73
78
  if (spelling_errors.hasOwnProperty(word)) {
74
79
  words.push(word);
80
+ exclude_output.words.push(word);
75
81
  }
76
82
  }
83
+ exclude_spellcheck_output.push(exclude_output);
77
84
  }
78
85
  return words;
79
86
  };
80
87
 
81
- const checkNavigation = async function (source_path, flat_nav) {
88
+ const checkNavigation = async function (source_path, flat_nav, excludes) {
82
89
  let nav_errors = [];
83
90
  for (let key in flat_nav) {
84
91
  if (flat_nav.hasOwnProperty(key)) {
@@ -126,7 +133,11 @@
126
133
  if (translate_output.hasOwnProperty(spell_val)) {
127
134
  for (const spelling in translate_output[spell_val][0]) {
128
135
  if (translate_output[spell_val][0].hasOwnProperty(spelling)) {
129
- nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
136
+ if (!excludes[key]) {
137
+ nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
138
+ } else if (!excludes[key].includes(spelling.toLowerCase())) {
139
+ nav_errors.push(`Navigation path [${key}] key contains a British English spelling: ${spelling} should be ${translate_output[spell_val][0][spelling].details}`);
140
+ }
130
141
  }
131
142
  }
132
143
  }
@@ -145,7 +156,11 @@
145
156
  for (let j = 0; j < translate_output[spell_val].length; j++) {
146
157
  for (const spelling in translate_output[spell_val][j]) {
147
158
  if (translate_output[spell_val][j].hasOwnProperty(spelling)) {
148
- nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
159
+ if (!excludes[key]) {
160
+ nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
161
+ } else if (!excludes[key].includes(spelling.toLowerCase())) {
162
+ nav_errors.push(`Navigation path [${key}] display text contains a British English spelling: ${spelling} should be ${translate_output[spell_val][j][spelling].details}`);
163
+ }
149
164
  }
150
165
  }
151
166
  }
@@ -391,22 +406,6 @@
391
406
  if (!hdocbook_config.audience || !(hdocbook_config.audience instanceof Array) || hdocbook_config.audience.length === 0) {
392
407
  meta_errors.push(`Property audience of type array in book metadata is mandatory.`);
393
408
  }
394
-
395
- // Check navigation spellings
396
- const nav_errors = await checkNavigation(source_path, nav_items);
397
- if (nav_errors.length > 0) meta_errors.push(...nav_errors);
398
-
399
- if (meta_errors.length > 0) {
400
- console.log('\r\n-----------------------');
401
- console.log(' Validation Output ');
402
- console.log('-----------------------');
403
- for (let i = 0; i < meta_errors.length; i++) {
404
- console.log(`- ${meta_errors[i]}`);
405
- }
406
- console.log(`\r\n${meta_errors.length} Validation Errors Found`);
407
- return false;
408
- }
409
-
410
409
  if (hdocbook_project.validation) {
411
410
  if (hdocbook_project.validation.exclude_links && hdocbook_project.validation.exclude_links instanceof Array) {
412
411
  hdocbook_project.validation.exclude_links.forEach(function (excl_link) {
@@ -425,6 +424,22 @@
425
424
  }
426
425
  }
427
426
 
427
+ // Check navigation spellings
428
+ const nav_errors = await checkNavigation(source_path, nav_items, exclude_spellcheck);
429
+ if (nav_errors.length > 0) meta_errors.push(...nav_errors);
430
+
431
+ if (meta_errors.length > 0) {
432
+ console.log('\r\n-----------------------');
433
+ console.log(' Validation Output ');
434
+ console.log('-----------------------');
435
+ for (let i = 0; i < meta_errors.length; i++) {
436
+ console.log(`- ${meta_errors[i]}`);
437
+ }
438
+ console.log(`\r\n${meta_errors.length} Validation Errors Found`);
439
+ return false;
440
+ }
441
+
442
+
428
443
  let excl_output = [];
429
444
 
430
445
  // Do spellchecking on markdown files
@@ -520,6 +535,10 @@
520
535
  }
521
536
  if (error_count > 0) {
522
537
  console.log(`\r\n${error_count} Validation Errors Found`);
538
+ if (verbose) {
539
+ console.log(`\n`);
540
+ console.log(JSON.stringify(exclude_spellcheck_output, null, 2));
541
+ }
523
542
  return false;
524
543
  }
525
544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.9.56",
3
+ "version": "0.10.0",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -64,7 +64,11 @@
64
64
  /* eof nav tabs in doc content */
65
65
 
66
66
 
67
-
67
+ .DocContent .code-badge-pre
68
+ {
69
+ max-width: 100%!important;
70
+ min-width: 100%!important;
71
+ }
68
72
 
69
73
  @media (min-width: 1000px) {
70
74
 
@@ -117,3 +121,4 @@
117
121
  width:100%;
118
122
  display:table;
119
123
  }
124
+
@@ -723,4 +723,19 @@
723
723
  content: "/";
724
724
  padding-left: 5px;
725
725
  padding-right: 5px;
726
- }
726
+ }
727
+
728
+
729
+
730
+ /* lighter bg for code blocks */
731
+ .HTL-doc .hljs
732
+ {
733
+ background: #494949;
734
+ width: 100%;
735
+ }
736
+
737
+ .dark .HTL-doc .hljs
738
+ {
739
+ background: #000000;
740
+ width: 100%;
741
+ }
@@ -642,6 +642,7 @@ async function intialiseApp() {
642
642
 
643
643
 
644
644
  //-- get session info
645
+ /*
645
646
  let dummyResponse = {
646
647
  "type": "user",
647
648
  "userId": "doom-guy",
@@ -653,6 +654,7 @@ async function intialiseApp() {
653
654
  "validUntil": "2023-07-30 06:33:49Z"
654
655
  }
655
656
  dummyResponse.expiresDateTime = new Date(dummyResponse.validUntil).toLocaleDateString() + ' ' + new Date(dummyResponse.validUntil).toLocaleTimeString();
657
+ */
656
658
 
657
659
  fetchJsonFile("_api/session/").then(function(sessionData)
658
660
  {
@@ -665,6 +667,7 @@ async function intialiseApp() {
665
667
  view.setSessionInfo(sessionData);
666
668
  }
667
669
  });
670
+
668
671
  //-- eof session stuff
669
672
 
670
673
  await fetchJsonFile("_books/library.json").then(function(data){