from unittest import TestCase, main from lonk import HtmlToGmi def fn_media_url(mime, img_url): return img_url class TestHtmlToGmi(TestCase): def test_br(self): html = '
head
tail
head https link tail
' self.assertEqual(HtmlToGmi("https://localhost/api", fn_media_url).feed(html), """\ head ↳ https link tail => https://localhost/sub1/1 https link """) def test_links_in_paragraph(self): html = 'head https link gemini link tail
' self.assertEqual(HtmlToGmi("", fn_media_url).feed(html), """\ head ↳ https link ↳ gemini link tail => https://127.0.0.1 https link => gemini://127.0.0.1 gemini link """) def test_in_text_tag(self): html = "bold text
" self.assertEqual(HtmlToGmi("", fn_media_url).feed(html), "bold text\n") def test_img_emu(self): html = "aa bb" self.assertEqual(HtmlToGmi("", fn_media_url).feed(html), "aa :blobcatgooglyshrug: bb\n") def test_html2gmi_header(self): html = """\Paragraph 1
Paragraph 1.1
""" self.assertEqual(HtmlToGmi("", fn_media_url).feed(html), """\ # Header 1 Paragraph 1 ## Header 1.1 Paragraph 1.1 """) def test_html2gmi_pre(self): html = """\def fib(n): if n == 1 or n == 2: return 1 return fib(n - 1) + fib(n - 1)""" self.assertEqual(HtmlToGmi("", fn_media_url).feed(html), """\ ``` def fib(n): if n == 1 or n == 2: return 1 return fib(n - 1) + fib(n - 1) ``` """) def test_html2gmi_description_list(self): html = """