markdown_link_checker_sc 0.0.13 → 0.0.116
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 +66 -12
- package/biglog.txt +0 -0
- package/index.js +181 -435
- package/package.json +6 -1
- package/src/errors.js +148 -0
- package/src/helpers.js +41 -0
- package/src/links.js +194 -0
- package/src/output_errors.js +49 -0
- package/src/process_image_orphans.js +97 -0
- package/src/process_internal_url_links.js +20 -0
- package/src/process_local_image_links.js +57 -0
- package/src/process_markdown.js +400 -0
- package/src/process_orphans.js +145 -0
- package/src/process_relative_links.js +116 -0
- package/src/shared_data.js +2 -0
- package/src/slugify.js +17 -0
- package/tests/errortype/current_file_missing_anchor/heading_present_for_anchor.md +13 -0
- package/tests/errortype/current_file_missing_anchor/missing_heading.md +5 -0
- package/tests/errortype/linked_file_missing_anchor/file_with_broken_heading_link.md +10 -0
- package/tests/errortype/linked_file_missing_anchor/file_without_heading.md +10 -0
- package/tests/errortype/linked_internal_file_html/file_exists.html +5 -0
- package/tests/errortype/linked_internal_file_html/file_exists_as_markdown.md +6 -0
- package/tests/errortype/linked_internal_file_html/links_to_file_that_is_html.md +10 -0
- package/tests/errortype/linked_internal_file_missing/file_present_relative_link_no_error.md +5 -0
- package/tests/errortype/linked_internal_file_missing/file_present_should_be_no_error.md +5 -0
- package/tests/errortype/linked_internal_file_missing/links_to_file_that_is_not_present.md +8 -0
- package/tests/errortype/local_image_not_found/page_with_missing_image.md +9 -0
- package/tests/errortype/local_image_not_found/test.png +0 -0
- package/tests/errortype/orphan_images/assets/image1_not_linked.png +0 -0
- package/tests/errortype/orphan_images/assets/image2_not_linked.png +0 -0
- package/tests/errortype/orphan_images/test/image3_not_linked.png +0 -0
- package/tests/errortype/orphan_images/test/image4_linked.png +0 -0
- package/tests/errortype/orphan_images/test/intro.md +11 -0
- package/tests/errortype/page_not_in_toc/page1intoc_should_not_error.md +7 -0
- package/tests/errortype/page_not_in_toc/page2intoc_should_not_error.md +7 -0
- package/tests/errortype/page_not_in_toc/page3NOTinTOC.md +7 -0
- package/tests/errortype/page_not_in_toc/toc.md +9 -0
- package/tests/errortype/url_to_local_site/mylocalsite_dot_com.md +8 -0
- package/tests/links/tests1.md +93 -0
- package/tests/links/tests2.md +3 -0
- package/tests/tests1.md +0 -42
package/README.md
CHANGED
|
@@ -6,30 +6,84 @@ Probably never coming out of alpha. Bit of fun.
|
|
|
6
6
|
Markdown link checker in node.
|
|
7
7
|
Better handling of internal link checking.
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
Current version only does internal link checking
|
|
11
10
|
|
|
12
11
|
```
|
|
13
12
|
Usage: markdown_link_checker_sc [options]
|
|
14
13
|
|
|
15
14
|
Options:
|
|
16
|
-
-
|
|
17
|
-
"D:\\github\\hamishwillee\\markdown_link_checker_sc")
|
|
18
|
-
-
|
|
19
|
-
|
|
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 run on
|
|
16
|
+
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 as -r
|
|
18
|
+
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 if not
|
|
20
|
+
explicitly set, and global orphan checking will not be done (default: "")
|
|
21
|
+
-c, --headingAnchorSlugify [value] Slugify approach for turning markdown headings into heading anchors. Currently support vuepress only and always (default: "vuepress")
|
|
20
22
|
-t, --tryMarkdownforHTML [value] Try a markdown file extension check if a link to HTML fails. (default: true)
|
|
21
|
-
-l, --log
|
|
22
|
-
-f, --files <path> JSON file with array of files to report on (default is all files). Paths are
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
-
|
|
26
|
-
directory. Useful if directory is not your repo root (default: "")
|
|
23
|
+
-l, --log <types...> Export logs for debugging. Types: allerrors, filterederrors, allresults 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 to set a
|
|
25
|
+
different root. (default: "")
|
|
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
|
+
-u, --site_url [value] Site base url in form dev.example.com (used to catch absolute urls to local files)
|
|
27
28
|
-h, --help display help for command
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
|
|
32
|
+
## What link formats can it match
|
|
33
|
+
|
|
34
|
+
Currently matches:
|
|
35
|
+
- `\[Link text](url#anchor)`, `\[Link text](url#anchor?param1=value...)`, `\[Link text](url?param1=value...#anchor)`
|
|
36
|
+
- `[Link text](url#anchor "title")`
|
|
37
|
+
- ``
|
|
38
|
+
- `<a href="someurl#someanchor?someparams" title="sometitle">some text</a>`
|
|
39
|
+
- `<img src="someurl" title="sometitle" />`
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
> **Note:** It uses simple regexp. If you have a link commented out, or inside a code block that may well be captured.
|
|
43
|
+
|
|
44
|
+
There are heaps of link formats it does not match:
|
|
45
|
+
|
|
46
|
+
- `<http://www.whatever.com>` - doesn't support autolinks
|
|
47
|
+
- `www.fred.com` - Doesn't support auto-links external.
|
|
48
|
+
- `[](linkurl)`- Doesn't properly support a link around an image.
|
|
49
|
+
- `linkreference: linkurl` - Doesn't support reference links (which would be linked like `[link text][linkreference]`
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Essentially lots of the other things https://github.github.com/gfm/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
The regex that drives this is very simple.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
There are many other alternatives, such as: https://github.com/tcort/markdown-link-check
|
|
59
|
+
You might also use a tokenziker or round trip to HTML using something like https://marked.js.org/using_advanced#inline in future as HTML is eaiser to extract links from.
|
|
60
|
+
|
|
61
|
+
This does catch a LOT of cases though, and is pretty quick.
|
|
62
|
+
|
|
63
|
+
## TODO
|
|
64
|
+
|
|
65
|
+
- Files passed in should be filtered to check if markdown and only use the markdown ones in the markdown areas.
|
|
66
|
+
- Files passed in shoudl be filtered for image types.
|
|
67
|
+
All image types passed in should be checked to make sure they are not orphans.
|
|
68
|
+
|
|
69
|
+
Anchors that are not url escaped can trip it up.
|
|
70
|
+
- You can URL escape them like this: [Airframe Reference](#underwater_robot_underwater_robot_hippocampus_uuv_%28unmanned_underwater_vehicle%29)
|
|
71
|
+
- BUT the comparision of the anchor is NOT url escaped, so you would need to convert back to compare.
|
|
72
|
+
- URL escaping anchors and reversing for comparison is not done.
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
A way to indicate that a particular error can be ignored - e.g. by page, type, maybe by line etc. Perhaps make this something that can be turned on and off.
|
|
77
|
+
|
|
78
|
+
Get images in/around the source files that are not linked - i.e. orphan images.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# How does it work?
|
|
83
|
+
|
|
31
84
|
The way this works:
|
|
32
|
-
-
|
|
85
|
+
- Specify the directory and it will searc
|
|
86
|
+
h below that for all markdown/html files.
|
|
33
87
|
- It loads each file, and:
|
|
34
88
|
- parses for markdown and html style links for both page and image links.
|
|
35
89
|
- parses headings and builds list of anchors in the page (as per vuepress) for those headings (poorly tested code)
|
package/biglog.txt
ADDED
|
Binary file
|