mkdocs-include-markdown-plugin 7.1.2__py3-none-any.whl → 7.1.3__py3-none-any.whl

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.
@@ -43,7 +43,7 @@ class Cache:
43
43
  is_file = stat.S_ISREG(os.stat(fpath).st_mode)
44
44
  except (FileNotFoundError, OSError): # pragma: no cover
45
45
  return None
46
- if is_file:
46
+ if is_file: # pragma: no branch
47
47
  creation_time = self.get_creation_time_from_fpath(fpath)
48
48
  if time.time() < creation_time + self.expiration_seconds:
49
49
  return self.read_file(fpath, encoding=encoding)
@@ -79,7 +79,7 @@ def get_cache_directory(cache_dir: str) -> str | None:
79
79
 
80
80
  try:
81
81
  from platformdirs import user_data_dir
82
- except ImportError:
82
+ except ImportError: # pragma: no cover
83
83
  return None
84
84
  else:
85
85
  return user_data_dir('mkdocs-include-markdown-plugin')
@@ -306,7 +306,6 @@ def resolve_file_paths_to_exclude(
306
306
  docs_dir: str,
307
307
  ) -> list[str]:
308
308
  """Resolve the file paths to exclude for a directive."""
309
- root_dir = None
310
309
  if process.is_absolute_path(exclude_string):
311
310
  return glob.glob(exclude_string, flags=GLOB_FLAGS)
312
311
 
@@ -330,7 +329,7 @@ def resolve_file_paths_to_exclude(
330
329
  )
331
330
  ]
332
331
 
333
- return glob.glob(
332
+ return glob.glob( # pragma: no cover
334
333
  exclude_string,
335
334
  flags=GLOB_FLAGS,
336
335
  root_dir=docs_dir,
@@ -83,21 +83,20 @@ def get_file_content( # noqa: PLR0913, PLR0915
83
83
  http_cache: Cache | None = None,
84
84
  ) -> str:
85
85
  """Return the content of the file to include."""
86
- settings_ignore_paths = []
87
- if settings.exclude is not None:
88
- for path in glob.glob(
89
- [
90
- os.path.join(docs_dir, fp)
91
- if not os.path.isabs(fp)
92
- else fp for fp in settings.exclude
93
- ],
94
- flags=GLOB_FLAGS,
95
- root_dir=docs_dir,
96
- ):
97
- if path not in settings_ignore_paths:
98
- settings_ignore_paths.append(path)
86
+ if settings.exclude:
87
+ settings_ignore_paths = list(glob.glob(
88
+ [
89
+ os.path.join(docs_dir, fp)
90
+ if not os.path.isabs(fp)
91
+ else fp for fp in settings.exclude
92
+ ],
93
+ flags=GLOB_FLAGS,
94
+ root_dir=docs_dir,
95
+ ))
99
96
  if page_src_path in settings_ignore_paths:
100
97
  return markdown
98
+ else:
99
+ settings_ignore_paths = []
101
100
 
102
101
  new_found_include_contents: list[tuple[str, str]] = []
103
102
  new_found_include_markdown_contents: list[tuple[str, str]] = []
@@ -150,8 +149,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
150
149
  for path in resolve_file_paths_to_exclude(
151
150
  exclude_string, page_src_path, docs_dir,
152
151
  ):
153
- if path not in ignore_paths:
154
- ignore_paths.append(path)
152
+ ignore_paths.append(path)
155
153
 
156
154
  file_paths_to_include, is_url = resolve_file_paths_to_include(
157
155
  filename,
@@ -361,8 +359,7 @@ def get_file_content( # noqa: PLR0913, PLR0915
361
359
  for path in resolve_file_paths_to_exclude(
362
360
  exclude_string, page_src_path, docs_dir,
363
361
  ):
364
- if path not in ignore_paths:
365
- ignore_paths.append(path)
362
+ ignore_paths.append(path)
366
363
 
367
364
  file_paths_to_include, is_url = resolve_file_paths_to_include(
368
365
  filename,
@@ -112,6 +112,49 @@ MARKDOWN_LINK_DEFINITION_REGEX = re.compile(
112
112
  flags=re.VERBOSE | re.MULTILINE,
113
113
  )
114
114
 
115
+ # Matched html image and source definition.
116
+ # e.g. <img src="path/to/image.png" alt="alt-text">
117
+ # e.g. <source src="path/to/image.png" alt="alt-text">
118
+ MARKDOWN_HTML_IMAGE_REGEX = re.compile(
119
+ r'''
120
+ <(?:img|source) # img or source
121
+ (?:\s+ # More than one whitespace
122
+ (?!src=) # Not src=
123
+ [\w-]+ # attribute name
124
+ (?:\s*=\s*)? # arbitrary whitespace (optional)
125
+ (?:
126
+ "[^"]*" # Quoted value (double quote)
127
+ |
128
+ '[^']*' # Quoted value (single quote)
129
+ )?
130
+ )* # Other attributes are repeated 0 or more times
131
+ \s+ # More than one whitespace
132
+ src=["'](\S+?)["'] # src = $1 (double quote or single quote)
133
+ ''',
134
+ flags=re.VERBOSE | re.MULTILINE,
135
+ )
136
+
137
+ # Matched html anchor definition.
138
+ # e.g. <a href="https://example.com">example</a>
139
+ MARKDOWN_HTML_ANCHOR_DEFINITION_REGEX = re.compile(
140
+ r'''
141
+ <a
142
+ (?:\s+ # More than one whitespace
143
+ (?!href=) # Not href=
144
+ [\w-]+ # attribute name
145
+ (?:\s*=\s*)? # arbitrary whitespace (optional)
146
+ (?:
147
+ "[^"]*" # Quoted value (double quote)
148
+ |
149
+ '[^']*' # Quoted value (single quote)
150
+ )?
151
+ )* # Other attributes are repeated 0 or more times
152
+ \s+ # More than one whitespace
153
+ href=["'](\S+?)["']# href = $1 (double quote or single quote)
154
+ ''',
155
+ flags=re.VERBOSE | re.MULTILINE,
156
+ )
157
+
115
158
 
116
159
  def transform_p_by_p_skipping_codeblocks( # noqa: PLR0912, PLR0915
117
160
  markdown: str,
@@ -247,6 +290,9 @@ def rewrite_relative_urls(
247
290
  from urllib.parse import urlparse, urlunparse
248
291
 
249
292
  def rewrite_url(url: str) -> str:
293
+ if is_url(url):
294
+ return url
295
+
250
296
  scheme, netloc, path, params, query, fragment = urlparse(url)
251
297
 
252
298
  # absolute or mail
@@ -296,10 +342,18 @@ def rewrite_relative_urls(
296
342
  found_href_url_group_index_3,
297
343
  paragraph,
298
344
  )
299
- return MARKDOWN_LINK_DEFINITION_REGEX.sub(
345
+ paragraph = MARKDOWN_LINK_DEFINITION_REGEX.sub(
300
346
  functools.partial(found_href, url_group_index=2),
301
347
  paragraph,
302
348
  )
349
+ paragraph = MARKDOWN_HTML_IMAGE_REGEX.sub(
350
+ functools.partial(found_href, url_group_index=1),
351
+ paragraph,
352
+ )
353
+ return MARKDOWN_HTML_ANCHOR_DEFINITION_REGEX.sub(
354
+ functools.partial(found_href, url_group_index=1),
355
+ paragraph,
356
+ )
303
357
 
304
358
  return transform_p_by_p_skipping_codeblocks(
305
359
  markdown,
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: mkdocs-include-markdown-plugin
3
- Version: 7.1.2
3
+ Version: 7.1.3
4
4
  Summary: Mkdocs Markdown includer plugin.
5
5
  Project-URL: Source, https://github.com/mondeja/mkdocs-include-markdown-plugin
6
6
  Project-URL: Documentation, https://github.com/mondeja/mkdocs-include-markdown-plugin#documentation
@@ -9,7 +9,8 @@ Project-URL: Changelog, https://github.com/mondeja/mkdocs-include-markdown-plugi
9
9
  Author: Joe Rickerby
10
10
  Author-email: Álvaro Mondéjar Rubio <mondejar1994@gmail.com>
11
11
  Maintainer-email: Álvaro Mondéjar Rubio <mondejar1994@gmail.com>
12
- License: Apache-2.0
12
+ License-Expression: Apache-2.0
13
+ License-File: LICENSE
13
14
  Keywords: includer,markdown,mkdocs,plugin
14
15
  Classifier: Development Status :: 5 - Production/Stable
15
16
  Classifier: Environment :: Console
@@ -0,0 +1,15 @@
1
+ mkdocs_include_markdown_plugin/__init__.py,sha256=ByOde15RQSHlZTmkepPSzIt0GzUIv_-GKORFDnxnOmc,193
2
+ mkdocs_include_markdown_plugin/cache.py,sha256=t0vwBNrUURzUegoHA3eWBhbU8J4Dh9VTcDKF1fbYMYE,3819
3
+ mkdocs_include_markdown_plugin/config.py,sha256=VX95U8-9gFzPUIBSTA8TSL4xOD49qTMSs8dhFiilGns,1091
4
+ mkdocs_include_markdown_plugin/directive.py,sha256=8W7-73GdZSX-NIACRSGX55h3FD5EbfHRnXTxaMebgvE,10455
5
+ mkdocs_include_markdown_plugin/event.py,sha256=LakZDvyyZ4gSZyuUpqT11aiMmRiDVjECH_RnODvlifA,24299
6
+ mkdocs_include_markdown_plugin/files_watcher.py,sha256=hu-63u8syl00mXP59vP_iqD7T1R9iU9JjiZOHDV5fas,298
7
+ mkdocs_include_markdown_plugin/logger.py,sha256=nl63G4IJSt5mEYHbObuh7BmmowSv-aa1l_v9I257570,230
8
+ mkdocs_include_markdown_plugin/plugin.py,sha256=0muHIhmklC7v-QKWsAcAtZKhhZQ2olH6b28b3_3e4gI,3850
9
+ mkdocs_include_markdown_plugin/process.py,sha256=SfNPW58737fz8dsUwD5CM-cevI4gC3AuUk3whJIYihQ,19745
10
+ mkdocs_include_markdown_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ mkdocs_include_markdown_plugin-7.1.3.dist-info/METADATA,sha256=J-2SGDeVHNcQjuVdMIyRdt4wPIrVNOvoN0af_NHclmc,12770
12
+ mkdocs_include_markdown_plugin-7.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
13
+ mkdocs_include_markdown_plugin-7.1.3.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
14
+ mkdocs_include_markdown_plugin-7.1.3.dist-info/licenses/LICENSE,sha256=qm1MNzU_lIANFB-1cBpD9hqdD_Htv3_Xr6hobt0IHq8,11365
15
+ mkdocs_include_markdown_plugin-7.1.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2017-2024 Joe Rickerby and contributors
190
+ Copyright 2017-2025 Joe Rickerby and contributors
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
@@ -1,15 +0,0 @@
1
- mkdocs_include_markdown_plugin/__init__.py,sha256=ByOde15RQSHlZTmkepPSzIt0GzUIv_-GKORFDnxnOmc,193
2
- mkdocs_include_markdown_plugin/cache.py,sha256=j4GWPEMOj8jVQrJRXryT-r3TNzWb3mFLE6FCROe_1MQ,3778
3
- mkdocs_include_markdown_plugin/config.py,sha256=VX95U8-9gFzPUIBSTA8TSL4xOD49qTMSs8dhFiilGns,1091
4
- mkdocs_include_markdown_plugin/directive.py,sha256=1OEA1XZKlYRvScOAP0gmaSROLmbWXTPbTJgPELk71yg,10455
5
- mkdocs_include_markdown_plugin/event.py,sha256=nT55KnM2gmzVKmlDS8SEBUDbOJ8TDXRNx0k_qhB5w4w,24507
6
- mkdocs_include_markdown_plugin/files_watcher.py,sha256=hu-63u8syl00mXP59vP_iqD7T1R9iU9JjiZOHDV5fas,298
7
- mkdocs_include_markdown_plugin/logger.py,sha256=nl63G4IJSt5mEYHbObuh7BmmowSv-aa1l_v9I257570,230
8
- mkdocs_include_markdown_plugin/plugin.py,sha256=0muHIhmklC7v-QKWsAcAtZKhhZQ2olH6b28b3_3e4gI,3850
9
- mkdocs_include_markdown_plugin/process.py,sha256=6mVGPDSMtnuUE5IF05GUwef0PYPUhI9G2FIX5nFHqcU,17779
10
- mkdocs_include_markdown_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- mkdocs_include_markdown_plugin-7.1.2.dist-info/METADATA,sha256=Y0FPqVd0VcmyctgO8jJK89QQxlBvGDg09oqwZPr_U30,12737
12
- mkdocs_include_markdown_plugin-7.1.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
13
- mkdocs_include_markdown_plugin-7.1.2.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
14
- mkdocs_include_markdown_plugin-7.1.2.dist-info/licenses/LICENSE,sha256=OunyKlPxiuvLB3ENbo2nyV-OPndkwzyZ5Gzwei0ofbc,11365
15
- mkdocs_include_markdown_plugin-7.1.2.dist-info/RECORD,,