Fix newline start in header tags (#89)

* Fix newline start in header tags
This commit is contained in:
Veronika Butkevich
2024-03-26 20:46:30 +01:00
committed by GitHub
parent a2f82678f7
commit f33ccd7c1a
2 changed files with 9 additions and 1 deletions

View File

@@ -265,7 +265,7 @@ class MarkdownConverter(object):
return text
style = self.options['heading_style'].lower()
text = text.rstrip()
text = text.strip()
if style == UNDERLINED and n <= 2:
line = '=' if n == 1 else '-'
return self.underline(text, line)

View File

@@ -90,6 +90,14 @@ def test_em():
inline_tests('em', '*')
def test_header_with_space():
assert md('<h3>\n\nHello</h3>') == '### Hello\n\n'
assert md('<h4>\n\nHello</h4>') == '#### Hello\n\n'
assert md('<h5>\n\nHello</h5>') == '##### Hello\n\n'
assert md('<h5>\n\nHello\n\n</h5>') == '##### Hello\n\n'
assert md('<h5>\n\nHello \n\n</h5>') == '##### Hello\n\n'
def test_h1():
assert md('<h1>Hello</h1>') == 'Hello\n=====\n\n'