diff --git a/CrossDown.py b/CrossDown.py index 031941c..397cb54 100644 --- a/CrossDown.py +++ b/CrossDown.py @@ -3,8 +3,6 @@ import re import markdown -import MarkDown - class Header: def __init__(self, text: str): diff --git a/MarkDown.py b/MarkDown.py deleted file mode 100644 index 1cea752..0000000 --- a/MarkDown.py +++ /dev/null @@ -1,7 +0,0 @@ -import markdown - - -with open('README.md', encoding='utf-8') as text: - html = markdown.markdown(text.read(), extensions=['markdown.extensions.extra']) - print(html) - diff --git a/Output.md b/Output.md deleted file mode 100644 index 82b81e4..0000000 --- a/Output.md +++ /dev/null @@ -1,87 +0,0 @@ - - -
- - -值 锚点名
-\(CO^2\)
-
- A:
- 1. a
- 2. b
- 3. c
- B:
- - a
- - b
- - c
-
-
- print('CrossDown')
-
- \\
-渲染引用
This is a paragraph.
\n" + self.assert_conversion(markdown_text, expected_html) + + def test_bold_and_italic_conversion(self): + markdown_text = "**Bold** and *Italic*" + expected_html = "Bold and Italic
\n" + self.assert_conversion(markdown_text, expected_html) + + def test_list_conversion(self): + markdown_text = """ + - Item 1 + - Item 2 + - Item 3 + """ + expected_html = """ +print('Hello, World!')
+
\n
+ """ # 注意:实际输出可能包含额外的空白或换行符,这取决于markdown库的处理方式
+ self.assert_conversion(markdown_text, expected_html)
+
+
+def test_link_conversion(self):
+ markdown_text = "[Google](https://www.google.com)"
+ expected_html = '\n'
+ self.assert_conversion(markdown_text, expected_html)
+
+
+def test_image_conversion(self):
+ markdown_text = "![Alt Text](https://www.example.com/image.jpg)"
+ expected_html = '\n'
+ self.assert_conversion(markdown_text, expected_html)
+
+
+def test_blockquote_conversion(self):
+ markdown_text = "> This is a quote."
+ expected_html = '\n\n' + self.assert_conversion(markdown_text, expected_html) + + +def assert_conversion(self, markdown_text, expected_html): + converted_html = convert_markdown_to_html(markdown_text) + # 使用replace方法去除不必要的空白字符,以便更灵活地比较输出 + self.assertEqual(converted_html.replace('\n', '').replace('\r', ''), + expected_html.replace('\n', '').replace('\r', '')) + + +if __name__ == '__main__': + unittest.main()This is a quote.
\n