mirror of
https://github.com/caronc/apprise.git
synced 2025-12-15 10:04:06 +08:00
fix(telegram): support <code> blocks wrapped in <pre> for syntax highlighting (#1423)
This commit is contained in:
@@ -307,19 +307,6 @@ class NotifyTelegram(NotifyBase):
|
||||
" -",
|
||||
{},
|
||||
),
|
||||
# convert pre tags to code (supported by Telegram)
|
||||
(
|
||||
re.compile(r"<\s*pre([^a-z0-9>][^>]*)?>", (re.I | re.M | re.S)),
|
||||
"{}<code>",
|
||||
{"html": "\r\n"},
|
||||
),
|
||||
(
|
||||
re.compile(
|
||||
r"<\s*/\s*pre([^a-z0-9>][^>]*)?>", (re.I | re.M | re.S)
|
||||
),
|
||||
"</code>{}",
|
||||
{"html": "\r\n"},
|
||||
),
|
||||
# New Lines
|
||||
(
|
||||
re.compile(
|
||||
|
||||
@@ -1404,7 +1404,8 @@ def test_plugin_telegram_html_formatting(mock_post):
|
||||
== "\r\n<b>Bootstrap 101 Template</b>\r\n<b>My Title</b>\r\n"
|
||||
"<b>Heading 1</b>\r\n-Bullet 1\r\n-Bullet 2\r\n-Bullet 3\r\n"
|
||||
"-Bullet 1\r\n-Bullet 2\r\n-Bullet 3\r\n<b>Heading 2</b>\r\n"
|
||||
"A div entry\r\nA div entry\r\n<code>A pre entry</code>\r\n"
|
||||
"A div entry\r\nA div entry\r\n"
|
||||
"<pre><code class=\"language-python\">print('hello')</code></pre>\r\n"
|
||||
"<b>Heading 3</b>\r\n<b>Heading 4</b>\r\n<b>Heading 5</b>\r\n"
|
||||
"<b>Heading 6</b>\r\nA set of text\r\n"
|
||||
"Another line after the set of text\r\nMore text\r\nlabel"
|
||||
|
||||
@@ -44,9 +44,10 @@
|
||||
<div>A div entry</div>
|
||||
<p>
|
||||
<span>A div entry</span>
|
||||
<pre>A pre entry</pre>
|
||||
</p>
|
||||
|
||||
<pre><code class="language-python">print('hello')</code></pre>
|
||||
|
||||
<h3>Heading 3</h3>
|
||||
<h4>Heading 4</h4>
|
||||
<h5>Heading 5</h5>
|
||||
|
||||
Reference in New Issue
Block a user