mkdocs-htmlproofer-plugin 1.1.0__tar.gz → 1.2.1__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.1.0/mkdocs_htmlproofer_plugin.egg-info → mkdocs-htmlproofer-plugin-1.2.1}/PKG-INFO +12 -1
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/README.md +11 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/htmlproofer/plugin.py +26 -23
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1/mkdocs_htmlproofer_plugin.egg-info}/PKG-INFO +12 -1
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/setup.py +1 -1
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/LICENSE.md +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/htmlproofer/__init__.py +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/SOURCES.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/requires.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/top_level.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/pyproject.toml +0 -0
- {mkdocs-htmlproofer-plugin-1.1.0 → mkdocs-htmlproofer-plugin-1.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
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
|
|
@@ -162,6 +162,17 @@ plugins:
|
|
|
162
162
|
validate_rendered_template: True
|
|
163
163
|
```
|
|
164
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
|
+
|
|
165
176
|
## Compatibility with `attr_list` extension
|
|
166
177
|
|
|
167
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.
|
|
@@ -139,6 +139,17 @@ plugins:
|
|
|
139
139
|
validate_rendered_template: True
|
|
140
140
|
```
|
|
141
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
|
+
|
|
142
153
|
## Compatibility with `attr_list` extension
|
|
143
154
|
|
|
144
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.
|
|
@@ -65,6 +65,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
65
65
|
('raise_error', config_options.Type(bool, default=False)),
|
|
66
66
|
('raise_error_after_finish', config_options.Type(bool, default=False)),
|
|
67
67
|
('raise_error_excludes', config_options.Type(dict, default={})),
|
|
68
|
+
('skip_downloads', config_options.Type(bool, default=False)),
|
|
68
69
|
('validate_external_urls', config_options.Type(bool, default=True)),
|
|
69
70
|
('validate_rendered_template', config_options.Type(bool, default=False)),
|
|
70
71
|
('ignore_urls', config_options.Type(list, default=[])),
|
|
@@ -115,9 +116,10 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
115
116
|
|
|
116
117
|
all_element_ids = set(tag['id'] for tag in soup.select('[id]'))
|
|
117
118
|
all_element_ids.add('') # Empty anchor is commonly used, but not real
|
|
118
|
-
for a in soup.find_all('a', href=True):
|
|
119
|
-
url = a['href']
|
|
120
119
|
|
|
120
|
+
urls = set(a['href'] for a in soup.find_all('a', href=True)) | set(img['src'] for img in soup.find_all('img'))
|
|
121
|
+
|
|
122
|
+
for url in urls:
|
|
121
123
|
if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
|
|
122
124
|
if self.config['warn_on_ignored_urls']:
|
|
123
125
|
log_warning(f"ignoring URL {url} from {page.file.src_path}")
|
|
@@ -146,7 +148,13 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
146
148
|
@lru_cache(maxsize=1000)
|
|
147
149
|
def resolve_web_scheme(self, url: str) -> int:
|
|
148
150
|
try:
|
|
149
|
-
response = self._session.get(url, timeout=URL_TIMEOUT)
|
|
151
|
+
response = self._session.get(url, timeout=URL_TIMEOUT, stream=True)
|
|
152
|
+
|
|
153
|
+
if self.config['skip_downloads'] is False:
|
|
154
|
+
# Download the entire contents as to not break previous behaviour.
|
|
155
|
+
for _ in response.iter_content(chunk_size=1024):
|
|
156
|
+
pass
|
|
157
|
+
|
|
150
158
|
return response.status_code
|
|
151
159
|
except requests.exceptions.Timeout:
|
|
152
160
|
return 504
|
|
@@ -187,18 +195,20 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
187
195
|
return True
|
|
188
196
|
|
|
189
197
|
url_target, _, optional_anchor = match.groups()
|
|
190
|
-
|
|
191
|
-
if
|
|
192
|
-
# URL is a link to another local Markdown file that may include an anchor.
|
|
193
|
-
target_markdown = HtmlProoferPlugin.find_target_markdown(url_target, src_path, files)
|
|
194
|
-
if target_markdown is None:
|
|
195
|
-
# The corresponding Markdown page was not found.
|
|
196
|
-
return False
|
|
197
|
-
if optional_anchor and not HtmlProoferPlugin.contains_anchor(target_markdown, optional_anchor):
|
|
198
|
-
# The corresponding Markdown header for this anchor was not found.
|
|
199
|
-
return False
|
|
200
|
-
elif HtmlProoferPlugin.find_source_file(url_target, src_path, files) is None:
|
|
198
|
+
source_file = HtmlProoferPlugin.find_source_file(url_target, src_path, files)
|
|
199
|
+
if source_file is None:
|
|
201
200
|
return False
|
|
201
|
+
|
|
202
|
+
# If there's an anchor (fragment) on the link, we try to find it in the source_file
|
|
203
|
+
if optional_anchor:
|
|
204
|
+
_, extension = os.path.splitext(source_file.src_uri)
|
|
205
|
+
# Currently only Markdown-based pages are supported, but conceptually others could be added below
|
|
206
|
+
if extension == ".md":
|
|
207
|
+
if source_file.page is None or source_file.page.markdown is None:
|
|
208
|
+
return False
|
|
209
|
+
if not HtmlProoferPlugin.contains_anchor(source_file.page.markdown, optional_anchor):
|
|
210
|
+
return False
|
|
211
|
+
|
|
202
212
|
return True
|
|
203
213
|
|
|
204
214
|
@staticmethod
|
|
@@ -285,17 +295,10 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
285
295
|
def bad_url(url_status: int) -> bool:
|
|
286
296
|
if url_status == -1:
|
|
287
297
|
return True
|
|
288
|
-
elif url_status == 401 or url_status == 403:
|
|
289
|
-
return False
|
|
290
|
-
elif url_status in (503, 504):
|
|
291
|
-
# Usually transient
|
|
292
|
-
return False
|
|
293
|
-
elif url_status == 999:
|
|
294
|
-
# Returned by some websites (e.g. LinkedIn) that think you're crawling them.
|
|
295
|
-
return False
|
|
296
298
|
elif url_status >= 400:
|
|
297
299
|
return True
|
|
298
|
-
|
|
300
|
+
else:
|
|
301
|
+
return False
|
|
299
302
|
|
|
300
303
|
@staticmethod
|
|
301
304
|
def is_error(config: Config, url: str, url_status: int) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
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
|
|
@@ -162,6 +162,17 @@ plugins:
|
|
|
162
162
|
validate_rendered_template: True
|
|
163
163
|
```
|
|
164
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
|
+
|
|
165
176
|
## Compatibility with `attr_list` extension
|
|
166
177
|
|
|
167
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.
|
|
@@ -9,7 +9,7 @@ def read(fname: str):
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name='mkdocs-htmlproofer-plugin',
|
|
12
|
-
version='1.1
|
|
12
|
+
version='1.2.1',
|
|
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
|