Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f70e3952f | ||
|
|
6258f5c38b | ||
|
|
3466061ca9 | ||
|
|
9595618796 |
@@ -213,7 +213,7 @@ class MarkdownConverter(object):
|
||||
n = int(m.group(1))
|
||||
|
||||
def convert_tag(el, text, convert_as_inline):
|
||||
return self.convert_hn(n, el, text, convert_as_inline)
|
||||
return self._convert_hn(n, el, text, convert_as_inline)
|
||||
|
||||
convert_tag.__name__ = 'convert_h%s' % n
|
||||
setattr(self, convert_tag.__name__, convert_tag)
|
||||
@@ -311,10 +311,14 @@ class MarkdownConverter(object):
|
||||
|
||||
convert_kbd = convert_code
|
||||
|
||||
def convert_hn(self, n, el, text, convert_as_inline):
|
||||
def _convert_hn(self, n, el, text, convert_as_inline):
|
||||
""" Method name prefixed with _ to prevent <hn> to call this """
|
||||
if convert_as_inline:
|
||||
return text
|
||||
|
||||
# prevent MemoryErrors in case of very large n
|
||||
n = max(1, min(6, n))
|
||||
|
||||
style = self.options['heading_style'].lower()
|
||||
text = text.strip()
|
||||
if style == UNDERLINED and n <= 2:
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "markdownify"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
authors = [{name = "Matthew Tretter", email = "m@tthewwithanm.com"}]
|
||||
description = "Convert HTML to markdown."
|
||||
readme = "README.rst"
|
||||
|
||||
@@ -133,6 +133,8 @@ def test_hn():
|
||||
assert md('<h4>Hello</h4>') == '\n#### Hello\n\n'
|
||||
assert md('<h5>Hello</h5>') == '\n##### Hello\n\n'
|
||||
assert md('<h6>Hello</h6>') == '\n###### Hello\n\n'
|
||||
assert md('<h10>Hello</h10>') == md('<h6>Hello</h6>')
|
||||
assert md('<hn>Hello</hn>') == md('Hello')
|
||||
|
||||
|
||||
def test_hn_chained():
|
||||
|
||||
Reference in New Issue
Block a user