def test_parse_block_html(self): ret = mistune.markdown('<div>**foo**</div>', parse_block_html=True, escape=False) self.assertIn('<div><strong>', ret, 'success') ret = mistune.markdown('<span>**foo**</span>', parse_block_html=True, escape=False) self.assertIsNot('<strong>', ret, 'success')
def test_use_xhtml(self): ret = mistune.markdown('foo\n\n----\n\nbar') self.assertIn('<hr>', ret, 'success') ret = mistune.markdown('foo\n\n----\n\nbar', use_xhtml=True) self.assertIn('<hr />', ret, 'success') ret = mistune.markdown('foo \nbar', use_xhtml=True) self.assertIn('<br />', ret, 'success') ret = mistune.markdown('![foo](bar "title")', use_xhtml=True) self.assertIn('<img src="bar" alt="foo" title="title" />', ret, 'success')
def test_parse_inline_html(self): ret = mistune.markdown('<div>**foo**</div>', parse_inline_html=True, escape=False) self.assertIsNot('<strong>', ret, 'success') ret = mistune.markdown('<span>**foo**</span>', parse_inline_html=True, escape=False) self.assertIn('<span><strong>', ret, 'success') ret = mistune.markdown('<a>http://lepture.com</a>', parse_inline_html=True, escape=False) self.assertIsNot('href', ret, 'sucess')
def getBuff(): lineNum, curLineNum = 0, vim.current.window.cursor[0] - 1 # markdown_lib._print(curLineNum) buff = '' for line in vim.current.buffer: if lineNum == curLineNum: if line.startswith("```") or line.startswith('===') or line.startswith("---") or line == "": buff += line + '\n{ANCHOR}\n' else: buff += line + '{ANCHOR}\n' else: buff += line + '\n' lineNum = lineNum + 1 buff = markdown_parser.markdown(buff) buff = buff.replace('{ANCHOR}', '<a id="anchor"></a>') return buff
def getBuff(): buff = '' for line in vim.current.buffer: buff += line + '\n' buff = markdown_parser.markdown(buff) return buff
def test_not_escape_inline_tags(self): text = '<a name="top"></a>' self.assertIn(text, mistune.markdown(text, escape=False), 'success')
def test_not_escape_block_tags(self): text = '<h1>heading</h1> text' self.assertIn(text, mistune.markdown(text, escape=False), 'success')
def test_skip_style(self): ret = mistune.markdown('foo\n<style>body{color:red}</style>', skip_style=True) self.assertEqual(ret, '<p>foo</p>\n', 'success')
def test_linebreak(self): ret = mistune.markdown('this **foo** \nis me') self.assertIsNot('<br>', ret, 'success') ret = mistune.markdown('this **foo** \nis me', hard_wrap=True) self.assertIn('<br>', ret, 'success')
def test_escape(self): ret = mistune.markdown('<div>**foo**</div>', escape=True) self.assertIn('>', ret, 'success') ret = mistune.markdown('this **foo** is <b>bold</b>', escape=True) self.assertIn('>', ret, 'success')