mkdocs-htmlproofer-plugin 1.2.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.
Files changed (14) hide show
  1. {mkdocs-htmlproofer-plugin-1.2.0/mkdocs_htmlproofer_plugin.egg-info → mkdocs-htmlproofer-plugin-1.2.1}/PKG-INFO +1 -1
  2. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/htmlproofer/plugin.py +16 -13
  3. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1/mkdocs_htmlproofer_plugin.egg-info}/PKG-INFO +1 -1
  4. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/setup.py +1 -1
  5. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/LICENSE.md +0 -0
  6. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/README.md +0 -0
  7. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/htmlproofer/__init__.py +0 -0
  8. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/SOURCES.txt +0 -0
  9. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/dependency_links.txt +0 -0
  10. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/entry_points.txt +0 -0
  11. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/requires.txt +0 -0
  12. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/mkdocs_htmlproofer_plugin.egg-info/top_level.txt +0 -0
  13. {mkdocs-htmlproofer-plugin-1.2.0 → mkdocs-htmlproofer-plugin-1.2.1}/pyproject.toml +0 -0
  14. {mkdocs-htmlproofer-plugin-1.2.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.2.0
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
@@ -116,9 +116,10 @@ class HtmlProoferPlugin(BasePlugin):
116
116
 
117
117
  all_element_ids = set(tag['id'] for tag in soup.select('[id]'))
118
118
  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
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:
122
123
  if any(fnmatch.fnmatch(url, ignore_url) for ignore_url in self.config['ignore_urls']):
123
124
  if self.config['warn_on_ignored_urls']:
124
125
  log_warning(f"ignoring URL {url} from {page.file.src_path}")
@@ -194,18 +195,20 @@ class HtmlProoferPlugin(BasePlugin):
194
195
  return True
195
196
 
196
197
  url_target, _, optional_anchor = match.groups()
197
- _, extension = os.path.splitext(url_target)
198
- if extension == ".html":
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:
198
+ source_file = HtmlProoferPlugin.find_source_file(url_target, src_path, files)
199
+ if source_file is None:
208
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
+
209
212
  return True
210
213
 
211
214
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mkdocs-htmlproofer-plugin
3
- Version: 1.2.0
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
@@ -9,7 +9,7 @@ def read(fname: str):
9
9
 
10
10
  setup(
11
11
  name='mkdocs-htmlproofer-plugin',
12
- version='1.2.0',
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',