hdoc-tools 0.47.4 → 0.47.5
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 +5 -5
- package/package.json +1 -1
package/hdoc-validate.js
CHANGED
|
@@ -529,7 +529,10 @@ const { error } = require("node:console");
|
|
|
529
529
|
const valid_url = hdoc.valid_url(links[i]);
|
|
530
530
|
if (!valid_url) {
|
|
531
531
|
// Could be a relative path, check
|
|
532
|
-
if (links[i].startsWith("
|
|
532
|
+
if (links[i].startsWith("#") || links[i].startsWith("/#")) {
|
|
533
|
+
//Flat Anchor - validate we have a same-file hit
|
|
534
|
+
isHashAnchor(htmlFile, links[i]);
|
|
535
|
+
} else if (links[i].startsWith("/") && !links[i].startsWith("/#")) {
|
|
533
536
|
let link_segments = links[i].split("/");
|
|
534
537
|
if (link_segments[0] === "") link_segments.shift();
|
|
535
538
|
const link_root = link_segments[0] === "_books" ? link_segments[1] : link_segments[0];
|
|
@@ -542,14 +545,11 @@ const { error } = require("node:console");
|
|
|
542
545
|
}
|
|
543
546
|
|
|
544
547
|
// Checking for internal links in other books - can't easily validate those here, returning
|
|
545
|
-
if (link_segments.length > 1 && link_root !== hdocbook_config.docId) {
|
|
548
|
+
if ((link_segments.length > 1 && link_root !== hdocbook_config.docId) || (link_segments.length === 1 && link_root !== hdocbook_config.docId && link_root !== "index")) {
|
|
546
549
|
fs.appendFileSync(skip_link_file, `${links[i]}\n`);
|
|
547
550
|
continue;
|
|
548
551
|
}
|
|
549
552
|
isRelativePath(source_path, htmlFile, links[i]);
|
|
550
|
-
} else if (links[i].startsWith("#") || links[i].startsWith("/#")) {
|
|
551
|
-
//Flat Anchor - validate we have a same-file hit
|
|
552
|
-
isHashAnchor(htmlFile, links[i]);
|
|
553
553
|
} else {
|
|
554
554
|
const error_message = processErrorMessage(`Root relative links should start with a forward-slash: ${links[i]}`, markdown_paths.relativePath, markdown_content, links[i]);
|
|
555
555
|
errors[htmlFile.relativePath].push(error_message);
|