mkdocs-include-markdown-plugin 7.1.5__tar.gz → 7.1.7__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.5 → mkdocs_include_markdown_plugin-7.1.7}/PKG-INFO +1 -1
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/pyproject.toml +1 -1
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/cache.py +1 -1
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/directive.py +1 -1
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/event.py +24 -21
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/process.py +23 -10
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/.gitignore +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/LICENSE +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/README.md +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/config.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/logger.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
- {mkdocs_include_markdown_plugin-7.1.5 → mkdocs_include_markdown_plugin-7.1.7}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version: 7.1.
|
|
3
|
+
Version: 7.1.7
|
|
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
|
|
@@ -208,7 +208,7 @@ def parse_filename_argument(
|
|
|
208
208
|
|
|
209
209
|
def parse_string_argument(match: re.Match[str] | None) -> str | None:
|
|
210
210
|
"""Return the string argument matched by ``match``."""
|
|
211
|
-
if match is None:
|
|
211
|
+
if match is None: # pragma: no cover
|
|
212
212
|
return None
|
|
213
213
|
value = match[1]
|
|
214
214
|
if value is None:
|
|
@@ -436,27 +436,30 @@ def get_file_content( # noqa: PLR0913, PLR0915
|
|
|
436
436
|
offset_match = ARGUMENT_REGEXES['heading-offset']().search(
|
|
437
437
|
arguments_string,
|
|
438
438
|
)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
439
|
+
try:
|
|
440
|
+
# Here None[1] would raise a TypeError
|
|
441
|
+
offset_raw_value = offset_match[1] # type: ignore
|
|
442
|
+
except (IndexError, TypeError): # pragma: no cover
|
|
443
|
+
offset_raw_value = ''
|
|
444
|
+
if offset_raw_value == '':
|
|
445
|
+
location = process.file_lineno_message(
|
|
446
|
+
page_src_path, docs_dir, directive_lineno(),
|
|
447
|
+
)
|
|
448
|
+
raise PluginError(
|
|
449
|
+
"Invalid empty 'heading-offset' argument in"
|
|
450
|
+
f" 'include-markdown' directive at {location}",
|
|
451
|
+
)
|
|
452
|
+
try:
|
|
453
|
+
offset = int(offset_raw_value)
|
|
454
|
+
except ValueError:
|
|
455
|
+
location = process.file_lineno_message(
|
|
456
|
+
page_src_path, docs_dir, directive_lineno(),
|
|
457
|
+
)
|
|
458
|
+
raise PluginError(
|
|
459
|
+
f"Invalid 'heading-offset' argument"
|
|
460
|
+
f" '{offset_raw_value}' in 'include-markdown'"
|
|
461
|
+
f" directive at {location}",
|
|
462
|
+
) from None
|
|
460
463
|
|
|
461
464
|
bool_options, invalid_bool_args = parse_bool_options(
|
|
462
465
|
[
|
|
@@ -33,7 +33,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
33
33
|
# previous to Python3.11. Also, these nested brackets can be recursive in the
|
|
34
34
|
# Perl implementation but this doesn't seem possible in Python, the current
|
|
35
35
|
# implementation only reaches two levels.
|
|
36
|
-
MARKDOWN_LINK_REGEX = re.compile(
|
|
36
|
+
MARKDOWN_LINK_REGEX = re.compile(
|
|
37
37
|
r'''
|
|
38
38
|
( # wrap whole match in $1
|
|
39
39
|
(?<!!) # don't match images - negative lookbehind
|
|
@@ -291,7 +291,7 @@ def rewrite_relative_urls(
|
|
|
291
291
|
``destination_path``.
|
|
292
292
|
"""
|
|
293
293
|
def rewrite_url(url: str) -> str:
|
|
294
|
-
if is_url(url) or is_absolute_path(url):
|
|
294
|
+
if is_url(url) or is_absolute_path(url) or is_anchor(url):
|
|
295
295
|
return url
|
|
296
296
|
|
|
297
297
|
new_path = os.path.relpath(
|
|
@@ -427,17 +427,19 @@ def filter_inclusions( # noqa: PLR0912
|
|
|
427
427
|
def _transform_negative_offset_func_factory(
|
|
428
428
|
offset: int,
|
|
429
429
|
) -> Callable[[str], str]:
|
|
430
|
-
|
|
430
|
+
abs_offset = abs(offset)
|
|
431
431
|
|
|
432
432
|
def transform(line: str) -> str:
|
|
433
433
|
try:
|
|
434
434
|
if line[0] != '#':
|
|
435
435
|
return line
|
|
436
436
|
except IndexError: # pragma: no cover
|
|
437
|
+
# Note for pragma: all lines include a newline
|
|
438
|
+
# so this exception is never raised in tests.
|
|
437
439
|
return line
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return '#' +
|
|
440
|
+
stripped_line = line.lstrip('#')
|
|
441
|
+
new_n_headings = max(len(line) - len(stripped_line) - abs_offset, 1)
|
|
442
|
+
return '#' * new_n_headings + stripped_line
|
|
441
443
|
|
|
442
444
|
return transform
|
|
443
445
|
|
|
@@ -449,11 +451,11 @@ def _transform_positive_offset_func_factory(
|
|
|
449
451
|
|
|
450
452
|
def transform(line: str) -> str:
|
|
451
453
|
try:
|
|
452
|
-
|
|
454
|
+
if line[0] != '#':
|
|
455
|
+
return line
|
|
453
456
|
except IndexError: # pragma: no cover
|
|
454
457
|
return line
|
|
455
|
-
|
|
456
|
-
return heading_prefix + line if prefix == '#' else line
|
|
458
|
+
return heading_prefix + line
|
|
457
459
|
|
|
458
460
|
return transform
|
|
459
461
|
|
|
@@ -583,6 +585,17 @@ def is_absolute_path(string: str) -> bool:
|
|
|
583
585
|
return False
|
|
584
586
|
|
|
585
587
|
|
|
588
|
+
def is_anchor(string: str) -> bool:
|
|
589
|
+
"""Check if a string looks like an anchor.
|
|
590
|
+
|
|
591
|
+
An anchor is a string that starts with `#` and is not a relative path.
|
|
592
|
+
"""
|
|
593
|
+
try:
|
|
594
|
+
return string[0] == '#'
|
|
595
|
+
except IndexError: # pragma: no cover
|
|
596
|
+
return False
|
|
597
|
+
|
|
598
|
+
|
|
586
599
|
def read_file(file_path: str, encoding: str) -> str:
|
|
587
600
|
"""Read a file and return its content."""
|
|
588
601
|
f = open(file_path, encoding=encoding) # noqa: SIM115
|
|
@@ -597,7 +610,7 @@ def read_url(
|
|
|
597
610
|
encoding: str = 'utf-8',
|
|
598
611
|
) -> Any:
|
|
599
612
|
"""Read an HTTP location and return its content."""
|
|
600
|
-
from urllib.request import Request, urlopen
|
|
613
|
+
from urllib.request import Request, urlopen # noqa: PLC0415
|
|
601
614
|
|
|
602
615
|
if http_cache is not None:
|
|
603
616
|
cached_content = http_cache.get_(url, encoding)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|