mkdocs-include-markdown-plugin 6.2.2__tar.gz → 7.0.0__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-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/.gitignore +1 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/PKG-INFO +7 -8
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/README.md +5 -5
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/pyproject.toml +7 -8
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/config.py +1 -1
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/process.py +57 -21
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/LICENSE +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/__init__.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/cache.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/directive.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/event.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/files_watcher.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/logger.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/plugin.py +0 -0
- {mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/src/mkdocs_include_markdown_plugin/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mkdocs-include-markdown-plugin
|
|
3
|
-
Version:
|
|
3
|
+
Version: 7.0.0
|
|
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
|
|
@@ -17,7 +17,6 @@ Classifier: Environment :: Console
|
|
|
17
17
|
Classifier: Intended Audience :: Developers
|
|
18
18
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
19
19
|
Classifier: Operating System :: OS Independent
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.10
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -27,7 +26,7 @@ Classifier: Topic :: Documentation
|
|
|
27
26
|
Classifier: Topic :: Software Development :: Documentation
|
|
28
27
|
Classifier: Topic :: Text Processing
|
|
29
28
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
30
|
-
Requires-Python: >=3.
|
|
29
|
+
Requires-Python: >=3.9
|
|
31
30
|
Requires-Dist: mkdocs>=1.4
|
|
32
31
|
Requires-Dist: wcmatch
|
|
33
32
|
Provides-Extra: cache
|
|
@@ -204,10 +203,10 @@ content to include.
|
|
|
204
203
|
are rewritten to work correctly in their new location. Possible values are
|
|
205
204
|
`true` and `false`.
|
|
206
205
|
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
|
|
207
|
-
**comments** (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
**comments** (_false_): When this option is enabled, the content to include
|
|
207
|
+
is wrapped by `<!-- BEGIN INCLUDE -->` and `<!-- END INCLUDE -->` comments
|
|
208
|
+
which help to identify that the content has been included. Possible values
|
|
209
|
+
are `true` and `false`.
|
|
211
210
|
- <a name="include-markdown_heading-offset" href="#include-markdown_heading-offset">#</a>
|
|
212
211
|
**heading-offset** (0): Increases or decreases the Markdown headings depth
|
|
213
212
|
by this number. Only supports number sign (`#`) heading syntax. Accepts
|
|
@@ -229,7 +228,7 @@ content to include.
|
|
|
229
228
|
start='<!--\n\ttable-start\n-->'
|
|
230
229
|
end='<!--\n\ttable-end\n-->'
|
|
231
230
|
rewrite-relative-urls=false
|
|
232
|
-
comments=
|
|
231
|
+
comments=true
|
|
233
232
|
%}
|
|
234
233
|
```
|
|
235
234
|
|
|
@@ -168,10 +168,10 @@ content to include.
|
|
|
168
168
|
are rewritten to work correctly in their new location. Possible values are
|
|
169
169
|
`true` and `false`.
|
|
170
170
|
- <a name="include-markdown_comments" href="#include-markdown_comments">#</a>
|
|
171
|
-
**comments** (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
**comments** (_false_): When this option is enabled, the content to include
|
|
172
|
+
is wrapped by `<!-- BEGIN INCLUDE -->` and `<!-- END INCLUDE -->` comments
|
|
173
|
+
which help to identify that the content has been included. Possible values
|
|
174
|
+
are `true` and `false`.
|
|
175
175
|
- <a name="include-markdown_heading-offset" href="#include-markdown_heading-offset">#</a>
|
|
176
176
|
**heading-offset** (0): Increases or decreases the Markdown headings depth
|
|
177
177
|
by this number. Only supports number sign (`#`) heading syntax. Accepts
|
|
@@ -193,7 +193,7 @@ content to include.
|
|
|
193
193
|
start='<!--\n\ttable-start\n-->'
|
|
194
194
|
end='<!--\n\ttable-end\n-->'
|
|
195
195
|
rewrite-relative-urls=false
|
|
196
|
-
comments=
|
|
196
|
+
comments=true
|
|
197
197
|
%}
|
|
198
198
|
```
|
|
199
199
|
|
{mkdocs_include_markdown_plugin-6.2.2 → mkdocs_include_markdown_plugin-7.0.0}/pyproject.toml
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mkdocs-include-markdown-plugin"
|
|
3
|
-
version = "
|
|
3
|
+
version = "7.0.0"
|
|
4
4
|
description = "Mkdocs Markdown includer plugin."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "Apache-2.0"
|
|
7
|
-
requires-python = ">=3.
|
|
7
|
+
requires-python = ">=3.9"
|
|
8
8
|
classifiers = [
|
|
9
9
|
"Development Status :: 5 - Production/Stable",
|
|
10
10
|
"Operating System :: OS Independent",
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"Topic :: Text Processing",
|
|
16
16
|
"Topic :: Text Processing :: Markup :: Markdown",
|
|
17
17
|
"Environment :: Console",
|
|
18
|
-
"Programming Language :: Python :: 3.8",
|
|
19
18
|
"Programming Language :: Python :: 3.9",
|
|
20
19
|
"Programming Language :: Python :: 3.10",
|
|
21
20
|
"Programming Language :: Python :: 3.11",
|
|
@@ -74,7 +73,7 @@ matrix-name-format = "{variable}-{value}"
|
|
|
74
73
|
dependencies = ["pytest~=7.0", "coverage~=6.4", "covdefaults"]
|
|
75
74
|
|
|
76
75
|
[[tool.hatch.envs.tests.matrix]]
|
|
77
|
-
python = ["
|
|
76
|
+
python = ["py39", "py310", "py311", "py312", "py313"]
|
|
78
77
|
mkdocs = ["1.4.0", "1.4.3", "1.5.0", "1.5.3", "1.6.0"]
|
|
79
78
|
cache = ["yes", "no"]
|
|
80
79
|
|
|
@@ -105,9 +104,9 @@ targets = [{ file = "pyproject.toml" }]
|
|
|
105
104
|
[tool.project-config]
|
|
106
105
|
cache = "2 days"
|
|
107
106
|
style = [
|
|
108
|
-
"gh://mondeja/project-config-styles@v5.
|
|
109
|
-
"gh://mondeja/project-config-styles@v5.
|
|
110
|
-
"gh://mondeja/project-config-styles@v5.
|
|
107
|
+
"gh://mondeja/project-config-styles@v5.4/base/pre-commit/md2po2md.json5",
|
|
108
|
+
"gh://mondeja/project-config-styles@v5.4/python/base.json5",
|
|
109
|
+
"gh://mondeja/project-config-styles@v5.4/python/mypy.json5",
|
|
111
110
|
]
|
|
112
111
|
|
|
113
112
|
[tool.coverage.run]
|
|
@@ -122,7 +121,7 @@ fail_under = 1
|
|
|
122
121
|
|
|
123
122
|
[tool.ruff]
|
|
124
123
|
line-length = 80
|
|
125
|
-
target-version = "
|
|
124
|
+
target-version = "py39"
|
|
126
125
|
|
|
127
126
|
[tool.ruff.lint]
|
|
128
127
|
select = [
|
|
@@ -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))
|
|
@@ -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,80 @@ 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
148
|
if (
|
|
142
149
|
lstripped_line.startswith('```')
|
|
143
150
|
or lstripped_line.startswith('~~~')
|
|
144
151
|
):
|
|
145
152
|
_current_fcodeblock_delimiter = lstripped_line[:3]
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
current_paragraph = ''
|
|
153
|
+
process_current_paragraph()
|
|
154
|
+
current_paragraph = ''
|
|
149
155
|
lines.append(line)
|
|
150
|
-
elif (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
elif line.startswith(' '):
|
|
157
|
+
if not lstripped_line or _maybe_icodeblock_lines:
|
|
158
|
+
# maybe enter indented codeblock
|
|
159
|
+
_maybe_icodeblock_lines.append(line)
|
|
160
|
+
else:
|
|
161
|
+
current_paragraph += line
|
|
162
|
+
elif _maybe_icodeblock_lines:
|
|
163
|
+
process_current_paragraph()
|
|
164
|
+
current_paragraph = ''
|
|
165
|
+
if not _previous_line_was_empty:
|
|
166
|
+
# wasn't an indented code block
|
|
167
|
+
for line_ in _maybe_icodeblock_lines:
|
|
168
|
+
current_paragraph += line_
|
|
169
|
+
_maybe_icodeblock_lines = []
|
|
170
|
+
current_paragraph += line
|
|
156
171
|
process_current_paragraph()
|
|
157
172
|
current_paragraph = ''
|
|
158
|
-
|
|
173
|
+
else:
|
|
174
|
+
# exit indented codeblock
|
|
175
|
+
for line_ in _maybe_icodeblock_lines:
|
|
176
|
+
lines.append(line_)
|
|
177
|
+
_maybe_icodeblock_lines = []
|
|
178
|
+
lines.append(line)
|
|
159
179
|
else:
|
|
160
180
|
current_paragraph += line
|
|
181
|
+
_previous_line_was_empty = not lstripped_line
|
|
161
182
|
else:
|
|
162
183
|
lines.append(line)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
lstripped_line = line.lstrip()
|
|
185
|
+
if lstripped_line.startswith(_current_fcodeblock_delimiter):
|
|
186
|
+
_current_fcodeblock_delimiter = ''
|
|
187
|
+
_previous_line_was_empty = not lstripped_line
|
|
188
|
+
|
|
189
|
+
if _maybe_icodeblock_lines:
|
|
190
|
+
if not _previous_line_was_empty:
|
|
191
|
+
# at EOF
|
|
192
|
+
process_current_paragraph()
|
|
193
|
+
current_paragraph = ''
|
|
194
|
+
for line_ in _maybe_icodeblock_lines:
|
|
195
|
+
current_paragraph += line_
|
|
196
|
+
process_current_paragraph()
|
|
197
|
+
current_paragraph = ''
|
|
198
|
+
else:
|
|
199
|
+
process_current_paragraph()
|
|
200
|
+
current_paragraph = ''
|
|
201
|
+
for line_ in _maybe_icodeblock_lines:
|
|
202
|
+
lines.append(line_)
|
|
203
|
+
else:
|
|
204
|
+
process_current_paragraph()
|
|
170
205
|
|
|
171
206
|
return ''.join(lines)
|
|
172
207
|
|
|
@@ -180,7 +215,7 @@ def transform_line_by_line_skipping_codeblocks(
|
|
|
180
215
|
Skip fenced codeblock lines, where the transformation never is applied.
|
|
181
216
|
|
|
182
217
|
Indented codeblocks are not taken into account because in the practice
|
|
183
|
-
this function is
|
|
218
|
+
this function is only used for transformations of heading prefixes. See
|
|
184
219
|
the PR https://github.com/mondeja/mkdocs-include-markdown-plugin/pull/95
|
|
185
220
|
to recover the implementation handling indented codeblocks.
|
|
186
221
|
"""
|
|
@@ -269,6 +304,7 @@ def rewrite_relative_urls(
|
|
|
269
304
|
functools.partial(found_href, url_group_index=2),
|
|
270
305
|
paragraph,
|
|
271
306
|
)
|
|
307
|
+
|
|
272
308
|
return transform_p_by_p_skipping_codeblocks(
|
|
273
309
|
markdown,
|
|
274
310
|
transform,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|