decktile 0.2.4__tar.gz → 0.2.5__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.
- {decktile-0.2.4 → decktile-0.2.5}/PKG-INFO +1 -1
- {decktile-0.2.4 → decktile-0.2.5}/pyproject.toml +1 -1
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/parser/ast.py +6 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/parser/markdown.py +16 -2
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/fenced.py +1 -1
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/html.py +10 -1
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/ir.py +4 -2
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_html.py +28 -1
- {decktile-0.2.4 → decktile-0.2.5}/LICENSE +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/README.md +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/__main__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/assets/lucide/VENDORED.md +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/assets/lucide/lucide.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/assets/lucide/lucide.ttf +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/cli.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/parser/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/cards.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/directives.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/layouts.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/lucide.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/plugins/lucide_font.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/odf/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/odf/geometry.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/odf/shapes.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/odf/styles.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/odp.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/pdf.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/pdg.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/seaborn.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/templates/base.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/templates/decktile.js +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/render/templates/shell.html +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/seaborn_styles/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/seaborn_styles/ossummit_europe.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/theme/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/theme/colors.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/theme/loader.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/theme/parser.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/default.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/kcd_vietnam.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/kubecon_china.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/kubecon_japan.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/ossummit_europe.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/src/decktile/themes/ossummit_korea.css +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/__init__.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_cli.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_geometry.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_ir.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_odf_shapes.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_odp.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_parser.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_pdg.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_seaborn_styles.py +0 -0
- {decktile-0.2.4 → decktile-0.2.5}/tests/test_video.py +0 -0
|
@@ -8,7 +8,7 @@ from markdown_it.token import Token
|
|
|
8
8
|
from decktile.parser.ast import (
|
|
9
9
|
Document, Meta, Slide,
|
|
10
10
|
Heading, Paragraph, CodeBlock, Card, Grid, Table, Quote, ListNode, AttrNode,
|
|
11
|
-
Text, Strong, Emphasis, Strikethrough, CodeSpan, Image, SoftBreak, LucideIcon,
|
|
11
|
+
Text, Strong, Emphasis, Strikethrough, CodeSpan, Image, SoftBreak, LucideIcon, Link,
|
|
12
12
|
)
|
|
13
13
|
from decktile.plugins.fenced import extract_fenced, interleave_fences
|
|
14
14
|
from decktile.plugins.directives import preprocess_directives, extract_attrs, parse_attr_token
|
|
@@ -87,7 +87,7 @@ def _parse_slide(content: str) -> Slide:
|
|
|
87
87
|
# Extract fenced blocks
|
|
88
88
|
content, fence_nodes = extract_fenced(content)
|
|
89
89
|
|
|
90
|
-
md = MarkdownIt("gfm-like", {"breaks": True, "html": True})
|
|
90
|
+
md = MarkdownIt("gfm-like", {"breaks": True, "html": True, "linkify": True})
|
|
91
91
|
md.use(lucide_plugin)
|
|
92
92
|
tokens = md.parse(content)
|
|
93
93
|
nodes = _tokens_to_nodes(tokens)
|
|
@@ -267,6 +267,20 @@ def _walk_inline_children(tokens: list) -> list:
|
|
|
267
267
|
inner.extend(_token_inline(tokens[i]))
|
|
268
268
|
i += 1
|
|
269
269
|
result.append(Strikethrough(children=inner))
|
|
270
|
+
elif t.type == "link_open":
|
|
271
|
+
href = dict(t.attrs or {}).get("href", "")
|
|
272
|
+
i += 1
|
|
273
|
+
depth, inner_tokens = 1, []
|
|
274
|
+
while i < len(tokens):
|
|
275
|
+
if tokens[i].type == "link_open":
|
|
276
|
+
depth += 1
|
|
277
|
+
elif tokens[i].type == "link_close":
|
|
278
|
+
depth -= 1
|
|
279
|
+
if depth == 0:
|
|
280
|
+
break
|
|
281
|
+
inner_tokens.append(tokens[i])
|
|
282
|
+
i += 1
|
|
283
|
+
result.append(Link(href=href, children=_walk_inline_children(inner_tokens)))
|
|
270
284
|
else:
|
|
271
285
|
result.extend(_token_inline(t))
|
|
272
286
|
i += 1
|
|
@@ -9,7 +9,7 @@ from markdown_it import MarkdownIt
|
|
|
9
9
|
from decktile.parser.ast import Arrow, Card, CodeBlock, Grid, Node, Notes
|
|
10
10
|
from decktile.plugins.lucide import lucide_plugin
|
|
11
11
|
|
|
12
|
-
_CARD_MD = MarkdownIt("gfm-like", {"breaks": False, "html": True})
|
|
12
|
+
_CARD_MD = MarkdownIt("gfm-like", {"breaks": False, "html": True, "linkify": True})
|
|
13
13
|
_CARD_MD.use(lucide_plugin)
|
|
14
14
|
|
|
15
15
|
_ICON_RE = re.compile(r'\{icon:(\S+)\s*([^}]*)\}')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""HTML renderer for decktile."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
import re
|
|
4
5
|
import subprocess
|
|
5
6
|
import tempfile
|
|
6
7
|
from pathlib import Path
|
|
@@ -200,7 +201,7 @@ def _render_elem(e: Elem) -> str:
|
|
|
200
201
|
from decktile.plugins.lucide import render_icon
|
|
201
202
|
name = e.attrs.get("name", e.content)
|
|
202
203
|
role = e.attrs.get("role", "")
|
|
203
|
-
text = f"{_escape(name)}<br><span class=\"role\">{_escape(role)}</span>" if role else _escape(name)
|
|
204
|
+
text = f"{_escape(name)}<br><span class=\"role\">{_link_emails(_escape(role))}</span>" if role else _escape(name)
|
|
204
205
|
links = []
|
|
205
206
|
contact_icons = {"github": "git-fork", "twitter": "bird", "email": "mail", "website": "globe"}
|
|
206
207
|
for key in ("github", "twitter", "email", "linkedin", "website"):
|
|
@@ -260,6 +261,14 @@ def _render_mermaid(content: str, svg: str = "", sid: str = "") -> str:
|
|
|
260
261
|
return f'<pre class="mermaid-fallback"{sid}><code>{_escape(content)}</code></pre>'
|
|
261
262
|
|
|
262
263
|
|
|
264
|
+
_EMAIL_RX = re.compile(r"(?<![\w.@/:])([\w.+-]+@[\w-]+(?:\.[\w-]+)+)(?![\w@])")
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _link_emails(escaped: str) -> str:
|
|
268
|
+
"""Wrap bare email addresses in already-escaped text with mailto links."""
|
|
269
|
+
return _EMAIL_RX.sub(r'<a href="mailto:\1">\1</a>', escaped)
|
|
270
|
+
|
|
271
|
+
|
|
263
272
|
def _render_pdg_html(content: str, svg: str = "", sid: str = "", live: str = "") -> str:
|
|
264
273
|
if svg and live:
|
|
265
274
|
# animated on screen, still frame in print/PDF (and for the ODP geometry pass)
|
|
@@ -13,7 +13,7 @@ from typing import Any
|
|
|
13
13
|
from decktile.parser.ast import (
|
|
14
14
|
Document, Slide, Heading, Paragraph, CodeBlock, Grid, Card,
|
|
15
15
|
Table, Quote, ListNode, AttrNode, Text, Strong, Emphasis,
|
|
16
|
-
Strikethrough, CodeSpan, Image, SoftBreak, LucideIcon, Arrow, Notes, Row,
|
|
16
|
+
Strikethrough, CodeSpan, Image, SoftBreak, LucideIcon, Link, Arrow, Notes, Row,
|
|
17
17
|
)
|
|
18
18
|
from decktile.plugins.layouts import KNOWN_LAYOUTS
|
|
19
19
|
from decktile.theme.parser import parse_theme
|
|
@@ -512,6 +512,8 @@ def _render_inline_html(nodes: list) -> str:
|
|
|
512
512
|
s += f'<img src="{_escape(n.src)}" alt="{_escape(n.alt)}" decoding="async"{title}>'
|
|
513
513
|
elif isinstance(n, SoftBreak):
|
|
514
514
|
s += " "
|
|
515
|
+
elif isinstance(n, Link):
|
|
516
|
+
s += f'<a href="{_escape(n.href)}">{_render_inline_html(n.children)}</a>'
|
|
515
517
|
elif isinstance(n, LucideIcon):
|
|
516
518
|
s += _render_lucide_inline(n.name, n.attrs)
|
|
517
519
|
return s
|
|
@@ -529,7 +531,7 @@ def _render_inline_text(nodes: list) -> str:
|
|
|
529
531
|
for n in nodes:
|
|
530
532
|
if isinstance(n, Text):
|
|
531
533
|
s += n.content
|
|
532
|
-
elif isinstance(n, (Strong, Emphasis, Strikethrough)):
|
|
534
|
+
elif isinstance(n, (Strong, Emphasis, Strikethrough, Link)):
|
|
533
535
|
s += _render_inline_text(n.children)
|
|
534
536
|
elif isinstance(n, CodeSpan):
|
|
535
537
|
s += n.content
|
|
@@ -39,7 +39,7 @@ def _title_html(md: str) -> str:
|
|
|
39
39
|
from decktile.parser.markdown import parse
|
|
40
40
|
from decktile.render.html import _render_slide
|
|
41
41
|
from decktile.render.ir import build_ir
|
|
42
|
-
return _render_slide(build_ir(parse(md))[0])
|
|
42
|
+
return _render_slide(build_ir(parse(md), base_css(), default_theme())[0])
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
def test_contributor_renders_labelled_and_distinct_from_speaker():
|
|
@@ -186,3 +186,30 @@ def test_render_subtitle_inline_markdown():
|
|
|
186
186
|
subtitle = html.split('<p class="subtitle"', 1)[1].split("</p>", 1)[0]
|
|
187
187
|
assert "<code>nvidia.com/gpu</code>" in subtitle
|
|
188
188
|
assert "`" not in subtitle
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_bare_emails_and_urls_become_links():
|
|
192
|
+
from decktile.parser.markdown import parse
|
|
193
|
+
from decktile.render.html import _render_elem
|
|
194
|
+
from decktile.render.ir import build_ir
|
|
195
|
+
|
|
196
|
+
md = "## S\n\nMail reza@dynamia.ai or https://decktile.github.io\n\n- in a list reza@dynamia.ai\n"
|
|
197
|
+
html = "".join(_render_elem(e) for e in build_ir(parse(md), base_css(), default_theme())[0].elements)
|
|
198
|
+
assert '<a href="mailto:reza@dynamia.ai">reza@dynamia.ai</a>' in html
|
|
199
|
+
assert '<a href="https://decktile.github.io">https://decktile.github.io</a>' in html
|
|
200
|
+
assert html.count("mailto:") == 2
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def test_markdown_link_keeps_its_text():
|
|
204
|
+
from decktile.parser.markdown import parse
|
|
205
|
+
from decktile.render.html import _render_elem
|
|
206
|
+
from decktile.render.ir import build_ir
|
|
207
|
+
|
|
208
|
+
html = "".join(_render_elem(e) for e in build_ir(parse("## S\n\nSee [the docs](https://x.io/d)\n"), base_css(), default_theme())[0].elements)
|
|
209
|
+
assert '<a href="https://x.io/d">the docs</a>' in html
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_email_in_speaker_role_is_a_link():
|
|
213
|
+
from decktile.render.html import _link_emails
|
|
214
|
+
assert _link_emails("Mail reza@dynamia.ai now") == 'Mail <a href="mailto:reza@dynamia.ai">reza@dynamia.ai</a> now'
|
|
215
|
+
assert _link_emails("https://x.io/a@b") == "https://x.io/a@b"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|