commit - ae087ef0d33ca1fd2aa0edb03a608bedee511501
commit + 57410cb213c1c2c1eec51cdb8e6ff4e4e83ccabc
blob - eb13d14bcd95f211d073eeb86e48d0d1a432961e
blob + d81889edf9b17d96840d87ac3d7a910974a2c4f9
--- .gitignore
+++ .gitignore
**/*.swp
.local/
+__pycache__/
blob - /dev/null
blob + 1421ebd352620245cec8ef55ee9c7bc465266d83 (mode 644)
--- /dev/null
+++ tests.py
+from lonk import HtmlToGmi
+
+
+def test_html2gmi_header():
+ html = """\
+<h1>Header 1</h1>
+<p>Paragraph 1</p>
+<h2>Header 1.1</h2>
+<p>Paragraph 1.1</p>
+"""
+ gmi = HtmlToGmi().feed(html)
+ assert gmi == """\
+# Header 1
+
+Paragraph 1
+
+## Header 1.1
+
+Paragraph 1.1
+""", gmi
+
+
+def test_html2gmi_pre():
+ html = """\
+<pre>
+def fib(n):
+ if n == 1 or n == 2:
+ return 1
+ return fib(n - 1) + fib(n - 1)
+</pre>
+"""
+ gmi = HtmlToGmi().feed(html)
+ assert gmi == """\
+```
+
+def fib(n):
+ if n == 1 or n == 2:
+ return 1
+ return fib(n - 1) + fib(n - 1)
+
+```
+""", gmi
+
+
+def test_html2gmi_description_list():
+ html = """\
+<dl>
+ <dt>Coffee</dt>
+ <dd>Black hot drink</dd>
+ <dt>Milk</dt>
+ <dd>White cold drink</dd>
+</dl>
+"""
+ gmi = HtmlToGmi().feed(html)
+ assert gmi == """\
+* Coffee
+
+Black hot drink
+
+* Milk
+
+White cold drink
+""", gmi
+
+
+if __name__ == '__main__':
+ TESTS = (
+ test_html2gmi_header,
+ test_html2gmi_pre,
+ test_html2gmi_description_list,
+ )
+ for func in TESTS:
+ print(f"{func.__name__} ... ", end="")
+ func()
+ print("PASSED")