diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 28cdaf6..27fb4ff 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -12,7 +12,7 @@ re_newline_whitespace = re.compile(r'[\t \r\n]*[\r\n][\t \r\n]*') re_html_heading = re.compile(r'h(\d+)') re_pre_lstrip1 = re.compile(r'^ *\n') -re_pre_rstrip1 = re.compile(r'\n *$') +re_pre_rstrip1 = re.compile(r'\n *\Z') re_pre_lstrip = re.compile(r'^[ \n]*\n') re_pre_rstrip = re.compile(r'[ \n]*$') diff --git a/tests/test_args.py b/tests/test_args.py index 838ef9d..1e996a0 100644 --- a/tests/test_args.py +++ b/tests/test_args.py @@ -38,6 +38,8 @@ def test_strip_pre(): assert markdownify("
\n \n Hello \n \n") == "```\n Hello\n```" assert markdownify("
\n \n Hello \n \n", strip_pre=STRIP) == "```\n Hello\n```" assert markdownify("
\n \n Hello \n \n", strip_pre=STRIP_ONE) == "```\n \n Hello \n \n```" + assert markdownify("
\n\nHello\n\n", strip_pre=STRIP_ONE) == "```\n\nHello\n\n```" + assert markdownify("
\n\nHello\n\n\n", strip_pre=STRIP_ONE) == "```\n\nHello\n\n\n```" assert markdownify("
\n \n Hello \n \n", strip_pre=None) == "```\n \n \n Hello \n \n \n```"