a tag conversion
This commit is contained in:
@@ -67,6 +67,10 @@ class MarkdownConverter(object):
|
||||
text = (text or '').rstrip()
|
||||
return '%s\n%s\n\n' % (text, pad_char * len(text)) if text else ''
|
||||
|
||||
def convert_a(self, el):
|
||||
href = el.get('href')
|
||||
return '[%s](%s)' % (el.text or '', href) if href else el.text or ''
|
||||
|
||||
def convert_b(self, el):
|
||||
return self.convert_strong(el)
|
||||
|
||||
|
||||
6
tests.py
6
tests.py
@@ -19,6 +19,12 @@ class EscapeTests(unittest.TestCase):
|
||||
|
||||
class ConversionTests(unittest.TestCase):
|
||||
|
||||
def test_a(self):
|
||||
self.assertEqual(
|
||||
md('<a href="http://google.com">Google</a>'),
|
||||
'[Google](http://google.com)'
|
||||
)
|
||||
|
||||
def test_b(self):
|
||||
self.assertEqual(md('<b>Hello</b>'), '**Hello**')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user