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 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 (i.e. root of github repo). Use -d as well to specify a folder if docs are not in the root, or to just
16
- run on particular subfolder. Defaults to current directory. (default: "D:\\github\\hamishwillee\\markdown_link_checker_sc")
17
- -d, --directory [directory] The directory to search for markdown and html files, relative to root - such as: `en` for an English subfolder. Default empty (same
18
- as -r directory) (default: "")
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
- if not explicitly set, and global orphan checking will not be done (default: "")
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
- to set a different root. (default: "")
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 url escaped can trip it up.
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 comparision of the anchor is NOT url escaped, so you would need to convert back to compare.
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 (i.e. root of github repo). Use -d as well to specify a folder if docs are not in the root, or to just run on particular subfolder. Defaults to current directory.",
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
- "The directory to search for markdown and html files, relative to root - such as: `en` for an English subfolder. Default empty (same as -r directory)",
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). Paths are relative relative to -d by default, but -r can be used to set a different root.",
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.root, str)
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
- process.exit(1);
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
- sharedData.options.ignoreFiles = await loadJSONFileToIgnore(
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown_link_checker_sc",
3
- "version": "0.0.134",
3
+ "version": "0.0.136",
4
4
  "description": "Markdown Link Checker",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/filters.js CHANGED
@@ -14,7 +14,6 @@ function filterIgnoreErrors(errors) {
14
14
  sharedData.options.root,
15
15
  "./_link_checker_sc/ignore_errors.json"
16
16
  );
17
- //console.log(errorFile);
18
17
 
19
18
  try {
20
19
  //sharedData.IgnoreErrors = require('./_link_checker_sc/ignore_errors.json');