hdoc-tools 0.9.47 → 0.9.48
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 +18 -15
- package/package.json +1 -1
package/hdoc-validate.js
CHANGED
@@ -12,10 +12,10 @@
|
|
12
12
|
{ trueCasePathSync } = require('true-case-path');
|
13
13
|
|
14
14
|
const spellcheck_options = {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
regex_nav_paths = /[a-z0-9-\/]
|
15
|
+
british: true,
|
16
|
+
spelling: true
|
17
|
+
},
|
18
|
+
regex_nav_paths = /[a-z0-9-\/]+[a-z0-9]+#{0,1}[a-z0-9-\/]+/,
|
19
19
|
agent = new https.Agent({
|
20
20
|
rejectUnauthorized: false
|
21
21
|
});
|
@@ -67,26 +67,28 @@
|
|
67
67
|
|
68
68
|
const checkNavigation = async function (source_path, flat_nav) {
|
69
69
|
let nav_errors = [];
|
70
|
-
for (
|
70
|
+
for (let key in flat_nav) {
|
71
71
|
if (flat_nav.hasOwnProperty(key)) {
|
72
72
|
// doc paths should only contain a-z - characters
|
73
73
|
const invalid_chars = key.replace(regex_nav_paths, '');
|
74
74
|
if (invalid_chars !== '') {
|
75
75
|
nav_errors.push(`Navigation path [${key}] contains the following invalid characters: [${[...invalid_chars].join('] [')}]`);
|
76
76
|
}
|
77
|
+
const key_split = key.split('#');
|
78
|
+
const key_no_hash = key_split[0];
|
77
79
|
|
78
80
|
// Validate path exists - key should be a html file at this point
|
79
81
|
let file_exists = true;
|
80
|
-
let file_name = path.join(source_path,
|
82
|
+
let file_name = path.join(source_path, key_no_hash + '.html');
|
81
83
|
if (!fs.existsSync(file_name)) {
|
82
|
-
file_name = path.join(source_path,
|
84
|
+
file_name = path.join(source_path, key_no_hash + '.htm');
|
83
85
|
if (!fs.existsSync(file_name)) {
|
84
|
-
file_name = path.join(source_path,
|
86
|
+
file_name = path.join(source_path, key_no_hash, 'index.html');
|
85
87
|
if (!fs.existsSync(file_name)) {
|
86
|
-
file_name = path.join(source_path,
|
88
|
+
file_name = path.join(source_path, key_no_hash, 'index.htm');
|
87
89
|
if (!fs.existsSync(file_name)) {
|
88
90
|
file_exists = false;
|
89
|
-
nav_errors.push(`Navigation path [${
|
91
|
+
nav_errors.push(`Navigation path [${key_no_hash}] file does not exist.`);
|
90
92
|
}
|
91
93
|
}
|
92
94
|
}
|
@@ -121,6 +123,7 @@
|
|
121
123
|
}
|
122
124
|
|
123
125
|
// Validate display names/bookmarks
|
126
|
+
console.log(key)
|
124
127
|
for (let i = 0; i < flat_nav[key].length; i++) {
|
125
128
|
if (flat_nav[key][i].link === key) {
|
126
129
|
const translate_output = translator.translate(flat_nav[key][i].text, spellcheck_options);
|
@@ -334,7 +337,7 @@
|
|
334
337
|
|
335
338
|
exports.run = async function (source_path, doc_id, verbose, hdocbook_config, hdocbook_project, nav_items, prod_families, prods_supported, gen_exclude) {
|
336
339
|
console.log(`Performing Validation and Building SEO Link List...`);
|
337
|
-
|
340
|
+
|
338
341
|
// Get a list of HTML files in source_path
|
339
342
|
dree.scan(source_path, dreeOptions, fileCallback);
|
340
343
|
|
@@ -389,7 +392,7 @@
|
|
389
392
|
}
|
390
393
|
|
391
394
|
let excl_output = [];
|
392
|
-
|
395
|
+
|
393
396
|
// Do spellchecking on markdown files
|
394
397
|
let md_files_spellchecked = {};
|
395
398
|
let mdPromiseArray = [];
|
@@ -402,7 +405,7 @@
|
|
402
405
|
await Promise.all(mdPromiseArray.map(async (file) => {
|
403
406
|
// Initiate maps for errors and verbose messages for markdown file
|
404
407
|
const exclusions = await spellcheckContent(file, exclude_spellcheck);
|
405
|
-
if (gen_exclude && exclusions.length > 0) excl_output.push({document_path: file.relativePath.replace('.' + file.extension, ''), words: exclusions});
|
408
|
+
if (gen_exclude && exclusions.length > 0) excl_output.push({ document_path: file.relativePath.replace('.' + file.extension, ''), words: exclusions });
|
406
409
|
md_files_spellchecked[file.relativePath.replace('.' + file.extension, '')] = true;
|
407
410
|
}));
|
408
411
|
|
@@ -419,7 +422,7 @@
|
|
419
422
|
// Check for British spellings in static HTML content
|
420
423
|
if (!md_files_spellchecked[file.relativePath.replace('.' + file.extension, '')]) {
|
421
424
|
const exclusions = await spellcheckContent(file, exclude_spellcheck);
|
422
|
-
if (gen_exclude && exclusions.length > 0) excl_output.push({document_path: file.relativePath.replace('.' + file.extension, ''), words: exclusions});
|
425
|
+
if (gen_exclude && exclusions.length > 0) excl_output.push({ document_path: file.relativePath.replace('.' + file.extension, ''), words: exclusions });
|
423
426
|
}
|
424
427
|
|
425
428
|
const links = getLinks(file);
|
@@ -436,7 +439,7 @@
|
|
436
439
|
|
437
440
|
// Check for multiple H1 tags
|
438
441
|
await checkTags(file);
|
439
|
-
|
442
|
+
|
440
443
|
// Build list content for Google
|
441
444
|
listContent += `/${file.relativePath.replace(path.extname(file.relativePath), '')}`;
|
442
445
|
listContent += '\r\n';
|