mkdocs-include-markdown-plugin 7.1.2__tar.gz → 7.1.3__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_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/LICENSE +1 -1
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/PKG-INFO +4 -3
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/pyproject.toml +4 -4
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/cache.py +2 -2
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/directive.py +1 -2
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/event.py +14 -17
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/process.py +55 -1
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/.gitignore +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/README.md +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/config.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/logger.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
|
@@ -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-
|
|
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,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version: 7.1.
|
|
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
|
{mkdocs_include_markdown_plugin-7.1.2 → mkdocs_include_markdown_plugin-7.1.3}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mkdocs-include-markdown-plugin"
|
|
3
|
-
version = "7.1.
|
|
3
|
+
version = "7.1.3"
|
|
4
4
|
description = "Mkdocs Markdown includer plugin."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
@@ -104,9 +104,9 @@ targets = [{ file = "pyproject.toml" }]
|
|
|
104
104
|
[tool.project-config]
|
|
105
105
|
cache = "2 days"
|
|
106
106
|
style = [
|
|
107
|
-
"gh://mondeja/project-config-styles@v5.
|
|
108
|
-
"gh://mondeja/project-config-styles@v5.
|
|
109
|
-
"gh://mondeja/project-config-styles@v5.
|
|
107
|
+
"gh://mondeja/project-config-styles@v5.5/base/pre-commit/md2po2md.json5",
|
|
108
|
+
"gh://mondeja/project-config-styles@v5.5/python/base.json5",
|
|
109
|
+
"gh://mondeja/project-config-styles@v5.5/python/mypy.json5",
|
|
110
110
|
]
|
|
111
111
|
|
|
112
112
|
[tool.coverage.run]
|
|
@@ -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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|