From f33ccd7c1aef77dcfc4751715f1008fa8d519b46 Mon Sep 17 00:00:00 2001 From: Veronika Butkevich <13301101+5yato4ok@users.noreply.github.com> Date: Tue, 26 Mar 2024 20:46:30 +0100 Subject: [PATCH] Fix newline start in header tags (#89) * Fix newline start in header tags --- markdownify/__init__.py | 2 +- tests/test_conversions.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 151a222..a60400c 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -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) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index 5c6ec06..b03c874 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -90,6 +90,14 @@ def test_em(): inline_tests('em', '*') +def test_header_with_space(): + assert md('