def test_not_use_directory_urls(self): md_text = 'An [internal link](internal.md) to another document.' expected = '<p>An <a href="internal/index.html">internal link</a> to another document.</p>' pages = [ ('internal.md',) ] site_navigation = nav.SiteNavigation(pages, use_directory_urls=False) html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html, site_navigation) self.assertEqual(html.strip(), expected.strip())
def test_anchor_only_link(self): pages = [ ('index.md',), ('internal.md',), ('sub/internal.md') ] site_navigation = nav.SiteNavigation(pages) for page in site_navigation.walk_pages(): html = '<p><a href="#test"> </a></p>' result = build.post_process_html(html, site_navigation) self.assertEqual(result, html)
def test_convert_internal_media(self): pages = [ ('index.md',), ('internal.md',), ('sub/internal.md') ] site_navigation = nav.SiteNavigation(pages) expected_results = ( '<p><img alt="The initial MkDocs layout" src="./img/initial-layout.png" /></p>', '<p><img alt="The initial MkDocs layout" src="../img/initial-layout.png" /></p>', '<p><img alt="The initial MkDocs layout" src="../../img/initial-layout.png" /></p>', ) for (page, expected) in zip(site_navigation.walk_pages(), expected_results): html = '<p><img alt="The initial MkDocs layout" src="img/initial-layout.png" /></p>' html = build.post_process_html(html, site_navigation) self.assertEqual(html, expected)
def test_ignore_external_link(self): md_text = 'An [external link](http://example.com/external.md).' expected = '<p>An <a href="http://example.com/external.md">external link</a>.</p>' html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html) self.assertEqual(html.strip(), expected.strip())
def test_convert_internal_link_with_anchor(self): md_text = 'An [internal link](internal.md#section1.1) to another document.' expected = '<p>An <a href="internal/#section1.1">internal link</a> to another document.</p>' html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html) self.assertEqual(html.strip(), expected.strip())
def test_convert_internal_link_differing_directory(self): md_text = 'An [internal link](../internal.md) to another document.' expected = '<p>An <a href="../internal/">internal link</a> to another document.</p>' html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html) self.assertEqual(html.strip(), expected.strip())
def test_convert_multiple_internal_links(self): md_text = '[First link](first.md) [second link](second.md).' expected = '<p><a href="first/">First link</a> <a href="second/">second link</a>.</p>' html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html) self.assertEqual(html.strip(), expected.strip())
def test_convert_internal_link(self): md_text = 'An [internal link](internal.md) to another document.' expected = '<p>An <a href="internal/">internal link</a> to another document.</p>' html, toc, meta = build.convert_markdown(md_text) html = build.post_process_html(html) self.assertEqual(html.strip(), expected.strip())