mkdocs-include-markdown-plugin 6.2.2__py3-none-any.whl → 7.0.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 -8
- mkdocs_include_markdown_plugin/config.py +1 -1
- mkdocs_include_markdown_plugin/directive.py +41 -33
- mkdocs_include_markdown_plugin/event.py +3 -3
- mkdocs_include_markdown_plugin/plugin.py +1 -3
- mkdocs_include_markdown_plugin/process.py +75 -43
- {mkdocs_include_markdown_plugin-6.2.2.dist-info → mkdocs_include_markdown_plugin-7.0.1.dist-info}/METADATA +8 -10
- mkdocs_include_markdown_plugin-7.0.1.dist-info/RECORD +15 -0
- {mkdocs_include_markdown_plugin-6.2.2.dist-info → mkdocs_include_markdown_plugin-7.0.1.dist-info}/WHEEL +1 -1
- mkdocs_include_markdown_plugin-6.2.2.dist-info/RECORD +0 -15
- {mkdocs_include_markdown_plugin-6.2.2.dist-info → mkdocs_include_markdown_plugin-7.0.1.dist-info}/entry_points.txt +0 -0
- {mkdocs_include_markdown_plugin-6.2.2.dist-info → mkdocs_include_markdown_plugin-7.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import base64
|
|
6
5
|
import hashlib
|
|
7
6
|
import os
|
|
8
7
|
import time
|
|
@@ -29,15 +28,13 @@ class Cache:
|
|
|
29
28
|
|
|
30
29
|
def get_creation_time_from_fpath(self, fpath: str) -> int:
|
|
31
30
|
"""Get creation time of an entry in the cache given its path."""
|
|
32
|
-
with open(fpath,
|
|
31
|
+
with open(fpath, 'rb') as f:
|
|
33
32
|
return int(f.readline())
|
|
34
33
|
|
|
35
34
|
@classmethod
|
|
36
35
|
def generate_unique_key_from_url(cls, url: str) -> str:
|
|
37
36
|
"""Generate a unique key from an URL."""
|
|
38
|
-
return
|
|
39
|
-
hashlib.sha3_512(url.encode()).digest(),
|
|
40
|
-
).decode('utf-8')
|
|
37
|
+
return hashlib.blake2b(url.encode(), digest_size=16).digest().hex()
|
|
41
38
|
|
|
42
39
|
def read_file(self, fpath: str, encoding: str = 'utf-8') -> str: # noqa: D102
|
|
43
40
|
with open(fpath, encoding=encoding) as f:
|
|
@@ -56,9 +53,10 @@ class Cache:
|
|
|
56
53
|
def set_(self, url: str, value: str, encoding: str = 'utf-8') -> None: # noqa: D102
|
|
57
54
|
key = self.generate_unique_key_from_url(url)
|
|
58
55
|
fpath = os.path.join(self.cache_dir, key)
|
|
59
|
-
with open(fpath, '
|
|
60
|
-
f
|
|
61
|
-
|
|
56
|
+
with open(fpath, 'wb') as fp:
|
|
57
|
+
now = f'{int(time.time())}\n'
|
|
58
|
+
fp.write(now.encode(encoding))
|
|
59
|
+
fp.write(value.encode(encoding))
|
|
62
60
|
|
|
63
61
|
def clean(self) -> None:
|
|
64
62
|
"""Clean expired entries from the cache."""
|
|
@@ -17,7 +17,7 @@ class PluginConfig(Config): # noqa: D101
|
|
|
17
17
|
preserve_includer_indent = MkType(bool, default=True)
|
|
18
18
|
dedent = MkType(bool, default=False)
|
|
19
19
|
trailing_newlines = MkType(bool, default=True)
|
|
20
|
-
comments = MkType(bool, default=
|
|
20
|
+
comments = MkType(bool, default=False)
|
|
21
21
|
rewrite_relative_urls = MkType(bool, default=True)
|
|
22
22
|
heading_offset = MkType(int, default=0)
|
|
23
23
|
start = Optional(MkType(str))
|
|
@@ -21,7 +21,7 @@ class DirectiveBoolArgument: # noqa: D101
|
|
|
21
21
|
regex: re.Pattern[str]
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
if TYPE_CHECKING:
|
|
24
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
25
25
|
from typing import Literal, TypedDict
|
|
26
26
|
|
|
27
27
|
DirectiveBoolArgumentsDict = dict[str, DirectiveBoolArgument]
|
|
@@ -112,6 +112,10 @@ INCLUDE_DIRECTIVE_ARGS = {
|
|
|
112
112
|
|
|
113
113
|
INCLUDE_MARKDOWN_DIRECTIVE_ARGS = set(ARGUMENT_REGEXES)
|
|
114
114
|
|
|
115
|
+
WARN_INVALID_DIRECTIVE_ARGS_REGEX = re.compile(
|
|
116
|
+
rf'[\w-]*=[{RE_ESCAPED_PUNCTUATION}\w]*',
|
|
117
|
+
)
|
|
118
|
+
|
|
115
119
|
|
|
116
120
|
def warn_invalid_directive_arguments(
|
|
117
121
|
arguments_string: str,
|
|
@@ -121,12 +125,14 @@ def warn_invalid_directive_arguments(
|
|
|
121
125
|
docs_dir: str,
|
|
122
126
|
) -> None:
|
|
123
127
|
"""Warns about the invalid arguments passed to a directive."""
|
|
124
|
-
arg_re = re.compile(rf'[\w-]*=[{RE_ESCAPED_PUNCTUATION}\w]*')
|
|
125
128
|
valid_args = (
|
|
126
129
|
INCLUDE_DIRECTIVE_ARGS if directive == 'include'
|
|
127
130
|
else INCLUDE_MARKDOWN_DIRECTIVE_ARGS
|
|
128
131
|
)
|
|
129
|
-
for arg_value in re.findall(
|
|
132
|
+
for arg_value in re.findall(
|
|
133
|
+
WARN_INVALID_DIRECTIVE_ARGS_REGEX,
|
|
134
|
+
arguments_string,
|
|
135
|
+
):
|
|
130
136
|
if arg_value.split('=', 1)[0] not in valid_args:
|
|
131
137
|
location = process.file_lineno_message(
|
|
132
138
|
page_src_path, docs_dir, directive_lineno,
|
|
@@ -174,9 +180,9 @@ def create_include_tag(
|
|
|
174
180
|
INCLUDE_TAG_RE by the effective tag.
|
|
175
181
|
"""
|
|
176
182
|
return re.compile(
|
|
177
|
-
INCLUDE_TAG_RE.replace(' include', f' {tag}').replace(
|
|
178
|
-
'$OPENING_TAG', re.escape(opening_tag),
|
|
179
|
-
).replace('$CLOSING_TAG', re.escape(closing_tag)),
|
|
183
|
+
INCLUDE_TAG_RE.replace(' include', f' {tag}', 1).replace(
|
|
184
|
+
'$OPENING_TAG', re.escape(opening_tag), 1,
|
|
185
|
+
).replace('$CLOSING_TAG', re.escape(closing_tag), 1),
|
|
180
186
|
flags=re.VERBOSE | re.DOTALL,
|
|
181
187
|
)
|
|
182
188
|
|
|
@@ -209,7 +215,7 @@ def parse_bool_options(
|
|
|
209
215
|
return bool_options, invalid_args
|
|
210
216
|
|
|
211
217
|
|
|
212
|
-
def resolve_file_paths_to_include(
|
|
218
|
+
def resolve_file_paths_to_include( # noqa: PLR0912
|
|
213
219
|
include_string: str,
|
|
214
220
|
includer_page_src_path: str | None,
|
|
215
221
|
docs_dir: str,
|
|
@@ -229,13 +235,11 @@ def resolve_file_paths_to_include(
|
|
|
229
235
|
return process.filter_paths(
|
|
230
236
|
[fpath], ignore_paths,
|
|
231
237
|
), False
|
|
238
|
+
|
|
232
239
|
return process.filter_paths(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
),
|
|
237
|
-
ignore_paths,
|
|
238
|
-
), False
|
|
240
|
+
[include_string] if os.path.isfile(include_string)
|
|
241
|
+
else glob.iglob(include_string, flags=GLOB_FLAGS),
|
|
242
|
+
ignore_paths), False
|
|
239
243
|
|
|
240
244
|
if process.is_relative_path(include_string):
|
|
241
245
|
if includer_page_src_path is None: # pragma: no cover
|
|
@@ -247,29 +251,33 @@ def resolve_file_paths_to_include(
|
|
|
247
251
|
root_dir = os.path.abspath(
|
|
248
252
|
os.path.dirname(includer_page_src_path),
|
|
249
253
|
)
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
flags=GLOB_FLAGS,
|
|
256
|
-
root_dir=root_dir,
|
|
257
|
-
)
|
|
258
|
-
), ignore_paths,
|
|
259
|
-
), False
|
|
260
|
-
|
|
261
|
-
# relative to docs_dir
|
|
262
|
-
return process.filter_paths(
|
|
263
|
-
(
|
|
264
|
-
os.path.normpath(os.path.join(docs_dir, fp))
|
|
254
|
+
paths = []
|
|
255
|
+
include_path = os.path.join(root_dir, include_string)
|
|
256
|
+
if os.path.isfile(include_path):
|
|
257
|
+
paths.append(include_path)
|
|
258
|
+
else:
|
|
265
259
|
for fp in glob.iglob(
|
|
266
260
|
include_string,
|
|
267
261
|
flags=GLOB_FLAGS,
|
|
268
|
-
root_dir=
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
ignore_paths,
|
|
272
|
-
|
|
262
|
+
root_dir=root_dir,
|
|
263
|
+
):
|
|
264
|
+
paths.append(os.path.join(root_dir, fp))
|
|
265
|
+
return process.filter_paths(paths, ignore_paths), False
|
|
266
|
+
|
|
267
|
+
# relative to docs_dir
|
|
268
|
+
paths = []
|
|
269
|
+
root_dir = docs_dir
|
|
270
|
+
include_path = os.path.join(root_dir, include_string)
|
|
271
|
+
if os.path.isfile(include_path):
|
|
272
|
+
paths.append(include_path)
|
|
273
|
+
else:
|
|
274
|
+
for fp in glob.iglob(
|
|
275
|
+
include_string,
|
|
276
|
+
flags=GLOB_FLAGS,
|
|
277
|
+
root_dir=root_dir,
|
|
278
|
+
):
|
|
279
|
+
paths.append(os.path.join(root_dir, fp))
|
|
280
|
+
return process.filter_paths(paths, ignore_paths), False
|
|
273
281
|
|
|
274
282
|
|
|
275
283
|
def resolve_file_paths_to_exclude(
|
|
@@ -28,7 +28,7 @@ from mkdocs_include_markdown_plugin.files_watcher import FilesWatcher
|
|
|
28
28
|
from mkdocs_include_markdown_plugin.logger import logger
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
if TYPE_CHECKING:
|
|
31
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
32
32
|
from typing import Literal, TypedDict
|
|
33
33
|
|
|
34
34
|
from mkdocs.structure.pages import Page
|
|
@@ -630,8 +630,8 @@ def on_page_markdown(
|
|
|
630
630
|
page.file.abs_src_path,
|
|
631
631
|
docs_dir,
|
|
632
632
|
{
|
|
633
|
-
'include': plugin._include_tag,
|
|
634
|
-
'include-markdown': plugin._include_markdown_tag,
|
|
633
|
+
'include': plugin._include_tag(),
|
|
634
|
+
'include-markdown': plugin._include_markdown_tag(),
|
|
635
635
|
},
|
|
636
636
|
{
|
|
637
637
|
'encoding': config.encoding,
|
|
@@ -11,7 +11,7 @@ from mkdocs.livereload import LiveReloadServer
|
|
|
11
11
|
from mkdocs.plugins import BasePlugin, event_priority
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
if TYPE_CHECKING:
|
|
14
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
15
15
|
import re
|
|
16
16
|
|
|
17
17
|
from mkdocs.config.defaults import MkDocsConfig
|
|
@@ -46,14 +46,12 @@ class IncludeMarkdownPlugin(BasePlugin[PluginConfig]):
|
|
|
46
46
|
|
|
47
47
|
return config
|
|
48
48
|
|
|
49
|
-
@cached_property
|
|
50
49
|
def _include_tag(self) -> re.Pattern[str]:
|
|
51
50
|
return create_include_tag(
|
|
52
51
|
self.config.opening_tag,
|
|
53
52
|
self.config.closing_tag,
|
|
54
53
|
)
|
|
55
54
|
|
|
56
|
-
@cached_property
|
|
57
55
|
def _include_markdown_tag(self) -> re.Pattern[str]:
|
|
58
56
|
return create_include_tag(
|
|
59
57
|
self.config.opening_tag,
|
|
@@ -12,7 +12,7 @@ from urllib.parse import urlparse, urlunparse
|
|
|
12
12
|
from urllib.request import Request, urlopen
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
if TYPE_CHECKING:
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
18
|
from mkdocs_include_markdown_plugin.cache import Cache
|
|
@@ -51,9 +51,9 @@ MARKDOWN_LINK_REGEX = re.compile( # noqa: DUO138
|
|
|
51
51
|
)
|
|
52
52
|
\]
|
|
53
53
|
\( # literal paren
|
|
54
|
-
|
|
54
|
+
\s*
|
|
55
55
|
<?(.*?)>? # href = $3
|
|
56
|
-
|
|
56
|
+
\s*
|
|
57
57
|
( # $4
|
|
58
58
|
(['"]) # quote char = $5
|
|
59
59
|
(.*?) # Title = $6
|
|
@@ -114,7 +114,7 @@ MARKDOWN_LINK_DEFINITION_REGEX = re.compile(
|
|
|
114
114
|
)
|
|
115
115
|
|
|
116
116
|
|
|
117
|
-
def transform_p_by_p_skipping_codeblocks(
|
|
117
|
+
def transform_p_by_p_skipping_codeblocks( # noqa: PLR0912, PLR0915
|
|
118
118
|
markdown: str,
|
|
119
119
|
func: Callable[[str], str],
|
|
120
120
|
) -> str:
|
|
@@ -128,45 +128,77 @@ def transform_p_by_p_skipping_codeblocks(
|
|
|
128
128
|
_current_fcodeblock_delimiter = ''
|
|
129
129
|
|
|
130
130
|
# inside indented codeblock
|
|
131
|
-
|
|
131
|
+
_maybe_icodeblock_lines: list[str] = []
|
|
132
|
+
_previous_line_was_empty = False
|
|
132
133
|
|
|
133
134
|
lines, current_paragraph = ([], '')
|
|
134
135
|
|
|
135
136
|
def process_current_paragraph() -> None:
|
|
136
137
|
lines.extend(func(current_paragraph).splitlines(keepends=True))
|
|
137
138
|
|
|
139
|
+
# The next implementation takes into account that indented code
|
|
140
|
+
# blocks must be surrounded by newlines as per the CommonMark
|
|
141
|
+
# specification. See https://spec.commonmark.org/0.28/#indented-code-blocks
|
|
142
|
+
#
|
|
143
|
+
# However, note that ambiguities with list items are not handled.
|
|
144
|
+
|
|
138
145
|
for line in io.StringIO(markdown):
|
|
139
|
-
if not _current_fcodeblock_delimiter
|
|
146
|
+
if not _current_fcodeblock_delimiter:
|
|
140
147
|
lstripped_line = line.lstrip()
|
|
141
|
-
if (
|
|
142
|
-
lstripped_line.startswith('```')
|
|
143
|
-
or lstripped_line.startswith('~~~')
|
|
144
|
-
):
|
|
148
|
+
if lstripped_line.startswith(('```', '~~~')):
|
|
145
149
|
_current_fcodeblock_delimiter = lstripped_line[:3]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
current_paragraph = ''
|
|
150
|
+
process_current_paragraph()
|
|
151
|
+
current_paragraph = ''
|
|
149
152
|
lines.append(line)
|
|
150
|
-
elif (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
elif line.startswith(' '):
|
|
154
|
+
if not lstripped_line or _maybe_icodeblock_lines:
|
|
155
|
+
# maybe enter indented codeblock
|
|
156
|
+
_maybe_icodeblock_lines.append(line)
|
|
157
|
+
else:
|
|
158
|
+
current_paragraph += line
|
|
159
|
+
elif _maybe_icodeblock_lines:
|
|
160
|
+
process_current_paragraph()
|
|
161
|
+
current_paragraph = ''
|
|
162
|
+
if not _previous_line_was_empty:
|
|
163
|
+
# wasn't an indented code block
|
|
164
|
+
for line_ in _maybe_icodeblock_lines:
|
|
165
|
+
current_paragraph += line_
|
|
166
|
+
_maybe_icodeblock_lines = []
|
|
167
|
+
current_paragraph += line
|
|
156
168
|
process_current_paragraph()
|
|
157
169
|
current_paragraph = ''
|
|
158
|
-
|
|
170
|
+
else:
|
|
171
|
+
# exit indented codeblock
|
|
172
|
+
for line_ in _maybe_icodeblock_lines:
|
|
173
|
+
lines.append(line_)
|
|
174
|
+
_maybe_icodeblock_lines = []
|
|
175
|
+
lines.append(line)
|
|
159
176
|
else:
|
|
160
177
|
current_paragraph += line
|
|
178
|
+
_previous_line_was_empty = not lstripped_line
|
|
161
179
|
else:
|
|
162
180
|
lines.append(line)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
181
|
+
lstripped_line = line.lstrip()
|
|
182
|
+
if lstripped_line.startswith(_current_fcodeblock_delimiter):
|
|
183
|
+
_current_fcodeblock_delimiter = ''
|
|
184
|
+
_previous_line_was_empty = not lstripped_line
|
|
185
|
+
|
|
186
|
+
if _maybe_icodeblock_lines:
|
|
187
|
+
if not _previous_line_was_empty:
|
|
188
|
+
# at EOF
|
|
189
|
+
process_current_paragraph()
|
|
190
|
+
current_paragraph = ''
|
|
191
|
+
for line_ in _maybe_icodeblock_lines:
|
|
192
|
+
current_paragraph += line_
|
|
193
|
+
process_current_paragraph()
|
|
194
|
+
current_paragraph = ''
|
|
195
|
+
else:
|
|
196
|
+
process_current_paragraph()
|
|
197
|
+
current_paragraph = ''
|
|
198
|
+
for line_ in _maybe_icodeblock_lines:
|
|
199
|
+
lines.append(line_)
|
|
200
|
+
else:
|
|
201
|
+
process_current_paragraph()
|
|
170
202
|
|
|
171
203
|
return ''.join(lines)
|
|
172
204
|
|
|
@@ -180,7 +212,7 @@ def transform_line_by_line_skipping_codeblocks(
|
|
|
180
212
|
Skip fenced codeblock lines, where the transformation never is applied.
|
|
181
213
|
|
|
182
214
|
Indented codeblocks are not taken into account because in the practice
|
|
183
|
-
this function is
|
|
215
|
+
this function is only used for transformations of heading prefixes. See
|
|
184
216
|
the PR https://github.com/mondeja/mkdocs-include-markdown-plugin/pull/95
|
|
185
217
|
to recover the implementation handling indented codeblocks.
|
|
186
218
|
"""
|
|
@@ -191,10 +223,7 @@ def transform_line_by_line_skipping_codeblocks(
|
|
|
191
223
|
for line in io.StringIO(markdown):
|
|
192
224
|
if not _current_fcodeblock_delimiter:
|
|
193
225
|
lstripped_line = line.lstrip()
|
|
194
|
-
if (
|
|
195
|
-
lstripped_line.startswith('```')
|
|
196
|
-
or lstripped_line.startswith('~~~')
|
|
197
|
-
):
|
|
226
|
+
if lstripped_line.startswith(('```', '~~~')):
|
|
198
227
|
_current_fcodeblock_delimiter = lstripped_line[:3]
|
|
199
228
|
else:
|
|
200
229
|
line = func(line) # noqa: PLW2901
|
|
@@ -220,25 +249,23 @@ def rewrite_relative_urls(
|
|
|
220
249
|
scheme, netloc, path, params, query, fragment = urlparse(url)
|
|
221
250
|
|
|
222
251
|
# absolute or mail
|
|
223
|
-
if path.startswith('/') or scheme == 'mailto':
|
|
252
|
+
if is_relative_path(url) or path.startswith('/') or scheme == 'mailto':
|
|
224
253
|
return url
|
|
225
254
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
path = os.path.relpath(
|
|
255
|
+
new_path = os.path.relpath(
|
|
229
256
|
os.path.join(os.path.dirname(source_path), path),
|
|
230
257
|
os.path.dirname(destination_path),
|
|
231
258
|
)
|
|
232
259
|
|
|
233
260
|
# ensure forward slashes are used, on Windows
|
|
234
|
-
|
|
261
|
+
new_path = new_path.replace('\\', '/').replace('//', '/')
|
|
235
262
|
|
|
236
|
-
if
|
|
263
|
+
if path.endswith('/'):
|
|
237
264
|
# the above operation removes a trailing slash. Add it back if it
|
|
238
265
|
# was present in the input
|
|
239
|
-
|
|
266
|
+
new_path = new_path + '/'
|
|
240
267
|
|
|
241
|
-
return urlunparse((scheme, netloc,
|
|
268
|
+
return urlunparse((scheme, netloc, new_path, params, query, fragment))
|
|
242
269
|
|
|
243
270
|
def found_href(m: re.Match[str], url_group_index: int = -1) -> str:
|
|
244
271
|
match_start, match_end = m.span(0)
|
|
@@ -269,6 +296,7 @@ def rewrite_relative_urls(
|
|
|
269
296
|
functools.partial(found_href, url_group_index=2),
|
|
270
297
|
paragraph,
|
|
271
298
|
)
|
|
299
|
+
|
|
272
300
|
return transform_p_by_p_skipping_codeblocks(
|
|
273
301
|
markdown,
|
|
274
302
|
transform,
|
|
@@ -364,7 +392,7 @@ def _transform_positive_offset_func_factory(
|
|
|
364
392
|
|
|
365
393
|
def increase_headings_offset(markdown: str, offset: int = 0) -> str:
|
|
366
394
|
"""Increases the headings depth of a snippet of Makdown content."""
|
|
367
|
-
if not offset:
|
|
395
|
+
if not offset: # pragma: no cover
|
|
368
396
|
return markdown
|
|
369
397
|
return transform_line_by_line_skipping_codeblocks(
|
|
370
398
|
markdown,
|
|
@@ -408,7 +436,9 @@ def filter_paths(
|
|
|
408
436
|
continue
|
|
409
437
|
|
|
410
438
|
# ignore by dirpath (relative or absolute)
|
|
411
|
-
|
|
439
|
+
fp_split = filepath.split(os.sep)
|
|
440
|
+
fp_split.pop()
|
|
441
|
+
if (os.sep).join(fp_split) in ignore_paths:
|
|
412
442
|
continue
|
|
413
443
|
|
|
414
444
|
# ignore if is a directory
|
|
@@ -420,6 +450,8 @@ def filter_paths(
|
|
|
420
450
|
|
|
421
451
|
def is_url(string: str) -> bool:
|
|
422
452
|
"""Determine if a string is an URL."""
|
|
453
|
+
if ':' not in string: # fast path
|
|
454
|
+
return False
|
|
423
455
|
try:
|
|
424
456
|
result = urlparse(string)
|
|
425
457
|
return all([result.scheme, result.netloc])
|
|
@@ -434,7 +466,7 @@ def is_relative_path(string: str) -> bool:
|
|
|
434
466
|
|
|
435
467
|
def is_absolute_path(string: str) -> bool:
|
|
436
468
|
"""Check if a string looks like an absolute path."""
|
|
437
|
-
return
|
|
469
|
+
return string.startswith((os.sep, '/'))
|
|
438
470
|
|
|
439
471
|
|
|
440
472
|
def read_file(file_path: str, encoding: str) -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.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
|
|
@@ -9,15 +9,13 @@ 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
|
|
13
|
-
License-File: LICENSE
|
|
12
|
+
License: Apache-2.0
|
|
14
13
|
Keywords: includer,markdown,mkdocs,plugin
|
|
15
14
|
Classifier: Development Status :: 5 - Production/Stable
|
|
16
15
|
Classifier: Environment :: Console
|
|
17
16
|
Classifier: Intended Audience :: Developers
|
|
18
17
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
18
|
Classifier: Operating System :: OS Independent
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
19
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
23
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -27,7 +25,7 @@ Classifier: Topic :: Documentation
|
|
|
27
25
|
Classifier: Topic :: Software Development :: Documentation
|
|
28
26
|
Classifier: Topic :: Text Processing
|
|
29
27
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
30
|
-
Requires-Python: >=3.
|
|
28
|
+
Requires-Python: >=3.9
|
|
31
29
|
Requires-Dist: mkdocs>=1.4
|
|
32
30
|
Requires-Dist: wcmatch
|
|
33
31
|
Provides-Extra: cache
|
|
@@ -204,10 +202,10 @@ content to include.
|
|
|
204
202
|
are rewritten to work correctly in their new location. Possible values are
|
|
205
203
|
`true` and `false`.
|
|
206
204
|
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
|
|
207
|
-
**comments** (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
**comments** (_false_): When this option is enabled, the content to include
|
|
206
|
+
is wrapped by `<!-- BEGIN INCLUDE -->` and `<!-- END INCLUDE -->` comments
|
|
207
|
+
which help to identify that the content has been included. Possible values
|
|
208
|
+
are `true` and `false`.
|
|
211
209
|
- <a name="include-markdown_heading-offset" href="#include-markdown_heading-offset">#</a>
|
|
212
210
|
**heading-offset** (0): Increases or decreases the Markdown headings depth
|
|
213
211
|
by this number. Only supports number sign (`#`) heading syntax. Accepts
|
|
@@ -229,7 +227,7 @@ content to include.
|
|
|
229
227
|
start='<!--\n\ttable-start\n-->'
|
|
230
228
|
end='<!--\n\ttable-end\n-->'
|
|
231
229
|
rewrite-relative-urls=false
|
|
232
|
-
comments=
|
|
230
|
+
comments=true
|
|
233
231
|
%}
|
|
234
232
|
```
|
|
235
233
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
mkdocs_include_markdown_plugin/__init__.py,sha256=ByOde15RQSHlZTmkepPSzIt0GzUIv_-GKORFDnxnOmc,193
|
|
2
|
+
mkdocs_include_markdown_plugin/cache.py,sha256=pwA5ZNEiDaTLTo1EuwELGqQ9w8Ud3Ajhtm4OvJ55-5c,2851
|
|
3
|
+
mkdocs_include_markdown_plugin/config.py,sha256=GezwaOHzZ3eDayweFEEG0b7PuWFIqiBBn-XMXrP0U3Q,862
|
|
4
|
+
mkdocs_include_markdown_plugin/directive.py,sha256=Btk04ARk17SLhGF_IbdRIgQucdjtKyvnnofiomyTBL0,9680
|
|
5
|
+
mkdocs_include_markdown_plugin/event.py,sha256=bOyevrcQDcNa_-0j8D3QlpLjlVypmjYmWHlquCJrWQY,24025
|
|
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=EY1iRokm6ZDlyvfZEFUkT81fPf_gNGtwrRKq9kER6r0,3790
|
|
9
|
+
mkdocs_include_markdown_plugin/process.py,sha256=b5fxQ3lCgOwUS3aeSQ7ZNZicbUVuUM_yDbrxkBHBIPE,17183
|
|
10
|
+
mkdocs_include_markdown_plugin/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
mkdocs_include_markdown_plugin-7.0.1.dist-info/METADATA,sha256=QX9LNRlTxho37nCxC3F8-EibGMAlDxLyWm0ePZ8qyE8,12049
|
|
12
|
+
mkdocs_include_markdown_plugin-7.0.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
13
|
+
mkdocs_include_markdown_plugin-7.0.1.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
|
|
14
|
+
mkdocs_include_markdown_plugin-7.0.1.dist-info/licenses/LICENSE,sha256=OunyKlPxiuvLB3ENbo2nyV-OPndkwzyZ5Gzwei0ofbc,11365
|
|
15
|
+
mkdocs_include_markdown_plugin-7.0.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=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.2.dist-info/METADATA,sha256=wDrrPZPZ8gpPTNFZTLjHUIirYKnewCwb3AzhOI6WSig,12142
|
|
12
|
-
mkdocs_include_markdown_plugin-6.2.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
13
|
-
mkdocs_include_markdown_plugin-6.2.2.dist-info/entry_points.txt,sha256=WEL5m7sw5ZMBwmdOs5S_9mGoZfLCaUDPkDKw7CUk16Q,96
|
|
14
|
-
mkdocs_include_markdown_plugin-6.2.2.dist-info/licenses/LICENSE,sha256=OunyKlPxiuvLB3ENbo2nyV-OPndkwzyZ5Gzwei0ofbc,11365
|
|
15
|
-
mkdocs_include_markdown_plugin-6.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|