mkdocs-htmlproofer-plugin 1.2.0__tar.gz → 1.3.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.2.0/mkdocs_htmlproofer_plugin.egg-info → mkdocs-htmlproofer-plugin-1.3.0}/PKG-INFO +18 -1
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/README.md +17 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/htmlproofer/plugin.py +24 -14
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0/mkdocs_htmlproofer_plugin.egg-info}/PKG-INFO +18 -1
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/setup.py +1 -1
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/LICENSE.md +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/htmlproofer/__init__.py +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/mkdocs_htmlproofer_plugin.egg-info/SOURCES.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/mkdocs_htmlproofer_plugin.egg-info/dependency_links.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/mkdocs_htmlproofer_plugin.egg-info/entry_points.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/mkdocs_htmlproofer_plugin.egg-info/requires.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/mkdocs_htmlproofer_plugin.egg-info/top_level.txt +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.0}/pyproject.toml +0 -0
- {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.3.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.3.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
|
|
@@ -27,6 +27,8 @@ License-File: LICENSE.md
|
|
|
27
27
|
|
|
28
28
|
*A [MkDocs](https://www.mkdocs.org/) plugin that validates URLs, including anchors, in rendered html files*.
|
|
29
29
|
|
|
30
|
+
> Note: [MkDocs 1.6+ supports native validation of anchors](https://www.mkdocs.org/user-guide/configuration/#validation).
|
|
31
|
+
|
|
30
32
|
## Installation
|
|
31
33
|
|
|
32
34
|
0. Prerequisites
|
|
@@ -140,6 +142,21 @@ plugins:
|
|
|
140
142
|
warn_on_ignored_urls: true
|
|
141
143
|
```
|
|
142
144
|
|
|
145
|
+
### `ignore_pages`
|
|
146
|
+
|
|
147
|
+
Avoid validating the URLs on the given list of markdown pages by ignoring them altogether.
|
|
148
|
+
Each page in the list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
plugins:
|
|
152
|
+
- search
|
|
153
|
+
- htmlproofer:
|
|
154
|
+
raise_error: True
|
|
155
|
+
ignore_pages:
|
|
156
|
+
- path/to/file
|
|
157
|
+
- path/to/folder/*
|
|
158
|
+
```
|
|
159
|
+
|
|
143
160
|
### `validate_external_urls`
|
|
144
161
|
|
|
145
162
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
*A [MkDocs](https://www.mkdocs.org/) plugin that validates URLs, including anchors, in rendered html files*.
|
|
6
6
|
|
|
7
|
+
> Note: [MkDocs 1.6+ supports native validation of anchors](https://www.mkdocs.org/user-guide/configuration/#validation).
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
0. Prerequisites
|
|
@@ -117,6 +119,21 @@ plugins:
|
|
|
117
119
|
warn_on_ignored_urls: true
|
|
118
120
|
```
|
|
119
121
|
|
|
122
|
+
### `ignore_pages`
|
|
123
|
+
|
|
124
|
+
Avoid validating the URLs on the given list of markdown pages by ignoring them altogether.
|
|
125
|
+
Each page in the list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
plugins:
|
|
129
|
+
- search
|
|
130
|
+
- htmlproofer:
|
|
131
|
+
raise_error: True
|
|
132
|
+
ignore_pages:
|
|
133
|
+
- path/to/file
|
|
134
|
+
- path/to/folder/*
|
|
135
|
+
```
|
|
136
|
+
|
|
120
137
|
### `validate_external_urls`
|
|
121
138
|
|
|
122
139
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -70,6 +70,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
70
70
|
('validate_rendered_template', config_options.Type(bool, default=False)),
|
|
71
71
|
('ignore_urls', config_options.Type(list, default=[])),
|
|
72
72
|
('warn_on_ignored_urls', config_options.Type(bool, default=False)),
|
|
73
|
+
('ignore_pages', config_options.Type(list, default=[])),
|
|
73
74
|
)
|
|
74
75
|
|
|
75
76
|
def __init__(self):
|
|
@@ -116,12 +117,19 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
116
117
|
|
|
117
118
|
all_element_ids = set(tag['id'] for tag in soup.select('[id]'))
|
|
118
119
|
all_element_ids.add('') # Empty anchor is commonly used, but not real
|
|
119
|
-
for a in soup.find_all('a', href=True):
|
|
120
|
-
url = a['href']
|
|
121
120
|
|
|
121
|
+
urls = set(a['href'] for a in soup.find_all('a', href=True)) | set(img['src'] for img in soup.find_all('img'))
|
|
122
|
+
|
|
123
|
+
for url in urls:
|
|
122
124
|
if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
|
|
123
125
|
if self.config['warn_on_ignored_urls']:
|
|
124
126
|
log_warning(f"ignoring URL {url} from {page.file.src_path}")
|
|
127
|
+
elif any(
|
|
128
|
+
fnmatch.fnmatch(page.file.src_path, ignore_page)
|
|
129
|
+
for ignore_page in self.config['ignore_pages']
|
|
130
|
+
):
|
|
131
|
+
if self.config['warn_on_ignored_urls']:
|
|
132
|
+
log_warning(f"ignoring URL {url} from {page.file.src_path}")
|
|
125
133
|
else:
|
|
126
134
|
url_status = self.get_url_status(url, page.file.src_path, all_element_ids, opt_files)
|
|
127
135
|
if self.bad_url(url_status) and self.is_error(self.config, url, url_status):
|
|
@@ -151,7 +159,7 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
151
159
|
|
|
152
160
|
if self.config['skip_downloads'] is False:
|
|
153
161
|
# Download the entire contents as to not break previous behaviour.
|
|
154
|
-
for _ in response.iter_content(chunk_size=1024):
|
|
162
|
+
for _ in response.iter_content(chunk_size=1024 * 1024):
|
|
155
163
|
pass
|
|
156
164
|
|
|
157
165
|
return response.status_code
|
|
@@ -194,18 +202,20 @@ class HtmlProoferPlugin(BasePlugin):
|
|
|
194
202
|
return True
|
|
195
203
|
|
|
196
204
|
url_target, _, optional_anchor = match.groups()
|
|
197
|
-
|
|
198
|
-
if
|
|
199
|
-
# URL is a link to another local Markdown file that may include an anchor.
|
|
200
|
-
target_markdown = HtmlProoferPlugin.find_target_markdown(url_target, src_path, files)
|
|
201
|
-
if target_markdown is None:
|
|
202
|
-
# The corresponding Markdown page was not found.
|
|
203
|
-
return False
|
|
204
|
-
if optional_anchor and not HtmlProoferPlugin.contains_anchor(target_markdown, optional_anchor):
|
|
205
|
-
# The corresponding Markdown header for this anchor was not found.
|
|
206
|
-
return False
|
|
207
|
-
elif HtmlProoferPlugin.find_source_file(url_target, src_path, files) is None:
|
|
205
|
+
source_file = HtmlProoferPlugin.find_source_file(url_target, src_path, files)
|
|
206
|
+
if source_file is None:
|
|
208
207
|
return False
|
|
208
|
+
|
|
209
|
+
# If there's an anchor (fragment) on the link, we try to find it in the source_file
|
|
210
|
+
if optional_anchor:
|
|
211
|
+
_, extension = os.path.splitext(source_file.src_uri)
|
|
212
|
+
# Currently only Markdown-based pages are supported, but conceptually others could be added below
|
|
213
|
+
if extension == ".md":
|
|
214
|
+
if source_file.page is None or source_file.page.markdown is None:
|
|
215
|
+
return False
|
|
216
|
+
if not HtmlProoferPlugin.contains_anchor(source_file.page.markdown, optional_anchor):
|
|
217
|
+
return False
|
|
218
|
+
|
|
209
219
|
return True
|
|
210
220
|
|
|
211
221
|
@staticmethod
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mkdocs-htmlproofer-plugin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.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
|
|
@@ -27,6 +27,8 @@ License-File: LICENSE.md
|
|
|
27
27
|
|
|
28
28
|
*A [MkDocs](https://www.mkdocs.org/) plugin that validates URLs, including anchors, in rendered html files*.
|
|
29
29
|
|
|
30
|
+
> Note: [MkDocs 1.6+ supports native validation of anchors](https://www.mkdocs.org/user-guide/configuration/#validation).
|
|
31
|
+
|
|
30
32
|
## Installation
|
|
31
33
|
|
|
32
34
|
0. Prerequisites
|
|
@@ -140,6 +142,21 @@ plugins:
|
|
|
140
142
|
warn_on_ignored_urls: true
|
|
141
143
|
```
|
|
142
144
|
|
|
145
|
+
### `ignore_pages`
|
|
146
|
+
|
|
147
|
+
Avoid validating the URLs on the given list of markdown pages by ignoring them altogether.
|
|
148
|
+
Each page in the list supports unix style wildcards `*`, `[]`, `?`, etc.
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
plugins:
|
|
152
|
+
- search
|
|
153
|
+
- htmlproofer:
|
|
154
|
+
raise_error: True
|
|
155
|
+
ignore_pages:
|
|
156
|
+
- path/to/file
|
|
157
|
+
- path/to/folder/*
|
|
158
|
+
```
|
|
159
|
+
|
|
143
160
|
### `validate_external_urls`
|
|
144
161
|
|
|
145
162
|
Avoids validating any external URLs (i.e those starting with http:// or https://).
|
|
@@ -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.3.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
|