markdown_link_checker_sc 0.0.134 → 0.0.136
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 +11 -10
- package/index.js +21 -10
- package/package.json +1 -1
- package/src/filters.js +0 -1
package/README.md
CHANGED
|
@@ -12,21 +12,22 @@ Current version only does internal link checking
|
|
|
12
12
|
Usage: markdown_link_checker_sc [options]
|
|
13
13
|
|
|
14
14
|
Options:
|
|
15
|
-
-r, --root <path> Root directory of your source (
|
|
16
|
-
|
|
17
|
-
-d, --directory [directory]
|
|
18
|
-
|
|
19
|
-
-i, --imagedir [directory] The directory to search for all image files for global orphan checking, relative to root - such as: `assets` or `en`. Default empty
|
|
20
|
-
|
|
15
|
+
-r, --root <path> Root directory of your docs source, such as <repo>/docs (the folder which contains all your docs, assets, etc). Use -d as well to restrict search to a
|
|
16
|
+
particular subfolder. Defaults to current directory. (default: "D:\\github\\hamishwillee\\markdown_link_checker_sc")
|
|
17
|
+
-d, --directory [directory] A subfolder or the root to search for markdown and html files. Such as: `en` for an English subfolder. Default empty (same as -r directory) (default:
|
|
18
|
+
"")
|
|
19
|
+
-i, --imagedir [directory] The directory to search for all image files for global orphan checking, relative to root - such as: `assets` or `en`. Default empty if not explicitly
|
|
20
|
+
set, and global orphan checking will not be done (default: "")
|
|
21
21
|
-c, --headingAnchorSlugify [value] Slugify approach for turning markdown headings into heading anchors. Currently support vuepress only and always (default: "vuepress")
|
|
22
22
|
-t, --tryMarkdownforHTML [value] Try a markdown file extension check if a link to HTML fails. (default: true)
|
|
23
23
|
-l, --log <types...> Types of console logs to display logs for debugging. Types: functions, todo etc.
|
|
24
|
-
-f, --files <path> JSON file with array of files to report on (default is all files). Paths are relative relative to -d by default, but -r can be used
|
|
25
|
-
|
|
24
|
+
-f, --files <path> JSON file with array of files to report on (default is all files). Paths are relative relative to -d by default, but -r can be used to set a different
|
|
25
|
+
root. (default: "")
|
|
26
26
|
-s, --toc [value] full filename of TOC/Summary file in file system. If not specified, inferred from file with most links to other files
|
|
27
27
|
-u, --site_url [value] Site base url in form dev.example.com (used to catch absolute urls to local files)
|
|
28
28
|
-o, --logtofile [value] Output logs to file (default: true)
|
|
29
29
|
-p, --interactive [value] Interactively add errors to the ignore list at _link_checker_sc/ignore_errors.json (default: false)
|
|
30
|
+
-c, --anchor_in_heading [value] Detect anchors in heading such as: # Heading {#anchor} (default: true)
|
|
30
31
|
-h, --help display help for command
|
|
31
32
|
```
|
|
32
33
|
|
|
@@ -73,9 +74,9 @@ This does catch a LOT of cases though, and is pretty quick.
|
|
|
73
74
|
|
|
74
75
|
## TODO
|
|
75
76
|
|
|
76
|
-
Anchors that are not
|
|
77
|
+
Anchors that are not URL-escaped can trip it up.
|
|
77
78
|
- You can URL escape them like this: [Airframe Reference](#underwater_robot_underwater_robot_hippocampus_uuv_%28unmanned_underwater_vehicle%29)
|
|
78
|
-
- BUT the
|
|
79
|
+
- BUT the comparison of the anchor is NOT url escaped, so you would need to convert back to compare.
|
|
79
80
|
- URL escaping anchors and reversing for comparison is not done.
|
|
80
81
|
|
|
81
82
|
Anchors defined in id in a or span are caught. Need to check those in video, div are also caught and used in internal link checking.
|
package/index.js
CHANGED
|
@@ -31,14 +31,15 @@ import { filterErrors, filterIgnoreErrors } from "./src/filters.js";
|
|
|
31
31
|
program
|
|
32
32
|
.option(
|
|
33
33
|
"-r, --root <path>",
|
|
34
|
-
"Root directory of your source (
|
|
34
|
+
"Root directory of your docs source, such as <repo>/docs (the folder which contains all your docs, assets, etc). Use -d as well to restrict search to a particular subfolder. Defaults to current directory.",
|
|
35
35
|
process.cwd()
|
|
36
36
|
)
|
|
37
37
|
.option(
|
|
38
38
|
"-d, --directory [directory]",
|
|
39
|
-
"
|
|
39
|
+
"A subfolder or the docs root to search for markdown and html files. Such as: `en` for an English subfolder. Default empty (same as -r directory)",
|
|
40
40
|
""
|
|
41
41
|
)
|
|
42
|
+
|
|
42
43
|
.option(
|
|
43
44
|
"-i, --imagedir [directory]",
|
|
44
45
|
"The directory to search for all image files for global orphan checking, relative to root - such as: `assets` or `en`. Default empty if not explicitly set, and global orphan checking will not be done",
|
|
@@ -60,10 +61,14 @@ program
|
|
|
60
61
|
)
|
|
61
62
|
.option(
|
|
62
63
|
"-f, --files <path>",
|
|
63
|
-
"JSON file with array of files to report on (default is all files).
|
|
64
|
+
"JSON file with array of files to report on (default is all files). JSON paths are usually relative to git root. Resolved to absolute file paths using `-g`.",
|
|
65
|
+
""
|
|
66
|
+
)
|
|
67
|
+
.option(
|
|
68
|
+
"-g, --repo [directory]",
|
|
69
|
+
"Repo root directory. Files in -f JSON are resolved to absolute paths relative to this dir. Defaults to current directory.)",
|
|
64
70
|
""
|
|
65
71
|
)
|
|
66
|
-
|
|
67
72
|
.option(
|
|
68
73
|
"-s, --toc [value]",
|
|
69
74
|
"full filename of TOC/Summary file in file system. If not specified, inferred from file with most links to other files"
|
|
@@ -115,7 +120,7 @@ async function loadJSONFileToReportOn(filePath) {
|
|
|
115
120
|
let filesArray = JSON.parse(fileContent);
|
|
116
121
|
// Array relative to root, so update to have full path
|
|
117
122
|
filesArray = filesArray.map((str) =>
|
|
118
|
-
path.join(sharedData.options.
|
|
123
|
+
path.join(sharedData.options.repo, str)
|
|
119
124
|
);
|
|
120
125
|
|
|
121
126
|
sharedData.options.log.includes("quick")
|
|
@@ -125,7 +130,7 @@ async function loadJSONFileToReportOn(filePath) {
|
|
|
125
130
|
return filesArray;
|
|
126
131
|
} catch (error) {
|
|
127
132
|
console.error(`Error reading file: ${error.message}`);
|
|
128
|
-
console.log(`Error reading file: ${error.message}`);
|
|
133
|
+
//console.log(`Error reading file: ${error.message}`);
|
|
129
134
|
process.exit(1);
|
|
130
135
|
}
|
|
131
136
|
}
|
|
@@ -157,9 +162,10 @@ async function loadJSONFileToIgnore(filePath) {
|
|
|
157
162
|
|
|
158
163
|
return filesArray;
|
|
159
164
|
} catch (error) {
|
|
160
|
-
console.error(`Error reading file: ${error.message}`);
|
|
161
|
-
console.log(`Error reading file: ${error.message}`);
|
|
162
|
-
|
|
165
|
+
//console.error(`Error reading file: ${error.message}`);
|
|
166
|
+
console.log(`Error reading ignore file: ${error.message}`);
|
|
167
|
+
return [];
|
|
168
|
+
//process.exit(1);
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
|
|
@@ -239,9 +245,14 @@ const processDirectory = async (dir) => {
|
|
|
239
245
|
))
|
|
240
246
|
: (sharedData.options.files = []);
|
|
241
247
|
|
|
242
|
-
|
|
248
|
+
const pathToJsonIgnoreFile = path.join(
|
|
249
|
+
sharedData.options.root,
|
|
243
250
|
"_link_checker_sc/ignorefile.json"
|
|
244
251
|
);
|
|
252
|
+
//console.log(`debug: pathToJsonIgnoreFile: ${pathToJsonIgnoreFile}`);
|
|
253
|
+
sharedData.options.ignoreFiles = await loadJSONFileToIgnore(
|
|
254
|
+
pathToJsonIgnoreFile
|
|
255
|
+
);
|
|
245
256
|
|
|
246
257
|
// process containing markdown, return results which includes links, headings, id anchors
|
|
247
258
|
const results = await processDirectory(markdownDirectory);
|
package/package.json
CHANGED
package/src/filters.js
CHANGED