Skip to main content

Module html

Module html 

Source
Expand description

Markdown → Telegram-supported HTML subset converter.

Ported from files.md (server/pkg/txt/md.go lines 262–432, str.go lines 122–170) by Artem Zakirullin.

Uses parser combinators (open/close/or/and/some) for inline markup. Supported tags: */_<i>, **/__<b>, `<code>, ```<pre>, #<b>.

Functions§

escape_html
Escape HTML special characters (&, <, >).
markdown_to_html
Convert markdown to Telegram-supported HTML subset.
replace_with_placeholders
Replace regex matches with placeholders, returning the modified string and a map of placeholder → original.
restore_from_placeholders
Restore placeholders back to their original values.
strip_html_tags
Strip all HTML tags from a string.