Skip to content

Commit 3466061

Browse files
committed
prevent <hn> to call convert_hn and crash
fixes #142
1 parent 9595618 commit 3466061

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: markdownify/__init__.py

+3-2
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,7 +311,8 @@ 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

Diff for: tests/test_conversions.py

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def test_hn():
134134
assert md('<h5>Hello</h5>') == '\n##### Hello\n\n'
135135
assert md('<h6>Hello</h6>') == '\n###### Hello\n\n'
136136
assert md('<h10>Hello</h10>') == md('<h6>Hello</h6>')
137+
assert md('<hn>Hello</hn>') == md('Hello')
137138

138139

139140
def test_hn_chained():

0 commit comments

Comments
 (0)