markdown_convert 1.2.52__py3-none-any.whl → 1.2.54__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.
- markdown_convert/default.css +10 -1
- markdown_convert/modules/convert.py +1 -1
- markdown_convert/modules/extras.py +36 -11
- markdown_convert/modules/overrides.py +36 -0
- {markdown_convert-1.2.52.dist-info → markdown_convert-1.2.54.dist-info}/METADATA +1 -1
- {markdown_convert-1.2.52.dist-info → markdown_convert-1.2.54.dist-info}/RECORD +9 -8
- {markdown_convert-1.2.52.dist-info → markdown_convert-1.2.54.dist-info}/WHEEL +0 -0
- {markdown_convert-1.2.52.dist-info → markdown_convert-1.2.54.dist-info}/entry_points.txt +0 -0
- {markdown_convert-1.2.52.dist-info → markdown_convert-1.2.54.dist-info}/licenses/LICENSE +0 -0
markdown_convert/default.css
CHANGED
|
@@ -445,6 +445,14 @@ math {
|
|
|
445
445
|
text-align: justify;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
.small {
|
|
449
|
+
font-size: 0.75em;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.big {
|
|
453
|
+
font-size: 1.5em;
|
|
454
|
+
}
|
|
455
|
+
|
|
448
456
|
/* Admonitions */
|
|
449
457
|
.admonition {
|
|
450
458
|
padding: 0.5rem 1rem;
|
|
@@ -517,7 +525,8 @@ math {
|
|
|
517
525
|
}
|
|
518
526
|
|
|
519
527
|
/* Vega-Lite charts*/
|
|
520
|
-
.vega-lite
|
|
528
|
+
div.vega-lite,
|
|
529
|
+
div.vega {
|
|
521
530
|
display: flex;
|
|
522
531
|
justify-content: center;
|
|
523
532
|
align-items: center;
|
|
@@ -9,7 +9,6 @@ import time
|
|
|
9
9
|
from datetime import datetime
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
|
-
import markdown2
|
|
13
12
|
from playwright.sync_api import sync_playwright
|
|
14
13
|
|
|
15
14
|
from .autoinstall import ensure_chromium
|
|
@@ -19,6 +18,7 @@ from .constants import (
|
|
|
19
18
|
MARKDOWN_EXTENSIONS,
|
|
20
19
|
PDF_PARAMS,
|
|
21
20
|
)
|
|
21
|
+
from .overrides import markdown2
|
|
22
22
|
from .resources import get_code_css_path, get_css_path, get_output_path
|
|
23
23
|
from .transform import (
|
|
24
24
|
create_html_document,
|
|
@@ -3,10 +3,12 @@ Extras are defined as helper functions called by
|
|
|
3
3
|
render_extra_features from transform.py
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
|
|
6
9
|
import vl_convert as vlc
|
|
10
|
+
from bs4 import BeautifulSoup, Tag
|
|
7
11
|
from ruamel.yaml import YAML
|
|
8
|
-
from bs4 import Tag, BeautifulSoup
|
|
9
|
-
import re
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class ExtraFeature:
|
|
@@ -162,28 +164,51 @@ class TocExtra(ExtraFeature):
|
|
|
162
164
|
|
|
163
165
|
class VegaExtra(ExtraFeature):
|
|
164
166
|
"""
|
|
165
|
-
Extra feature for rendering Vega-Lite diagrams from YAML.
|
|
167
|
+
Extra feature for rendering Vega-Lite diagrams from JSON or YAML.
|
|
166
168
|
"""
|
|
167
169
|
|
|
168
|
-
pattern =
|
|
170
|
+
pattern = (
|
|
171
|
+
r"<pre[^>]*>"
|
|
172
|
+
r"<code[^>]*class=[\"'][^\"]*language-vega[^\"]*[\"'][^>]*>"
|
|
173
|
+
r"(?P<content>.*?)"
|
|
174
|
+
r"</code>"
|
|
175
|
+
r"</pre>"
|
|
176
|
+
)
|
|
169
177
|
run_before_stash = True
|
|
170
178
|
|
|
171
179
|
def replace(match, html):
|
|
172
180
|
"""
|
|
173
|
-
Render a tag for a vega lite diagram YAML.
|
|
181
|
+
Render a tag for a vega lite diagram from JSON or YAML.
|
|
174
182
|
|
|
175
183
|
Args:
|
|
176
|
-
match (re.Match): Element identified as a vega lite diagram
|
|
184
|
+
match (re.Match): Element identified as a vega lite diagram.
|
|
177
185
|
html (str): The full HTML content.
|
|
178
186
|
|
|
179
187
|
Returns:
|
|
180
188
|
str: SVG tag representing the vega lite diagram.
|
|
181
189
|
"""
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
content = match.group("content")
|
|
191
|
+
spec = None
|
|
192
|
+
|
|
193
|
+
try:
|
|
194
|
+
spec = json.loads(content)
|
|
195
|
+
except (json.JSONDecodeError, TypeError):
|
|
196
|
+
try:
|
|
197
|
+
yaml = YAML(typ="safe")
|
|
198
|
+
spec = yaml.load(content)
|
|
199
|
+
except Exception as exc:
|
|
200
|
+
print(f"WARNING: Failed to parse Vega-Lite spec: {exc}")
|
|
201
|
+
return match.group(0)
|
|
202
|
+
|
|
203
|
+
if spec is None:
|
|
204
|
+
return match.group(0)
|
|
205
|
+
|
|
206
|
+
try:
|
|
207
|
+
tag = vlc.vegalite_to_svg(spec)
|
|
208
|
+
return f"<div class='vega-lite'>{tag}</div>"
|
|
209
|
+
except Exception as exc:
|
|
210
|
+
print(f"WARNING: Failed to convert Vega-Lite spec to SVG: {exc}")
|
|
211
|
+
return match.group(0)
|
|
187
212
|
|
|
188
213
|
|
|
189
214
|
def apply_extras(extras: set[ExtraFeature], html, before_stash=False):
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Overrides for markdown2.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import markdown2
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def tags(self, lexer_name: str) -> tuple[str, str]:
|
|
9
|
+
"""
|
|
10
|
+
Overrides markdown2.FencedCodeBlocks.tags
|
|
11
|
+
|
|
12
|
+
Provides support for the fenced code blocks language attribute without
|
|
13
|
+
the need to have the highlightjs-lang extension enabled.
|
|
14
|
+
"""
|
|
15
|
+
pre_class = self.md._html_class_str_from_tag("pre")
|
|
16
|
+
if lexer_name:
|
|
17
|
+
code_class = f' class="{lexer_name} language-{lexer_name}"'
|
|
18
|
+
else:
|
|
19
|
+
code_class = self.md._html_class_str_from_tag("code")
|
|
20
|
+
return (f"<pre{pre_class}><code{code_class}>", "</code></pre>")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _convert_double_match(self, match):
|
|
24
|
+
"""
|
|
25
|
+
Overrides markdown2.Latex._convert_double_match
|
|
26
|
+
|
|
27
|
+
Fixes bug #674 of latex macros that start with backslash n not being
|
|
28
|
+
properly rendered.
|
|
29
|
+
"""
|
|
30
|
+
return self.converter.convert(match.group(1).replace("\n", " "), display="block")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Apply overrides on module import and expose markdown2
|
|
34
|
+
markdown2.FencedCodeBlocks.tags = tags
|
|
35
|
+
markdown2.Latex._convert_double_match = _convert_double_match
|
|
36
|
+
__all__ = ["markdown2"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdown_convert
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.54
|
|
4
4
|
Summary: Convert Markdown files to PDF from your command line.
|
|
5
5
|
Project-URL: homepage, https://github.com/Julynx/markdown_convert
|
|
6
6
|
Author-email: Julio Cabria <juliocabria@tutanota.com>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
markdown_convert/__init__.py,sha256=0hLMtJnCIuApqopx5P4tiDSw850AmnuVcohmAbPVEZ4,303
|
|
2
2
|
markdown_convert/__main__.py,sha256=AocRo1iF1El_-Uo0owJ-QLbJUF0rum5R_AlNrTTTSOQ,2780
|
|
3
3
|
markdown_convert/code.css,sha256=Wt4FqFqJcpT-jwY3GN-o4ZRCCXU8DQj-9lqKdGiuoyw,4935
|
|
4
|
-
markdown_convert/default.css,sha256=
|
|
4
|
+
markdown_convert/default.css,sha256=dwLdWkhub4lm063zj-xEmvBNmTfGk7IHFqlFF-7_rb0,8259
|
|
5
5
|
markdown_convert/modules/__init__.py,sha256=PFPgiQhMXgyfjD8BkfLC_X8AR1jz-dCxfif2qmNofJs,65
|
|
6
6
|
markdown_convert/modules/autoinstall.py,sha256=Tnrde6MIcO11PWT7GZwhs_QTVRy6CSpUB_gIi9G5ve8,2063
|
|
7
7
|
markdown_convert/modules/constants.py,sha256=FA8DrQa9nzTUIJFXwXrK-AuOc5_ToGSFaD4sJqsnAjU,1305
|
|
8
|
-
markdown_convert/modules/convert.py,sha256=
|
|
9
|
-
markdown_convert/modules/extras.py,sha256=
|
|
8
|
+
markdown_convert/modules/convert.py,sha256=kinhf9izQDY8O9-gWdTt0tQB1j5z4ExKcwLaEaBKrM4,8988
|
|
9
|
+
markdown_convert/modules/extras.py,sha256=KWIMXEm_hLLliBIsPraqpA5p3RFKLuqefFz2bbo0DI8,6921
|
|
10
|
+
markdown_convert/modules/overrides.py,sha256=VcrXmfZqypg796WQFQZHfpQnmdem2uC6MEPoHY_xc_o,1063
|
|
10
11
|
markdown_convert/modules/resources.py,sha256=eskLLbrkLJWs-vqtCLq4qV2Hjy6XeGFCUdT0VN2b_tA,2488
|
|
11
12
|
markdown_convert/modules/transform.py,sha256=9_0mqeHwKPECr3Ft1z8r14flTOw4Y8dxblsOIfblEGw,3476
|
|
12
13
|
markdown_convert/modules/utils.py,sha256=NX0WegM8e8MPKNNmweTujAWO8ZghdB8LSGDx20K2E44,655
|
|
13
14
|
markdown_convert/modules/validate.py,sha256=XV_k7cHeifEKDaltF26tCmabs2-Me5msP3enI_eVwfA,1517
|
|
14
|
-
markdown_convert-1.2.
|
|
15
|
-
markdown_convert-1.2.
|
|
16
|
-
markdown_convert-1.2.
|
|
17
|
-
markdown_convert-1.2.
|
|
18
|
-
markdown_convert-1.2.
|
|
15
|
+
markdown_convert-1.2.54.dist-info/METADATA,sha256=j_FFN1Guykm0EHCdKOfrBDSyeyxNIQYXoxnXmif1mSY,4199
|
|
16
|
+
markdown_convert-1.2.54.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
17
|
+
markdown_convert-1.2.54.dist-info/entry_points.txt,sha256=RCmzC7C0sX-SpzIP2Cr34rhg3lMd7BRx-exaZPfK8bU,68
|
|
18
|
+
markdown_convert-1.2.54.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
|
19
|
+
markdown_convert-1.2.54.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|