def test_nested_uls(self): """ Nested ULs should alternate bullet characters. """ self.assertTrue( html_to_jira_wiki(nested_uls) == '* 1\n\t+ a\n\t\t- I\n\t\t- II\n\t\t- III\n\t\t\n\t+ b\n\t+ c\n\t\n* 2\n* 3\n' )
def test_p(self): self.assertTrue(html_to_jira_wiki('<p>hello</p>') == 'hello\n\n')
def test_h2(self): self.assertTrue(html_to_jira_wiki('<h2>Hello</h2>') == 'h2. Hello\n')
def test_em(self): self.assertTrue(html_to_jira_wiki('<em>Hello</em>') == '_Hello_')
def test_nested_blockquote(self): text = html_to_jira_wiki('<blockquote>And she was like <blockquote>Hello</blockquote></blockquote>').strip() self.assertTrue(text == '> And she was like \n> > Hello')
def test_b(self): self.assertTrue(html_to_jira_wiki('<b>Hello</b>') == '*Hello*')
def test_a_shortcut(self): text = html_to_jira_wiki('<a href="http://google.com">http://google.com</a>') self.assertTrue(text == '<http://google.com>')
def test_a(self): self.assertTrue(html_to_jira_wiki('<a href="http://google.com">Google</a>') == '[Google](http://google.com)')
def test_xml_entities(self): self.assertTrue(html_to_jira_wiki('&') == '&')
def test_underscore(self): self.assertTrue(html_to_jira_wiki('_hey_dude_') == '\_hey\_dude\_')
def test_img(self): self.assertTrue(html_to_jira_wiki( '<img src="/path/to/img.jpg" alt="Alt text" title="Optional title" />') == '![Alt text](/path/to/img.jpg ' '"Optional title")') self.assertTrue(html_to_jira_wiki('<img src="/path/to/img.jpg" alt="Alt text" />') == '![Alt text](' '/path/to/img.jpg)')
def test_bullets(self): self.assertTrue( html_to_jira_wiki(nested_uls, bullets='-') == '- 1\n\t- a\n\t\t- I\n\t\t- II\n\t\t- III\n\t\t\n\t- b\n\t- c\n\t\n- 2\n- 3\n' )
def test_ul(self): self.assertTrue(html_to_jira_wiki('<ul><li>a</li><li>b</li></ul>') == '* a\n* b\n')
def test_strong(self): self.assertTrue(html_to_jira_wiki('<strong>Hello</strong>') == '*Hello*')
def test_soup(self): self.assertTrue(html_to_jira_wiki('<div><span>Hello</div></span>') == 'Hello')
def test_named_entities(self): self.assertTrue(html_to_jira_wiki('»') == u'\xbb')
def test_whitespace(self): self.assertTrue(html_to_jira_wiki(' a b \n\n c ') == ' a b c ')
def test_hexadecimal_entities(self): # This looks to be a bug in BeautifulSoup (fixed in bs4) that we have to work around. self.assertTrue(html_to_jira_wiki(''') == '\x27')
def test_a_with_title(self): text = html_to_jira_wiki('<a href="http://google.com" title="The "Goog"">Google</a>') self.assertTrue(text == r'[Google](http://google.com "The \"Goog\"")')
def test_single_escaping_entities(self): self.assertTrue(html_to_jira_wiki('&amp;') == '&')
def test_a_no_autolinks(self): text = html_to_jira_wiki('<a href="http://google.com">http://google.com</a>', autolinks=False) self.assertTrue(text == '[http://google.com](http://google.com)')
def test_nested(self): text = html_to_jira_wiki('<p>This is an <a href="http://example.com/">example link</a>.</p>') self.assertTrue(text == 'This is an [example link](http://example.com/).\n\n')
def test_blockquote(self): self.assertTrue(html_to_jira_wiki('<blockquote>Hello</blockquote>').strip() == '> Hello')
def test_do_not_strip(self): text = html_to_jira_wiki('<a href="https://github.com/matthewwithanm">Some Text</a>', strip=[]) self.assertTrue(text == '[Some Text](https://github.com/matthewwithanm)')
def test_br(self): self.assertTrue(html_to_jira_wiki('a<br />b<br />c') == 'a \nb \nc')
def test_do_not_convert(self): text = html_to_jira_wiki('<a href="https://github.com/matthewwithanm">Some Text</a>', convert=[]) self.assertTrue(text == 'Some Text')
def test_h1(self): self.assertTrue(html_to_jira_wiki('<h1>Hello</h1>') == 'h1. Hello\n')
def test_single_tag(self): self.assertTrue(html_to_jira_wiki('<span>Hello</span>') == 'Hello')
def test_hn(self): self.assertTrue(html_to_jira_wiki('<h3>Hello</h3>') == 'h3. Hello\n') self.assertTrue(html_to_jira_wiki('<h6>Hello</h6>') == 'h6. Hello\n')
def test_ol(self): self.assertTrue(html_to_jira_wiki('<ol><li>a</li><li>b</li></ol>') == '1. a\n2. b\n')