prevent very large headline prefixes
for example: `<h9999999>` could crash the conversion. fixes #143
This commit is contained in:
@@ -315,6 +315,9 @@ class MarkdownConverter(object):
|
||||
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:
|
||||
|
||||
@@ -133,6 +133,7 @@ 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>')
|
||||
|
||||
|
||||
def test_hn_chained():
|
||||
|
||||
Reference in New Issue
Block a user