def test_basic_markdown(self): md = """~~strike~~ **bold** _italic_ `code` [link](asana.com)""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, '<s>strike</s> <strong>bold</strong> <em>italic</em> <code>code</code> <a href="asana.com">link</a>\n', )
def test_auto_linking(self): md = "https://asana.com/ [still works](www.test.com)" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, '<a href="https://asana.com/">https://asana.com/</a> <a href="www.test.com">still works</a>\n', )
def test_ol_tag(self): md = """1. bullet one\n2. bullet two""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, """<ol>\n<li>bullet one</li>\n<li>bullet two</li>\n</ol>\n""", )
def test_escapes_raw_html_mixed_with_markdown(self): md = """## <img href="link" />still here <h3>header</h3>""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, "\n<b>" + escape('<img href="link" />') + "still here " + escape("<h3>header</h3>") + "</b>\n", )
def test_escapes_raw_html(self): md = """<img href="link" />still here <h3>header</h3>""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, escape('<img href="link" />') + "still here " + escape("<h3>header</h3>\n"), )
def test_removes_pre_tags_block(self): md = """see: ``` function foo = () => null; ``` """ xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, "see:\n<code>function foo = () => null;\n</code>\n")
def test_escapes_raw_html_on_own_lines(self): md = """## blah blah blah <img href="link"> still here <h3>header</h3>""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual( xml, "\n<b>blah blah blah</b>\n" + escape('<img href="link">\n') + "still here " + escape("<h3>header</h3>"), )
def test_removes_pre_tags_inline(self): md = """```test```""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, "<code>test</code>\n")
def test_nested_code_within_block_quote(self): md = "> abc `123`" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, "<em>> abc <code>123</code>\n</em>")
def test_converts_headings_to_bold(self): md = "## heading" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, "\n<b>heading</b>\n")
def test_horizontal_rule(self): # Asana doesn't support <hr /> tags, so we just ignore them md = "hello\n\n---\nworld\n" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, md) # unchanged
def test_block_quote(self): md = "> block quote" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, "<em>> block quote\n</em>")
def test_paragraph(self): md = "we don't wrap random text in p tags" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(md + "\n", xml)
def test_removes_images(self): md = """![image](https://image.com)""" xml = convert_github_markdown_to_asana_xml(md) self.assertEqual(xml, '<a href="https://image.com">image</a>\n')
def _format_github_text_for_asana(text: str) -> str: return _transform_github_mentions_to_asana_mentions( convert_github_markdown_to_asana_xml(text))