markdown
markdown
Markdown to HTML conversion and RawHTML utilities.
Classes:
-
RawHTML–String subclass that bypasses markdown-to-HTML conversion.
markdown.RawHTML
Bases: str
String subclass that bypasses markdown-to-HTML conversion.
Use this to pass pre-formatted HTML directly to tooltip or popup
parameters on any add_* method.
Examples:
>>> from mapyta.markdown import RawHTML
>>> html = RawHTML("<b>Bold</b> and <em>italic</em>")
>>> m.add_point(Point(4.9, 52.37), tooltip=html)
markdown.escape_text
escape_text(value: str | RawHTML) -> str
Escape a plain string, or pass :class:RawHTML through verbatim.
The counterpart to :func:render_text for labels that take no Markdown — legend
captions and swatch labels. Escaping keeps untrusted text from becoming active
markup while :class:RawHTML still opts into inline markup such as <sub>.
Source code in mapyta/markdown.py
88 89 90 91 92 93 94 95 | |
markdown.markdown_to_html
markdown_to_html(md_text: str) -> str
Convert a subset of Markdown to HTML for popups/tooltips.
Supports **bold**, *italic*, backtick code, [links](url),
headers (# - ###), and unordered lists (- item).
Parameters:
-
md_text(str) –Markdown-formatted string.
Returns:
-
str–HTML string.
Source code in mapyta/markdown.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
markdown.render_text
render_text(value: str | RawHTML) -> str
Convert a plain string from Markdown, or pass :class:RawHTML through verbatim.
Source code in mapyta/markdown.py
83 84 85 | |
markdown.sanitize_href
sanitize_href(url: str) -> str
Allow only safe URL schemes (http, https, mailto). Returns # otherwise.
Source code in mapyta/markdown.py
21 22 23 24 | |