h1 and h2 tag conversion

This commit is contained in:
Matthew Tretter
2012-06-29 12:20:02 -04:00
parent 36cb7f6ac1
commit c7cbe8a5b1
2 changed files with 19 additions and 0 deletions

View File

@@ -36,6 +36,16 @@ class MarkdownConverter(object):
node.clear()
node.text = text
def underline(self, text, pad_char):
text = (text or '').rstrip()
return '%s\n%s\n\n' % (text, pad_char * len(text)) if text else ''
def convert_h1(self, el):
return self.underline(el.text, '=')
def convert_h2(self, el):
return self.underline(el.text, '-')
def markdownify(html, strip=None, keep=None):
converter = MarkdownConverter(strip, keep)