Skip to content

Commit 8cda560

Browse files
committed
make convert_hn() public instead of internal
Signed-off-by: chrispy <[email protected]>
1 parent 13183f9 commit 8cda560

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

markdownify/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,11 @@ def get_conv_fn(self, tag_name):
362362
if not self.should_convert_tag(tag_name):
363363
return None
364364

365-
# Handle headings with _convert_hn() function
365+
# Handle headings with convert_hn() function
366366
match = re_html_heading.match(tag_name)
367367
if match:
368368
n = int(match.group(1))
369-
return lambda el, text, parent_tags: self._convert_hn(n, el, text, parent_tags)
369+
return lambda el, text, parent_tags: self.convert_hn(n, el, text, parent_tags)
370370

371371
# For other tags, look up their conversion function by tag name
372372
convert_fn_name = "convert_%s" % re_make_convert_fn_name.sub('_', tag_name)
@@ -509,12 +509,12 @@ def convert_dt(self, el, text, parent_tags):
509509

510510
return '\n\n%s\n' % text
511511

512-
def _convert_hn(self, n, el, text, parent_tags):
513-
""" Method name prefixed with _ to prevent <hn> to call this """
512+
def convert_hn(self, n, el, text, parent_tags):
513+
# convert_hn() converts <h#> tags, where # is any integer
514514
if '_inline' in parent_tags:
515515
return text
516516

517-
# prevent MemoryErrors in case of very large n
517+
# Markdown does not support heading depths of n > 6
518518
n = max(1, min(6, n))
519519

520520
style = self.options['heading_style'].lower()

tests/test_conversions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ def test_hn():
164164
assert md('<h5>Hello</h5>') == '\n\n##### Hello\n\n'
165165
assert md('<h6>Hello</h6>') == '\n\n###### Hello\n\n'
166166
assert md('<h10>Hello</h10>') == md('<h6>Hello</h6>')
167-
assert md('<hn>Hello</hn>') == md('Hello')
167+
assert md('<h0>Hello</h0>') == md('<h1>Hello</h1>')
168+
assert md('<hx>Hello</hx>') == md('Hello')
168169

169170

170171
def test_hn_chained():

0 commit comments

Comments
 (0)