mkdocs-htmlproofer-plugin 1.0.0__tar.gz → 1.2.0__tar.gz
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.
- {mkdocs-htmlproofer-plugin-1.0.0/mkdocs_htmlproofer_plugin.egg-info → mkdocs-htmlproofer-plugin-1.2.0}/PKG-INFO +49 -12
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/README.md +48 -11
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/htmlproofer/plugin.py +48 -33
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0/mkdocs_htmlproofer_plugin.egg-info}/PKG-INFO +49 -12
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/setup.py +1 -1
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/LICENSE.md +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/htmlproofer/__init__.py +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/mkdocs_htmlproofer_plugin.egg-info/SOURCES.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/mkdocs_htmlproofer_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/mkdocs_htmlproofer_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/mkdocs_htmlproofer_plugin.egg-info/requires.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/mkdocs_htmlproofer_plugin.egg-info/top_level.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/pyproject.toml +0 -0
- {mkdocs-htmlproofer-plugin-1.0.0 → mkdocs-htmlproofer-plugin-1.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A MkDocs plugin that validates URL in rendered HTML files
|
|
5
5
|
Home-page: https://github.com/manuzhang/mkdocs-htmlproofer-plugin
|
|
6
6
|
Author: Manu Zhang
|
|
@@ -51,12 +51,6 @@ plugins:
|
|
|
51
51
|
- htmlproofer
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
To enable cross-page anchor validation, you must set `use_directory_urls = False` in `mkdocs.yml`:
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
use_directory_urls: False
|
|
58
|
-
```
|
|
59
|
-
|
|
60
54
|
## Configuring
|
|
61
55
|
|
|
62
56
|
### `enabled`
|
|
@@ -101,7 +95,7 @@ plugins:
|
|
|
101
95
|
### `raise_error_excludes`
|
|
102
96
|
|
|
103
97
|
When specifying `raise_error: True` or `raise_error_after_finish: True`, it is possible to ignore errors
|
|
104
|
-
for combinations of
|
|
98
|
+
for combinations of URLs and status codes with `raise_error_excludes`. Each URL supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
105
99
|
|
|
106
100
|
```yaml
|
|
107
101
|
plugins:
|
|
@@ -110,10 +104,42 @@ plugins:
|
|
|
110
104
|
raise_error: True
|
|
111
105
|
raise_error_excludes:
|
|
112
106
|
504: ['https://www.mkdocs.org/']
|
|
113
|
-
404: ['https://github.com/manuzhang
|
|
107
|
+
404: ['https://github.com/manuzhang/*']
|
|
114
108
|
400: ['*']
|
|
115
109
|
```
|
|
116
110
|
|
|
111
|
+
### `ignore_urls`
|
|
112
|
+
|
|
113
|
+
Avoid validating the given list of URLs by ignoring them altogether. Each URL in the
|
|
114
|
+
list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
115
|
+
|
|
116
|
+
Unlike `raise_error_excludes`, ignored URLs will not be fetched at all.
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
plugins:
|
|
120
|
+
- search
|
|
121
|
+
- htmlproofer:
|
|
122
|
+
raise_error: True
|
|
123
|
+
ignore_urls:
|
|
124
|
+
- https://github.com/myprivateorg/*
|
|
125
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `warn_on_ignored_urls`
|
|
129
|
+
|
|
130
|
+
Log a warning when ignoring URLs with `ignore_urls` option. Defaults to `false` (no warning).
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
plugins:
|
|
134
|
+
- search
|
|
135
|
+
- htmlproofer:
|
|
136
|
+
raise_error: True
|
|
137
|
+
ignore_urls:
|
|
138
|
+
- https://github.com/myprivateorg/*
|
|
139
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
140
|
+
warn_on_ignored_urls: true
|
|
141
|
+
```
|
|
142
|
+
|
|
117
143
|
### `validate_external_urls`
|
|
118
144
|
|
|
119
145
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -136,13 +162,24 @@ plugins:
|
|
|
136
162
|
validate_rendered_template: True
|
|
137
163
|
```
|
|
138
164
|
|
|
165
|
+
### `skip_downloads`
|
|
166
|
+
|
|
167
|
+
Optionally skip downloading of a remote URLs content via GET request. This can
|
|
168
|
+
considerably reduce the time taken to validate URLs.
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
plugins:
|
|
172
|
+
- htmlproofer:
|
|
173
|
+
skip_downloads: True
|
|
174
|
+
```
|
|
175
|
+
|
|
139
176
|
## Compatibility with `attr_list` extension
|
|
140
177
|
|
|
141
|
-
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
178
|
+
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
142
179
|
This can be useful for multilingual documentation to keep anchors as language neutral permalinks in all languages.
|
|
143
180
|
|
|
144
181
|
* A sample for a heading `# Grüße {#greetings}` (the slugified generated anchor `Gre` is overwritten with `greetings`).
|
|
145
|
-
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
182
|
+
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
146
183
|
* And generall for paragraphs:
|
|
147
184
|
```markdown
|
|
148
185
|
Listing: This is noteworthy.
|
|
@@ -155,4 +192,4 @@ More information about plugins in the [MkDocs documentation](http://www.mkdocs.o
|
|
|
155
192
|
|
|
156
193
|
## Acknowledgement
|
|
157
194
|
|
|
158
|
-
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/blog/
|
|
195
|
+
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/en-us/blog/find-fix-website-link-rot-python-beautifulsoup-requests-html) article.
|
|
@@ -28,12 +28,6 @@ plugins:
|
|
|
28
28
|
- htmlproofer
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
To enable cross-page anchor validation, you must set `use_directory_urls = False` in `mkdocs.yml`:
|
|
32
|
-
|
|
33
|
-
```yaml
|
|
34
|
-
use_directory_urls: False
|
|
35
|
-
```
|
|
36
|
-
|
|
37
31
|
## Configuring
|
|
38
32
|
|
|
39
33
|
### `enabled`
|
|
@@ -78,7 +72,7 @@ plugins:
|
|
|
78
72
|
### `raise_error_excludes`
|
|
79
73
|
|
|
80
74
|
When specifying `raise_error: True` or `raise_error_after_finish: True`, it is possible to ignore errors
|
|
81
|
-
for combinations of
|
|
75
|
+
for combinations of URLs and status codes with `raise_error_excludes`. Each URL supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
82
76
|
|
|
83
77
|
```yaml
|
|
84
78
|
plugins:
|
|
@@ -87,10 +81,42 @@ plugins:
|
|
|
87
81
|
raise_error: True
|
|
88
82
|
raise_error_excludes:
|
|
89
83
|
504: ['https://www.mkdocs.org/']
|
|
90
|
-
404: ['https://github.com/manuzhang
|
|
84
|
+
404: ['https://github.com/manuzhang/*']
|
|
91
85
|
400: ['*']
|
|
92
86
|
```
|
|
93
87
|
|
|
88
|
+
### `ignore_urls`
|
|
89
|
+
|
|
90
|
+
Avoid validating the given list of URLs by ignoring them altogether. Each URL in the
|
|
91
|
+
list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
92
|
+
|
|
93
|
+
Unlike `raise_error_excludes`, ignored URLs will not be fetched at all.
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
plugins:
|
|
97
|
+
- search
|
|
98
|
+
- htmlproofer:
|
|
99
|
+
raise_error: True
|
|
100
|
+
ignore_urls:
|
|
101
|
+
- https://github.com/myprivateorg/*
|
|
102
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### `warn_on_ignored_urls`
|
|
106
|
+
|
|
107
|
+
Log a warning when ignoring URLs with `ignore_urls` option. Defaults to `false` (no warning).
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
plugins:
|
|
111
|
+
- search
|
|
112
|
+
- htmlproofer:
|
|
113
|
+
raise_error: True
|
|
114
|
+
ignore_urls:
|
|
115
|
+
- https://github.com/myprivateorg/*
|
|
116
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
117
|
+
warn_on_ignored_urls: true
|
|
118
|
+
```
|
|
119
|
+
|
|
94
120
|
### `validate_external_urls`
|
|
95
121
|
|
|
96
122
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -113,13 +139,24 @@ plugins:
|
|
|
113
139
|
validate_rendered_template: True
|
|
114
140
|
```
|
|
115
141
|
|
|
142
|
+
### `skip_downloads`
|
|
143
|
+
|
|
144
|
+
Optionally skip downloading of a remote URLs content via GET request. This can
|
|
145
|
+
considerably reduce the time taken to validate URLs.
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
plugins:
|
|
149
|
+
- htmlproofer:
|
|
150
|
+
skip_downloads: True
|
|
151
|
+
```
|
|
152
|
+
|
|
116
153
|
## Compatibility with `attr_list` extension
|
|
117
154
|
|
|
118
|
-
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
155
|
+
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
119
156
|
This can be useful for multilingual documentation to keep anchors as language neutral permalinks in all languages.
|
|
120
157
|
|
|
121
158
|
* A sample for a heading `# Grüße {#greetings}` (the slugified generated anchor `Gre` is overwritten with `greetings`).
|
|
122
|
-
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
159
|
+
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
123
160
|
* And generall for paragraphs:
|
|
124
161
|
```markdown
|
|
125
162
|
Listing: This is noteworthy.
|
|
@@ -132,4 +169,4 @@ More information about plugins in the [MkDocs documentation](http://www.mkdocs.o
|
|
|
132
169
|
|
|
133
170
|
## Acknowledgement
|
|
134
171
|
|
|
135
|
-
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/blog/
|
|
172
|
+
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/en-us/blog/find-fix-website-link-rot-python-beautifulsoup-requests-html) article.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import fnmatch
|
|
1
2
|
from functools import lru_cache, partial
|
|
2
3
|
import os.path
|
|
3
4
|
import pathlib
|
|
4
5
|
import re
|
|
5
|
-
from typing import Dict, Optional, Set
|
|
6
|
+
from typing import Dict, List, Optional, Set
|
|
6
7
|
import urllib.parse
|
|
7
8
|
import uuid
|
|
8
9
|
|
|
@@ -56,7 +57,7 @@ def log_error(msg, *args, **kwargs):
|
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
class HtmlProoferPlugin(BasePlugin):
|
|
59
|
-
files:
|
|
60
|
+
files: List[File]
|
|
60
61
|
invalid_links = False
|
|
61
62
|
|
|
62
63
|
config_scheme = (
|
|
@@ -64,8 +65,11 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
64
65
|
('raise_error', config_options.Type(bool, default=False)),
|
|
65
66
|
('raise_error_after_finish', config_options.Type(bool, default=False)),
|
|
66
67
|
('raise_error_excludes', config_options.Type(dict, default={})),
|
|
68
|
+
('skip_downloads', config_options.Type(bool, default=False)),
|
|
67
69
|
('validate_external_urls', config_options.Type(bool, default=True)),
|
|
68
70
|
('validate_rendered_template', config_options.Type(bool, default=False)),
|
|
71
|
+
('ignore_urls', config_options.Type(list, default=[])),
|
|
72
|
+
('warn_on_ignored_urls', config_options.Type(bool, default=False)),
|
|
69
73
|
)
|
|
70
74
|
|
|
71
75
|
def __init__(self):
|
|
@@ -73,7 +77,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
73
77
|
self._session.verify = False
|
|
74
78
|
self._session.headers.update(URL_HEADERS)
|
|
75
79
|
self._session.max_redirects = 5
|
|
76
|
-
self.files =
|
|
80
|
+
self.files = []
|
|
77
81
|
self.scheme_handlers = {
|
|
78
82
|
"http": partial(HtmlProoferPlugin.resolve_web_scheme, self),
|
|
79
83
|
"https": partial(HtmlProoferPlugin.resolve_web_scheme, self),
|
|
@@ -84,15 +88,24 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
84
88
|
if self.config['raise_error_after_finish'] and self.invalid_links:
|
|
85
89
|
raise PluginError("Invalid links present.")
|
|
86
90
|
|
|
87
|
-
def
|
|
91
|
+
def on_files(self, files: Files, config: Config) -> None:
|
|
88
92
|
# Store files to allow inspecting Markdown files in later stages.
|
|
89
|
-
|
|
93
|
+
# The values in files at this point are not guaranteed to be the same as the ones in the Page objects.
|
|
94
|
+
# For example, material blog plugin may modify the files after this event.
|
|
95
|
+
for f in files:
|
|
96
|
+
self.files.append(f)
|
|
90
97
|
|
|
91
98
|
def on_post_page(self, output_content: str, page: Page, config: Config) -> None:
|
|
92
99
|
if not self.config['enabled']:
|
|
93
100
|
return
|
|
94
101
|
|
|
95
|
-
|
|
102
|
+
# Optimization: At this point, we have all the files, so we can create
|
|
103
|
+
# a dictionary for faster lookups. Prior to this point, files are
|
|
104
|
+
# still being updated so creating a dictionary before now would result
|
|
105
|
+
# in incorrect values appearing as the key.
|
|
106
|
+
opt_files = {}
|
|
107
|
+
opt_files.update({os.path.normpath(file.url): file for file in self.files})
|
|
108
|
+
opt_files.update({os.path.normpath(file.src_uri): file for file in self.files})
|
|
96
109
|
|
|
97
110
|
# Optimization: only parse links and headings
|
|
98
111
|
# li, sup are used for footnotes
|
|
@@ -106,10 +119,13 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
106
119
|
for a in soup.find_all('a', href=True):
|
|
107
120
|
url = a['href']
|
|
108
121
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
|
|
123
|
+
if self.config['warn_on_ignored_urls']:
|
|
124
|
+
log_warning(f"ignoring URL {url} from {page.file.src_path}")
|
|
125
|
+
else:
|
|
126
|
+
url_status = self.get_url_status(url, page.file.src_path, all_element_ids, opt_files)
|
|
127
|
+
if self.bad_url(url_status) and self.is_error(self.config, url, url_status):
|
|
128
|
+
self.report_invalid_url(url, url_status, page.file.src_path)
|
|
113
129
|
|
|
114
130
|
def report_invalid_url(self, url, url_status, src_path):
|
|
115
131
|
error = f'invalid url - {url} [{url_status}] [{src_path}]'
|
|
@@ -131,7 +147,13 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
131
147
|
@lru_cache(maxsize=1000)
|
|
132
148
|
def resolve_web_scheme(self, url: str) -> int:
|
|
133
149
|
try:
|
|
134
|
-
response = self._session.get(url, timeout=URL_TIMEOUT)
|
|
150
|
+
response = self._session.get(url, timeout=URL_TIMEOUT, stream=True)
|
|
151
|
+
|
|
152
|
+
if self.config['skip_downloads'] is False:
|
|
153
|
+
# Download the entire contents as to not break previous behaviour.
|
|
154
|
+
for _ in response.iter_content(chunk_size=1024):
|
|
155
|
+
pass
|
|
156
|
+
|
|
135
157
|
return response.status_code
|
|
136
158
|
except requests.exceptions.Timeout:
|
|
137
159
|
return 504
|
|
@@ -145,8 +167,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
145
167
|
url: str,
|
|
146
168
|
src_path: str,
|
|
147
169
|
all_element_ids: Set[str],
|
|
148
|
-
files: Dict[str, File]
|
|
149
|
-
use_directory_urls: bool
|
|
170
|
+
files: Dict[str, File]
|
|
150
171
|
) -> int:
|
|
151
172
|
if any(pat.match(url) for pat in LOCAL_PATTERNS):
|
|
152
173
|
return 0
|
|
@@ -158,18 +179,13 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
158
179
|
return 0
|
|
159
180
|
if fragment and not path:
|
|
160
181
|
return 0 if url[1:] in all_element_ids else 404
|
|
161
|
-
|
|
162
|
-
# use_directory_urls = True injects too many challenges for locating the correct target
|
|
163
|
-
# Markdown file, so disable target anchor validation in this case. Examples include:
|
|
164
|
-
# ../..#BAD_ANCHOR style links to index.html and extra ../ inserted into relative
|
|
165
|
-
# links.
|
|
182
|
+
else:
|
|
166
183
|
is_valid = self.is_url_target_valid(url, src_path, files)
|
|
167
184
|
url_status = 404
|
|
168
185
|
if not is_valid and self.is_error(self.config, url, url_status):
|
|
169
186
|
log_warning(f"Unable to locate source file for: {url}")
|
|
170
187
|
return url_status
|
|
171
188
|
return 0
|
|
172
|
-
return 0
|
|
173
189
|
|
|
174
190
|
@staticmethod
|
|
175
191
|
def is_url_target_valid(url: str, src_path: str, files: Dict[str, File]) -> bool:
|
|
@@ -209,8 +225,14 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
209
225
|
# Convert root/site paths
|
|
210
226
|
search_path = os.path.normpath(url[1:])
|
|
211
227
|
else:
|
|
212
|
-
# Handle relative links by
|
|
213
|
-
|
|
228
|
+
# Handle relative links by looking up the destination url for the
|
|
229
|
+
# src_path and getting the parent directory.
|
|
230
|
+
try:
|
|
231
|
+
dest_uri = files[src_path].dest_uri
|
|
232
|
+
src_dir = urllib.parse.quote(str(pathlib.Path(dest_uri).parent), safe='/\\')
|
|
233
|
+
search_path = os.path.normpath(str(pathlib.Path(src_dir) / pathlib.Path(url)))
|
|
234
|
+
except KeyError:
|
|
235
|
+
return None
|
|
214
236
|
|
|
215
237
|
try:
|
|
216
238
|
return files[search_path]
|
|
@@ -270,23 +292,16 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
270
292
|
def bad_url(url_status: int) -> bool:
|
|
271
293
|
if url_status == -1:
|
|
272
294
|
return True
|
|
273
|
-
elif url_status == 401 or url_status == 403:
|
|
274
|
-
return False
|
|
275
|
-
elif url_status in (503, 504):
|
|
276
|
-
# Usually transient
|
|
277
|
-
return False
|
|
278
|
-
elif url_status == 999:
|
|
279
|
-
# Returned by some websites (e.g. LinkedIn) that think you're crawling them.
|
|
280
|
-
return False
|
|
281
295
|
elif url_status >= 400:
|
|
282
296
|
return True
|
|
283
|
-
|
|
297
|
+
else:
|
|
298
|
+
return False
|
|
284
299
|
|
|
285
300
|
@staticmethod
|
|
286
301
|
def is_error(config: Config, url: str, url_status: int) -> bool:
|
|
287
302
|
excludes = config['raise_error_excludes'].get(url_status, [])
|
|
288
303
|
|
|
289
|
-
if
|
|
304
|
+
if any(fnmatch.fnmatch(url, exclude_url) for exclude_url in excludes):
|
|
290
305
|
return False
|
|
291
|
-
|
|
292
|
-
|
|
306
|
+
else:
|
|
307
|
+
return True
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: A MkDocs plugin that validates URL in rendered HTML files
|
|
5
5
|
Home-page: https://github.com/manuzhang/mkdocs-htmlproofer-plugin
|
|
6
6
|
Author: Manu Zhang
|
|
@@ -51,12 +51,6 @@ plugins:
|
|
|
51
51
|
- htmlproofer
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
To enable cross-page anchor validation, you must set `use_directory_urls = False` in `mkdocs.yml`:
|
|
55
|
-
|
|
56
|
-
```yaml
|
|
57
|
-
use_directory_urls: False
|
|
58
|
-
```
|
|
59
|
-
|
|
60
54
|
## Configuring
|
|
61
55
|
|
|
62
56
|
### `enabled`
|
|
@@ -101,7 +95,7 @@ plugins:
|
|
|
101
95
|
### `raise_error_excludes`
|
|
102
96
|
|
|
103
97
|
When specifying `raise_error: True` or `raise_error_after_finish: True`, it is possible to ignore errors
|
|
104
|
-
for combinations of
|
|
98
|
+
for combinations of URLs and status codes with `raise_error_excludes`. Each URL supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
105
99
|
|
|
106
100
|
```yaml
|
|
107
101
|
plugins:
|
|
@@ -110,10 +104,42 @@ plugins:
|
|
|
110
104
|
raise_error: True
|
|
111
105
|
raise_error_excludes:
|
|
112
106
|
504: ['https://www.mkdocs.org/']
|
|
113
|
-
404: ['https://github.com/manuzhang
|
|
107
|
+
404: ['https://github.com/manuzhang/*']
|
|
114
108
|
400: ['*']
|
|
115
109
|
```
|
|
116
110
|
|
|
111
|
+
### `ignore_urls`
|
|
112
|
+
|
|
113
|
+
Avoid validating the given list of URLs by ignoring them altogether. Each URL in the
|
|
114
|
+
list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
115
|
+
|
|
116
|
+
Unlike `raise_error_excludes`, ignored URLs will not be fetched at all.
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
plugins:
|
|
120
|
+
- search
|
|
121
|
+
- htmlproofer:
|
|
122
|
+
raise_error: True
|
|
123
|
+
ignore_urls:
|
|
124
|
+
- https://github.com/myprivateorg/*
|
|
125
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `warn_on_ignored_urls`
|
|
129
|
+
|
|
130
|
+
Log a warning when ignoring URLs with `ignore_urls` option. Defaults to `false` (no warning).
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
plugins:
|
|
134
|
+
- search
|
|
135
|
+
- htmlproofer:
|
|
136
|
+
raise_error: True
|
|
137
|
+
ignore_urls:
|
|
138
|
+
- https://github.com/myprivateorg/*
|
|
139
|
+
- https://app.dynamic-service-of-some-kind.io*
|
|
140
|
+
warn_on_ignored_urls: true
|
|
141
|
+
```
|
|
142
|
+
|
|
117
143
|
### `validate_external_urls`
|
|
118
144
|
|
|
119
145
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -136,13 +162,24 @@ plugins:
|
|
|
136
162
|
validate_rendered_template: True
|
|
137
163
|
```
|
|
138
164
|
|
|
165
|
+
### `skip_downloads`
|
|
166
|
+
|
|
167
|
+
Optionally skip downloading of a remote URLs content via GET request. This can
|
|
168
|
+
considerably reduce the time taken to validate URLs.
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
plugins:
|
|
172
|
+
- htmlproofer:
|
|
173
|
+
skip_downloads: True
|
|
174
|
+
```
|
|
175
|
+
|
|
139
176
|
## Compatibility with `attr_list` extension
|
|
140
177
|
|
|
141
|
-
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
178
|
+
If you need to manually specify anchors make use of the `attr_list` [extension](https://python-markdown.github.io/extensions/attr_list) in the markdown.
|
|
142
179
|
This can be useful for multilingual documentation to keep anchors as language neutral permalinks in all languages.
|
|
143
180
|
|
|
144
181
|
* A sample for a heading `# Grüße {#greetings}` (the slugified generated anchor `Gre` is overwritten with `greetings`).
|
|
145
|
-
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
182
|
+
* This also works for images `this is a nice image [](foo-bar.png){#nice-image}`
|
|
146
183
|
* And generall for paragraphs:
|
|
147
184
|
```markdown
|
|
148
185
|
Listing: This is noteworthy.
|
|
@@ -155,4 +192,4 @@ More information about plugins in the [MkDocs documentation](http://www.mkdocs.o
|
|
|
155
192
|
|
|
156
193
|
## Acknowledgement
|
|
157
194
|
|
|
158
|
-
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/blog/
|
|
195
|
+
This work is based on the [mkdocs-markdownextradata-plugin](https://github.com/rosscdh/mkdocs-markdownextradata-plugin) project and the [Finding and Fixing Website Link Rot with Python, BeautifulSoup and Requests](https://www.twilio.com/en-us/blog/find-fix-website-link-rot-python-beautifulsoup-requests-html) article.
|
|
@@ -9,7 +9,7 @@ def read(fname: str):
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name='mkdocs-htmlproofer-plugin',
|
|
12
|
-
version='1.
|
|
12
|
+
version='1.2.0',
|
|
13
13
|
description='A MkDocs plugin that validates URL in rendered HTML files',
|
|
14
14
|
long_description=read('README.md'),
|
|
15
15
|
long_description_content_type='text/markdown',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|