From 29b81c8a564a051f50ce954ece4bf0f2bbae5ac4 Mon Sep 17 00:00:00 2001 From: matteo Date: Thu, 30 Apr 2020 15:41:54 +0200 Subject: [PATCH] added support for new html and markdown tags to the syntax detector --- botogram/syntaxes.py | 10 ++++++++-- docs/changelog/0.7.rst | 5 +++++ tests/test_syntaxes.py | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/botogram/syntaxes.py b/botogram/syntaxes.py index 4b74b48..4a0d519 100644 --- a/botogram/syntaxes.py +++ b/botogram/syntaxes.py @@ -28,7 +28,8 @@ r"_(.*)_|" r"\[(.*)\]\((.*)\)|" r"`(.*)`|" - r"```(.*)```" + r"```(.*)```|" + r"~(.*)~" r").*") _html_re = re.compile(r".*(" @@ -38,7 +39,12 @@ r"(.*)<\/em>|" r"(.*)<\/a>|" r"(.*)<\/code>|" - r"
(.*)<\/pre>"
+                      r"
(.*)<\/pre>|"
+                      r"(.*)<\/u>|"
+                      r"(.*)<\/ins>|"
+                      r"(.*)<\/s>|"
+                      r"(.*)<\/strike>|"
+                      r"(.*)<\/del>"
                       r").*")
 
 
diff --git a/docs/changelog/0.7.rst b/docs/changelog/0.7.rst
index 7555957..8e72717 100644
--- a/docs/changelog/0.7.rst
+++ b/docs/changelog/0.7.rst
@@ -77,6 +77,11 @@ New features
   * New argument ``vcard`` in :py:meth:`botogram.Message.reply_with_contact`
   * New attribute :py:attr:`Contact.vcard`
 
+Changes
+-------
+
+* added support for new html and markdown tags to the syntax detector
+
 Bug fixes
 ---------
 
diff --git a/tests/test_syntaxes.py b/tests/test_syntaxes.py
index 09df617..66342b1 100644
--- a/tests/test_syntaxes.py
+++ b/tests/test_syntaxes.py
@@ -27,7 +27,7 @@ def test_is_markdown():
     assert not botogram.syntaxes.is_markdown("not markdown, sorry!")
     assert not botogram.syntaxes.is_markdown("*a [wonderfully](broken syntax`")
 
-    for delimiter in "*", "_", "`", "```":
+    for delimiter in "*", "_", "`", "```", "~":
         assert botogram.syntaxes.is_markdown(delimiter+"a"+delimiter)
         assert botogram.syntaxes.is_markdown("!"+delimiter+"a"+delimiter+"!")
         assert botogram.syntaxes.is_markdown("a\n"+delimiter+"a"+delimiter)
@@ -47,7 +47,8 @@ def test_is_html():
     assert not botogram.syntaxes.is_html("not HTML, sorry!")
     assert not botogram.syntaxes.is_html(" roken html")
 
-    for tag in "b", "strong", "i", "em", "pre", "code":
+    for tag in "b", "strong", "i", "em", "code", "pre", "u", "ins", "s",\
+               "strike", "del":
         assert botogram.syntaxes.is_html("<"+tag+">a")
         assert botogram.syntaxes.is_html("!<"+tag+">a!")
         assert botogram.syntaxes.is_html("a\n<"+tag+">a")