Skip to content

Commit 8f70e39

Browse files
committed
Merge branch 'develop'
2 parents e935ce8 + 6258f5c commit 8f70e39

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

markdownify/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def __getattr__(self, attr):
213213
n = int(m.group(1))
214214

215215
def convert_tag(el, text, convert_as_inline):
216-
return self.convert_hn(n, el, text, convert_as_inline)
216+
return self._convert_hn(n, el, text, convert_as_inline)
217217

218218
convert_tag.__name__ = 'convert_h%s' % n
219219
setattr(self, convert_tag.__name__, convert_tag)
@@ -311,10 +311,14 @@ def convert_code(self, el, text, convert_as_inline):
311311

312312
convert_kbd = convert_code
313313

314-
def convert_hn(self, n, el, text, convert_as_inline):
314+
def _convert_hn(self, n, el, text, convert_as_inline):
315+
""" Method name prefixed with _ to prevent <hn> to call this """
315316
if convert_as_inline:
316317
return text
317318

319+
# prevent MemoryErrors in case of very large n
320+
n = max(1, min(6, n))
321+
318322
style = self.options['heading_style'].lower()
319323
text = text.strip()
320324
if style == UNDERLINED and n <= 2:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "markdownify"
7-
version = "0.14.0"
7+
version = "0.14.1"
88
authors = [{name = "Matthew Tretter", email = "[email protected]"}]
99
description = "Convert HTML to markdown."
1010
readme = "README.rst"

tests/test_conversions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def test_hn():
133133
assert md('<h4>Hello</h4>') == '\n#### Hello\n\n'
134134
assert md('<h5>Hello</h5>') == '\n##### Hello\n\n'
135135
assert md('<h6>Hello</h6>') == '\n###### Hello\n\n'
136+
assert md('<h10>Hello</h10>') == md('<h6>Hello</h6>')
137+
assert md('<hn>Hello</hn>') == md('Hello')
136138

137139

138140
def test_hn_chained():

0 commit comments

Comments
 (0)