Skip to content

Commit 00f9e29

Browse files
authored
Add support for ignoring every URL on a page (#88)
1 parent 7b1285f commit 00f9e29

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ plugins:
119119
warn_on_ignored_urls: true
120120
```
121121

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+
122137
### `validate_external_urls`
123138

124139
Avoids validating any external URLs (i.e those starting with http:// or https://).

htmlproofer/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class HtmlProoferPlugin(BasePlugin):
7070
('validate_rendered_template', config_options.Type(bool, default=False)),
7171
('ignore_urls', config_options.Type(list, default=[])),
7272
('warn_on_ignored_urls', config_options.Type(bool, default=False)),
73+
('ignore_pages', config_options.Type(list, default=[])),
7374
)
7475

7576
def __init__(self):
@@ -123,6 +124,12 @@ def on_post_page(self, output_content: str, page: Page, config: Config) -> None:
123124
if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
124125
if self.config['warn_on_ignored_urls']:
125126
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}")
126133
else:
127134
url_status = self.get_url_status(url, page.file.src_path, all_element_ids, opt_files)
128135
if self.bad_url(url_status) and self.is_error(self.config, url, url_status):

0 commit comments

Comments
 (0)