mkdocs-include-markdown-plugin 6.2.0__py3-none-any.whl → 6.2.1__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.
- mkdocs_include_markdown_plugin/cache.py +6 -6
- mkdocs_include_markdown_plugin/directive.py +2 -2
- mkdocs_include_markdown_plugin/event.py +10 -4
- mkdocs_include_markdown_plugin/process.py +8 -4
- {mkdocs_include_markdown_plugin-6.2.0.dist-info → mkdocs_include_markdown_plugin-6.2.1.dist-info}/METADATA +8 -5
- mkdocs_include_markdown_plugin-6.2.1.dist-info/RECORD +15 -0
- mkdocs_include_markdown_plugin-6.2.0.dist-info/RECORD +0 -15
- {mkdocs_include_markdown_plugin-6.2.0.dist-info → mkdocs_include_markdown_plugin-6.2.1.dist-info}/WHEEL +0 -0
- {mkdocs_include_markdown_plugin-6.2.0.dist-info → mkdocs_include_markdown_plugin-6.2.1.dist-info}/entry_points.txt +0 -0
- {mkdocs_include_markdown_plugin-6.2.0.dist-info → mkdocs_include_markdown_plugin-6.2.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -39,24 +39,24 @@ class Cache:
|
|
|
39
39
|
hashlib.sha3_512(url.encode()).digest(),
|
|
40
40
|
).decode('utf-8')
|
|
41
41
|
|
|
42
|
-
def read_file(self, fpath: str) -> str: # noqa: D102
|
|
43
|
-
with open(fpath, encoding=
|
|
42
|
+
def read_file(self, fpath: str, encoding: str = 'utf-8') -> str: # noqa: D102
|
|
43
|
+
with open(fpath, encoding=encoding) as f:
|
|
44
44
|
return f.read().split('\n', 1)[1]
|
|
45
45
|
|
|
46
|
-
def get_(self, url: str) -> str | None: # noqa: D102
|
|
46
|
+
def get_(self, url: str, encoding: str = 'utf-8') -> str | None: # noqa: D102
|
|
47
47
|
key = self.generate_unique_key_from_url(url)
|
|
48
48
|
fpath = os.path.join(self.cache_dir, key)
|
|
49
49
|
if os.path.isfile(fpath):
|
|
50
50
|
creation_time = self.get_creation_time_from_fpath(fpath)
|
|
51
51
|
if time.time() < creation_time + self.expiration_seconds:
|
|
52
|
-
return self.read_file(fpath)
|
|
52
|
+
return self.read_file(fpath, encoding=encoding)
|
|
53
53
|
os.remove(fpath)
|
|
54
54
|
return None
|
|
55
55
|
|
|
56
|
-
def set_(self, url: str, value: str) -> None: # noqa: D102
|
|
56
|
+
def set_(self, url: str, value: str, encoding: str = 'utf-8') -> None: # noqa: D102
|
|
57
57
|
key = self.generate_unique_key_from_url(url)
|
|
58
58
|
fpath = os.path.join(self.cache_dir, key)
|
|
59
|
-
with open(fpath, 'w', encoding=
|
|
59
|
+
with open(fpath, 'w', encoding=encoding) as f:
|
|
60
60
|
f.write(f'{int(time.time())}\n')
|
|
61
61
|
f.write(value)
|
|
62
62
|
|
|
@@ -52,7 +52,7 @@ SINGLE_QUOTED_STR_RE = r"([^']|(?<=\\)')+"
|
|
|
52
52
|
# and "$CLOSING_TAG" will be replaced by the effective opening and
|
|
53
53
|
# closing tags in the `on_config` plugin event.
|
|
54
54
|
INCLUDE_TAG_RE = rf'''
|
|
55
|
-
(?P<_includer_indent>[ \t\
|
|
55
|
+
(?P<_includer_indent>[ \t\w\\.]*?)$OPENING_TAG
|
|
56
56
|
\s*
|
|
57
57
|
include
|
|
58
58
|
\s+
|
|
@@ -171,7 +171,7 @@ def create_include_tag(
|
|
|
171
171
|
"""Create a regex pattern to match an inclusion tag directive.
|
|
172
172
|
|
|
173
173
|
Replaces the substrings '$OPENING_TAG' and '$CLOSING_TAG' from
|
|
174
|
-
|
|
174
|
+
INCLUDE_TAG_RE by the effective tag.
|
|
175
175
|
"""
|
|
176
176
|
return re.compile(
|
|
177
177
|
INCLUDE_TAG_RE.replace(' include', f' {tag}').replace(
|
|
@@ -230,7 +230,9 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
230
230
|
expected_but_any_found = [start is not None, end is not None]
|
|
231
231
|
for file_path in file_paths_to_include:
|
|
232
232
|
if process.is_url(filename):
|
|
233
|
-
new_text_to_include = process.read_url(
|
|
233
|
+
new_text_to_include = process.read_url(
|
|
234
|
+
file_path, http_cache, encoding,
|
|
235
|
+
)
|
|
234
236
|
else:
|
|
235
237
|
new_text_to_include = process.read_file(file_path, encoding)
|
|
236
238
|
|
|
@@ -481,7 +483,9 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
481
483
|
text_to_include = ''
|
|
482
484
|
for file_path in file_paths_to_include:
|
|
483
485
|
if process.is_url(filename):
|
|
484
|
-
new_text_to_include = process.read_url(
|
|
486
|
+
new_text_to_include = process.read_url(
|
|
487
|
+
file_path, http_cache, encoding,
|
|
488
|
+
)
|
|
485
489
|
else:
|
|
486
490
|
new_text_to_include = process.read_file(file_path, encoding)
|
|
487
491
|
|
|
@@ -587,9 +591,11 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
587
591
|
nonlocal new_found_include_markdown_contents
|
|
588
592
|
markdown_include_index = len(new_found_include_markdown_contents)
|
|
589
593
|
placeholder = build_placeholder(
|
|
590
|
-
markdown_include_index, 'include-markdown'
|
|
594
|
+
markdown_include_index, 'include-markdown',
|
|
595
|
+
)
|
|
591
596
|
new_found_include_markdown_contents.append(
|
|
592
|
-
(placeholder, text_to_include)
|
|
597
|
+
(placeholder, text_to_include),
|
|
598
|
+
)
|
|
593
599
|
return placeholder
|
|
594
600
|
|
|
595
601
|
# Replace contents by placeholders
|
|
@@ -443,16 +443,20 @@ def read_file(file_path: str, encoding: str) -> str:
|
|
|
443
443
|
return f.read()
|
|
444
444
|
|
|
445
445
|
|
|
446
|
-
def read_url(
|
|
446
|
+
def read_url(
|
|
447
|
+
url: str,
|
|
448
|
+
http_cache: Cache | None,
|
|
449
|
+
encoding: str = 'utf-8',
|
|
450
|
+
) -> Any:
|
|
447
451
|
"""Read an HTTP location and return its content."""
|
|
448
452
|
if http_cache is not None:
|
|
449
|
-
cached_content = http_cache.get_(url)
|
|
453
|
+
cached_content = http_cache.get_(url, encoding)
|
|
450
454
|
if cached_content is not None:
|
|
451
455
|
return cached_content
|
|
452
456
|
with urlopen(Request(url)) as response:
|
|
453
|
-
content = response.read().decode(
|
|
457
|
+
content = response.read().decode(encoding)
|
|
454
458
|
if http_cache is not None:
|
|
455
|
-
http_cache.set_(url, content)
|
|
459
|
+
http_cache.set_(url, content, encoding)
|
|
456
460
|
return content
|
|
457
461
|
|
|
458
462
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version: 6.2.
|
|
3
|
+
Version: 6.2.1
|
|
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
|
|
@@ -43,6 +43,7 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
[![License][license-image]][license-link]
|
|
44
44
|
[![Tests][tests-image]][tests-link]
|
|
45
45
|
[![Coverage status][coverage-image]][coverage-link]
|
|
46
|
+
[![Downloads][downloads-image]][downloads-link]
|
|
46
47
|
|
|
47
48
|
<!-- mdpo-enable -->
|
|
48
49
|
|
|
@@ -194,8 +195,8 @@ content to include.
|
|
|
194
195
|
**recursive** (_true_): When this option is disabled, included files are not
|
|
195
196
|
processed for recursive includes. Possible values are `true` and `false`.
|
|
196
197
|
- <a name="include-markdown_encoding" href="#include-markdown_encoding">#</a>
|
|
197
|
-
**encoding** (
|
|
198
|
-
If not defined `utf-8` will be used.
|
|
198
|
+
**encoding** (_'utf-8'_): Specify the encoding of the included file.
|
|
199
|
+
If not defined `'utf-8'` will be used.
|
|
199
200
|
- <a name="include-markdown_rewrite-relative-urls" href="#include-markdown_rewrite-relative-urls">#</a>
|
|
200
201
|
**rewrite-relative-urls** (_true_): When this option is enabled (default),
|
|
201
202
|
Markdown links and images in the content that are specified by a relative URL
|
|
@@ -285,8 +286,8 @@ Includes the content of a file or a group of files.
|
|
|
285
286
|
**recursive** (_true_): When this option is disabled, included files are not
|
|
286
287
|
processed for recursive includes. Possible values are `true` and `false`.
|
|
287
288
|
- <a name="include_encoding" href="#include_encoding">#</a>
|
|
288
|
-
**encoding** (
|
|
289
|
-
If not defined `utf-8` will be used.
|
|
289
|
+
**encoding** (_'utf-8'_): Specify the encoding of the included file.
|
|
290
|
+
If not defined `'utf-8'` will be used.
|
|
290
291
|
|
|
291
292
|
##### Examples
|
|
292
293
|
|
|
@@ -330,6 +331,8 @@ Includes the content of a file or a group of files.
|
|
|
330
331
|
[coverage-link]: https://app.codecov.io/gh/mondeja/mkdocs-include-markdown-plugin
|
|
331
332
|
[license-image]: https://img.shields.io/pypi/l/mkdocs-include-markdown-plugin?color=light-green&logo=apache&logoColor=white
|
|
332
333
|
[license-link]: https://github.com/mondeja/mkdocs-include-markdown-plugin/blob/master/LICENSE
|
|
334
|
+
[downloads-image]: https://img.shields.io/pypi/dm/mkdocs-include-markdown-plugin
|
|
335
|
+
[downloads-link]: https://pepy.tech/project/mkdocs-include-markdown-plugin
|
|
333
336
|
[platformdirs]: https://pypi.org/project/platformdirs/
|
|
334
337
|
[cibuildwheel-470]: https://github.com/pypa/cibuildwheel/issues/470
|
|
335
338
|
[cibuildwheel-475]: https://github.com/pypa/cibuildwheel/pull/475
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
mkdocs_include_markdown_plugin/__init__.py,sha256=ByOde15RQSHlZTmkepPSzIt0GzUIv_-GKORFDnxnOmc,193
|
|
2
|
+
mkdocs_include_markdown_plugin/cache.py,sha256=fFm2kU3ONoE2euo0rHC8DOBmV-ubX6BsfHe9hVFeRf4,2880
|
|
3
|
+
mkdocs_include_markdown_plugin/config.py,sha256=CTP5xhdZwPKuee3urDLOjanV93uhHHAL8XZ3L6_2HIE,861
|
|
4
|
+
mkdocs_include_markdown_plugin/directive.py,sha256=K0-lnw5AOwwLv0MShGydhhZQrS_07w-sizcQCuivGSY,9313
|
|
5
|
+
mkdocs_include_markdown_plugin/event.py,sha256=37x21rRdIDsZDkUZjxb-IgxHy1olZ7yxqTxFedPlAFU,24001
|
|
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=PfpU2nrc2jlAtbVg5-c6GiK2GSwkFPEos5zvbGkONOo,3812
|
|
9
|
+
mkdocs_include_markdown_plugin/process.py,sha256=3TT0Zkv-IWAloDuuLpcw-SR62lRQyxzDk_K8heFJl58,15669
|
|
10
|
+
mkdocs_include_markdown_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
mkdocs_include_markdown_plugin-6.2.1.dist-info/METADATA,sha256=cDV5V0sFOKUvmvnJuvzNQTMJz8AO0Gtb2iKtfkwq4L8,12097
|
|
12
|
+
mkdocs_include_markdown_plugin-6.2.1.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
13
|
+
mkdocs_include_markdown_plugin-6.2.1.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
|
|
14
|
+
mkdocs_include_markdown_plugin-6.2.1.dist-info/licenses/LICENSE,sha256=OunyKlPxiuvLB3ENbo2nyV-OPndkwzyZ5Gzwei0ofbc,11365
|
|
15
|
+
mkdocs_include_markdown_plugin-6.2.1.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
mkdocs_include_markdown_plugin/__init__.py,sha256=ByOde15RQSHlZTmkepPSzIt0GzUIv_-GKORFDnxnOmc,193
|
|
2
|
-
mkdocs_include_markdown_plugin/cache.py,sha256=2CAVNwDUHilY1-x1VMLw33hxv76z1wcpid22jTyoJyI,2784
|
|
3
|
-
mkdocs_include_markdown_plugin/config.py,sha256=CTP5xhdZwPKuee3urDLOjanV93uhHHAL8XZ3L6_2HIE,861
|
|
4
|
-
mkdocs_include_markdown_plugin/directive.py,sha256=F2SZufY8jN8uCinT87TE8RtbOsz6gIdj7fZ3h850wXg,9348
|
|
5
|
-
mkdocs_include_markdown_plugin/event.py,sha256=MMYxGBOi6TK3FO0-m_kSynr2YG0tGL2C-rHycZ1gzfY,23883
|
|
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=PfpU2nrc2jlAtbVg5-c6GiK2GSwkFPEos5zvbGkONOo,3812
|
|
9
|
-
mkdocs_include_markdown_plugin/process.py,sha256=t1uJO2dJH5Zw_TtIcGbWDwphEwVdiY65x7Zhx0s3oLc,15596
|
|
10
|
-
mkdocs_include_markdown_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
mkdocs_include_markdown_plugin-6.2.0.dist-info/METADATA,sha256=udwqISg4sK7zi7g3HotFcV84MHK5XPdhEseC9V8UA54,11885
|
|
12
|
-
mkdocs_include_markdown_plugin-6.2.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
|
|
13
|
-
mkdocs_include_markdown_plugin-6.2.0.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
|
|
14
|
-
mkdocs_include_markdown_plugin-6.2.0.dist-info/licenses/LICENSE,sha256=OunyKlPxiuvLB3ENbo2nyV-OPndkwzyZ5Gzwei0ofbc,11365
|
|
15
|
-
mkdocs_include_markdown_plugin-6.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|