markdown_convert 1.2.42__py3-none-any.whl → 1.2.44__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.
@@ -10,6 +10,14 @@
10
10
  --left-margin: 1.5em;
11
11
  --left-margin-small: 1em;
12
12
  --left-margin-big: 2em;
13
+
14
+ /* -- Colors -- */
15
+ --color-text: #333; /* Main text color */
16
+ --color-text-light: #666; /* Tables, blockquotes, footers */
17
+ --color-text-background: #eee; /* Code blocks, table headers */
18
+ --color-border: #999; /* Image borders, rules */
19
+ --color-border-light: #ccc; /* Table borders, blockquotes */
20
+ --color-links: #09f; /* Hyperlinks */
13
21
  }
14
22
 
15
23
  /* Document */
@@ -24,7 +32,7 @@ body {
24
32
  font-family:
25
33
  "Segoe UI", "Ubuntu", "DejaVu Sans", "Liberation Sans", "Arial",
26
34
  "sans-serif";
27
- color: #333;
35
+ color: var(--color-text);
28
36
  }
29
37
 
30
38
  /* Headers and paragraphs */
@@ -51,18 +59,18 @@ h2,
51
59
  h3,
52
60
  h4,
53
61
  h5 {
54
- color: #333;
62
+ color: var(--color-text);
55
63
  font-weight: 600;
56
64
  }
57
65
 
58
66
  h1 {
59
67
  font-size: 2.2rem;
60
- border-bottom: 0.5px solid #999;
68
+ border-bottom: 0.5px solid var(--color-border);
61
69
  }
62
70
 
63
71
  h2 {
64
72
  font-size: 1.8rem;
65
- border-bottom: 0.5px solid #999;
73
+ border-bottom: 0.5px solid var(--color-border);
66
74
  }
67
75
 
68
76
  h3 {
@@ -83,7 +91,7 @@ p {
83
91
 
84
92
  /* Links */
85
93
  a {
86
- color: #09f;
94
+ color: var(--color-links);
87
95
  margin: 0;
88
96
  vertical-align: baseline;
89
97
  }
@@ -126,7 +134,7 @@ code {
126
134
  "JetBrains Mono", "Consolas", "Ubuntu Mono", "DejaVu Sans Mono",
127
135
  "Liberation Mono", "Courier New", monospace;
128
136
  font-size: 1rem;
129
- background-color: #eee;
137
+ background-color: var(--color-text-background);
130
138
  padding-left: 0.4em;
131
139
  padding-right: 0.4em;
132
140
  display: inline-block;
@@ -147,9 +155,9 @@ blockquote {
147
155
  margin-top: 0;
148
156
  margin-bottom: var(--bottom-margin);
149
157
  margin-left: var(--left-margin);
150
- border-left: 4px solid #ccc;
158
+ border-left: 4px solid var(--color-border-light);
151
159
  padding-left: 0.5em;
152
- color: #666;
160
+ color: var(--color-text-light);
153
161
  }
154
162
 
155
163
  blockquote > blockquote {
@@ -166,6 +174,16 @@ img {
166
174
  margin: 1em auto;
167
175
  }
168
176
 
177
+ /* Image footers */
178
+ p > img + em {
179
+ text-align: center;
180
+ font-size: 1rem;
181
+ font-style: italic;
182
+ color: var(--color-text-light);
183
+ display: block;
184
+ margin: 1em auto;
185
+ }
186
+
169
187
  /* Image alt text attributes */
170
188
  img[alt*="::tiny::"],
171
189
  img[alt*="::smallest::"] {
@@ -201,14 +219,29 @@ p:has(> img[alt*="::inline::"]) {
201
219
  margin-right: 1em;
202
220
  }
203
221
 
204
- /* Image footers */
205
- p > img + em {
206
- text-align: center;
207
- font-size: 1rem;
208
- font-style: italic;
209
- color: #666;
210
- display: block;
211
- margin: 1em auto;
222
+ img[alt*="::shadow::"] {
223
+ box-shadow: rgba(100, 100, 100, 0.4) 0px 2px 8px 0px;
224
+ }
225
+
226
+ img[alt*="::border::"] {
227
+ border: 2px solid var(--color-border);
228
+ }
229
+
230
+ img[alt*="::invert::"] {
231
+ filter: invert(100%);
232
+ }
233
+
234
+ img[alt*="::grayscale::"],
235
+ img[alt*="::greyscale::"] {
236
+ filter: grayscale(100%);
237
+ }
238
+
239
+ img[alt*="::circle::"] {
240
+ border-radius: 50%;
241
+ }
242
+
243
+ img[alt*="::rounded::"] {
244
+ border-radius: 1em;
212
245
  }
213
246
 
214
247
  /* Tables */
@@ -224,17 +257,17 @@ table {
224
257
  }
225
258
 
226
259
  thead {
227
- background-color: #eee;
260
+ background-color: var(--color-text-background);
228
261
  }
229
262
 
230
263
  tbody {
231
- color: #666;
264
+ color: var(--color-text-light);
232
265
  }
233
266
 
234
267
  th,
235
268
  td {
236
269
  padding: 0.5em 0.75em;
237
- border: 1px solid #ccc;
270
+ border: 1px solid var(--color-border-light);
238
271
  overflow-wrap: break-word;
239
272
  vertical-align: top;
240
273
  }
@@ -253,7 +286,7 @@ td {
253
286
  /* Horizontal rulers */
254
287
  hr {
255
288
  height: 1px;
256
- background-color: #999;
289
+ background-color: var(--color-border);
257
290
  border: none;
258
291
  }
259
292
 
@@ -296,3 +329,74 @@ math {
296
329
  text-rendering: optimizeLegibility;
297
330
  font-family: "Latin Modern Math", "Cambria Math", serif;
298
331
  }
332
+
333
+ /* Classes for custom containers */
334
+ .red,
335
+ .r {
336
+ color: red;
337
+ }
338
+
339
+ .green,
340
+ .g {
341
+ color: green;
342
+ }
343
+
344
+ .blue,
345
+ .b {
346
+ color: blue;
347
+ }
348
+
349
+ .yellow {
350
+ color: goldenrod;
351
+ }
352
+
353
+ .orange {
354
+ color: orange;
355
+ }
356
+
357
+ .purple {
358
+ color: purple;
359
+ }
360
+
361
+ .white {
362
+ color: white;
363
+ }
364
+
365
+ .black {
366
+ color: black;
367
+ }
368
+
369
+ .gray {
370
+ color: gray;
371
+ }
372
+
373
+ .brown {
374
+ color: brown;
375
+ }
376
+
377
+ .pink {
378
+ color: pink;
379
+ }
380
+
381
+ .underline,
382
+ .u {
383
+ text-decoration: underline;
384
+ }
385
+
386
+ .highlight,
387
+ .hl {
388
+ background-color: yellow;
389
+ }
390
+
391
+ .keyboard,
392
+ .key {
393
+ font-family:
394
+ "Segoe UI Symbol", "DejaVu Sans", "Liberation Sans", "Arial",
395
+ "sans-serif";
396
+ font-size: 0.9rem;
397
+ background-color: var(--color-text-background);
398
+ border: 1px solid var(--color-border);
399
+ border-radius: 0.3em;
400
+ padding: 0.1em 0.4em;
401
+ box-shadow: rgba(100, 100, 100, 0.4) 0px 2px 4px 0px;
402
+ }
@@ -19,6 +19,7 @@ from .transform import (
19
19
  render_mermaid_diagrams,
20
20
  create_html_document,
21
21
  render_checkboxes,
22
+ create_spans,
22
23
  )
23
24
  from .utils import drop_duplicates
24
25
 
@@ -135,6 +136,7 @@ def convert(
135
136
  html = create_sections(html)
136
137
  html = render_mermaid_diagrams(html, nonce=nonce)
137
138
  html = render_checkboxes(html)
139
+ html = create_spans(html)
138
140
 
139
141
  _generate_pdf_with_playwright(
140
142
  html,
@@ -206,6 +208,7 @@ def convert_text(markdown_text, css_text=None, *, extend_default_css=True):
206
208
  html = create_sections(html)
207
209
  html = render_mermaid_diagrams(html, nonce=nonce)
208
210
  html = render_checkboxes(html)
211
+ html = create_spans(html)
209
212
 
210
213
  return _generate_pdf_with_playwright(
211
214
  html,
@@ -110,3 +110,56 @@ def render_checkboxes(html):
110
110
  parts[part_index] = parts[part_index].replace(checked, checked_html)
111
111
 
112
112
  return "".join(parts)
113
+
114
+
115
+ def create_spans(html):
116
+ """
117
+ Renders custom spans in the HTML content by replacing classname{{ content }} tags.
118
+ Args:
119
+ html (str): HTML content.
120
+ Returns:
121
+ str: HTML content with rendered custom spans.
122
+ """
123
+ soup = BeautifulSoup(html, "html.parser")
124
+
125
+ # Regex to match classname{{ content }}
126
+ # It captures the class name and the content
127
+ pattern = re.compile(r"([a-zA-Z0-9_-]+){{\s*(.*?)\s*}}")
128
+
129
+ # We need to find all text nodes and replace the pattern
130
+ for text_node in soup.find_all(string=True):
131
+ # Skip text nodes inside code, pre, script, style tags
132
+ if text_node.parent.name in ["code", "pre", "script", "style"]:
133
+ continue
134
+
135
+ content = str(text_node)
136
+ if "{{" in content:
137
+ new_content_nodes = []
138
+ last_end = 0
139
+ for match in pattern.finditer(content):
140
+ # Add text before the match
141
+ before = content[last_end : match.start()]
142
+ if before:
143
+ new_content_nodes.append(soup.new_string(before))
144
+
145
+ # Create the new span tag
146
+ class_name = match.group(1)
147
+ inner_text = match.group(2)
148
+ new_span = soup.new_tag("span", attrs={"class": class_name})
149
+ new_span.string = inner_text
150
+ new_content_nodes.append(new_span)
151
+
152
+ last_end = match.end()
153
+
154
+ # Add remaining text after the last match
155
+ after = content[last_end:]
156
+ if after:
157
+ new_content_nodes.append(soup.new_string(after))
158
+
159
+ if new_content_nodes:
160
+ # Replace the original text node with the new nodes
161
+ for node in reversed(new_content_nodes):
162
+ text_node.insert_after(node)
163
+ text_node.extract()
164
+
165
+ return str(soup)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown_convert
3
- Version: 1.2.42
3
+ Version: 1.2.44
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,16 +1,16 @@
1
1
  markdown_convert/__init__.py,sha256=ysW3pXsDGGK4PzZHcIBTpfVW58IkDUwHffDkf_GM6UU,303
2
2
  markdown_convert/__main__.py,sha256=w6sHfJcJQpMOERPqiNoKgoRM38YUwK22eGBmVkpZj1g,2807
3
3
  markdown_convert/code.css,sha256=Wt4FqFqJcpT-jwY3GN-o4ZRCCXU8DQj-9lqKdGiuoyw,4935
4
- markdown_convert/default.css,sha256=-O54VpOvX_PP7vwT8zTErZLYVSzXV4LQoELRM8yXWS8,4166
4
+ markdown_convert/default.css,sha256=i7RE3GrRB_RlsB16AeFVQt1YMxSP__6ygcR2dZcKkac,5928
5
5
  markdown_convert/modules/__init__.py,sha256=PFPgiQhMXgyfjD8BkfLC_X8AR1jz-dCxfif2qmNofJs,65
6
6
  markdown_convert/modules/constants.py,sha256=eUeIFRxZerP3E0Rgp_Nsl0Q38IBELwca5UO3fbUcxRA,1280
7
- markdown_convert/modules/convert.py,sha256=02N_Iz4TLKWR1xseNv8hyCTujCJdYepWZlxjXw9tsj0,8876
7
+ markdown_convert/modules/convert.py,sha256=8pWlE2PSvV9vIaziPWymXnQZqw92PkeTnLmttdQzgaw,8962
8
8
  markdown_convert/modules/resources.py,sha256=tnW8JmCrJNBRbzOcaOVG6GX5jPC8Kzj3dA7gX0B935A,2488
9
- markdown_convert/modules/transform.py,sha256=p7J8LJKBjMA_EtUYIfXqw_Tc1eean7EbM6KW5Tv4AOs,3138
9
+ markdown_convert/modules/transform.py,sha256=fNsZfXzBlOmuNCOwXdHbMIC7FBp16tfjQG-0tf3UIIE,5012
10
10
  markdown_convert/modules/utils.py,sha256=NX0WegM8e8MPKNNmweTujAWO8ZghdB8LSGDx20K2E44,655
11
11
  markdown_convert/modules/validate.py,sha256=XV_k7cHeifEKDaltF26tCmabs2-Me5msP3enI_eVwfA,1517
12
- markdown_convert-1.2.42.dist-info/METADATA,sha256=FpWY-E6em0W-zeNUd8bmg4bk-qJ7Lk3YkKoqWGg2d0k,3928
13
- markdown_convert-1.2.42.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
- markdown_convert-1.2.42.dist-info/entry_points.txt,sha256=RCmzC7C0sX-SpzIP2Cr34rhg3lMd7BRx-exaZPfK8bU,68
15
- markdown_convert-1.2.42.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
16
- markdown_convert-1.2.42.dist-info/RECORD,,
12
+ markdown_convert-1.2.44.dist-info/METADATA,sha256=5EdXkh69H1RFfFWGXzv-up_o4bsOU0QIFB1CGrzGTgI,3928
13
+ markdown_convert-1.2.44.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
+ markdown_convert-1.2.44.dist-info/entry_points.txt,sha256=RCmzC7C0sX-SpzIP2Cr34rhg3lMd7BRx-exaZPfK8bU,68
15
+ markdown_convert-1.2.44.dist-info/licenses/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
16
+ markdown_convert-1.2.44.dist-info/RECORD,,