diff --git a/README.md b/README.md index 2f4df55..758515f 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,21 @@ plugins: warn_on_ignored_urls: true ``` +### `ignore_pages` + +Avoid validating the URLs on the given list of markdown pages by ignoring them altogether. +Each page in the list supports unix style wildcards `*`, `[]`, `?`, etc. + +```yaml +plugins: + - search + - htmlproofer: + raise_error: True + ignore_pages: + - path/to/file + - path/to/folder/* +``` + ### `validate_external_urls` Avoids validating any external URLs (i.e those starting with http:// or https://). diff --git a/htmlproofer/plugin.py b/htmlproofer/plugin.py index b308391..698d42b 100644 --- a/htmlproofer/plugin.py +++ b/htmlproofer/plugin.py @@ -70,6 +70,7 @@ class HtmlProoferPlugin(BasePlugin): ('validate_rendered_template', config_options.Type(bool, default=False)), ('ignore_urls', config_options.Type(list, default=[])), ('warn_on_ignored_urls', config_options.Type(bool, default=False)), + ('ignore_pages', config_options.Type(list, default=[])), ) def __init__(self): @@ -123,6 +124,12 @@ def on_post_page(self, output_content: str, page: Page, config: Config) -> None: if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']): if self.config['warn_on_ignored_urls']: log_warning(f"ignoring URL {url} from {page.file.src_path}") + elif any( + fnmatch.fnmatch(page.file.src_path, ignore_page) + for ignore_page in self.config['ignore_pages'] + ): + if self.config['warn_on_ignored_urls']: + log_warning(f"ignoring URL {url} from {page.file.src_path}") else: url_status = self.get_url_status(url, page.file.src_path, all_element_ids, opt_files) if self.bad_url(url_status) and self.is_error(self.config, url, url_status):