diff --git a/tests/test_custom_filter.py b/tests/test_custom_filter.py
index da75dfa..c56062a 100644
--- a/tests/test_custom_filter.py
+++ b/tests/test_custom_filter.py
@@ -4,7 +4,7 @@ import tempfile
from reader import Reader
-from discord_rss_bot.custom_filters import convert_to_md, encode_url, entry_is_blacklisted, entry_is_whitelisted
+from discord_rss_bot.custom_filters import encode_url, entry_is_blacklisted, entry_is_whitelisted
from discord_rss_bot.settings import get_reader
@@ -104,30 +104,3 @@ def test_entry_is_blacklisted() -> None:
# Close the reader, so we can delete the directory.
custom_reader.close()
-
-
-def test_convert_to_md():
- # Test normal input
- assert (
- convert_to_md("
Headline
Subheadline
subsubheadline
")
- == """Headline
-========
-
-Subheadline
------------
-
-### subsubheadline
-
-"""
- )
- # Test input with tables
- assert (
- convert_to_md(
- "Column 1 | Column 2 | Column 3 |
---|
Row 1, Column 1 | Row 1, Column 2 | Row 1, Column 3 |
Row 2, Column 1 | Row 2, Column 2 | Row 2, Column 3 |
" # noqa: E501
- )
- == "Column 1Column 2Column 3Row 1, Column 1Row 1, Column 2Row 1, Column 3Row 2, Column 1Row 2, Column 2Row 2, Column 3" # noqa: E501
- )
- # Test empty input
- assert convert_to_md("") == ""
- # Test input as None
- assert convert_to_md(None) == "" # type: ignore
diff --git a/tests/test_markdown.py b/tests/test_markdown.py
new file mode 100644
index 0000000..4020316
--- /dev/null
+++ b/tests/test_markdown.py
@@ -0,0 +1,62 @@
+from discord_rss_bot.markdown import convert_html_to_md
+
+
+def test_convert_to_md():
+ # Test bold
+ assert convert_html_to_md("bold") == "**bold**"
+
+ # Test italic
+ assert convert_html_to_md("italic") == "*italic*"
+
+ # Test blockquote
+ assert convert_html_to_md("blockquote
") == ">>> blockquote"
+
+ # Test code
+ assert convert_html_to_md("code
") == "`code`"
+
+ # Test strikethrough
+ assert convert_html_to_md("strikethrough") == "~~strikethrough~~"
+
+ # Test link
+ assert convert_html_to_md('link') == "[link](https://example.com)"
+
+ # Test pre code
+ assert convert_html_to_md("pre code
") == "``pre code``"
+
+ # Test strong
+ assert convert_html_to_md("strong") == "**strong**"
+
+ # Test multiple tags
+ assert (
+ convert_html_to_md(
+ 'bold italic link code
strikethrough'
+ )
+ == "**bold** *italic* [link](https://example.com) `code` ~~strikethrough~~"
+ )
+
+ # Test removing all other tags
+ assert convert_html_to_md("paragraph
") == "paragraph"
+ assert convert_html_to_md("paragraph
paragraph
") == "paragraphparagraph"
+
+ # Test
tags
+ assert (
+ convert_html_to_md("paragraph
paragraph
")
+ == """paragraph
+paragraph"""
+ )
+
+ # Test removing trailing newline
+ assert convert_html_to_md("paragraph ") == "paragraph"
+
+ # Test removing leading and trailing whitespace
+ assert convert_html_to_md(" paragraph ") == "paragraph"
+
+ # Test removing leading and trailing whitespace and trailing newline
+ assert (
+ convert_html_to_md(
+ """ paragraph
+
+ """ # noqa: W293
+ )
+ == "paragraph"
+ )