From 5f102d5223bed81f3540a3a7b23997eb10f87a50 Mon Sep 17 00:00:00 2001 From: Jiulong Wang Date: Wed, 28 Apr 2021 15:22:24 -0700 Subject: [PATCH 1/2] Add conversion for hr element --- markdownify/__init__.py | 3 +++ tests/test_conversions.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 0b2a620..eeaaf74 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -269,6 +269,9 @@ class MarkdownConverter(object): continue return '\n'.join(text_data) + def convert_hr(self, el, text, convert_as_inline): + return '\n\n---\n\n' + def markdownify(html, **options): return MarkdownConverter(**options).convert(html) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index 6dcf9a6..fcb9bf3 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -307,3 +307,7 @@ def test_strong_em_symbol(): def test_newline_style(): assert md('a
b
c', newline_style=BACKSLASH) == 'a\\\nb\\\nc' + + +def test_hr(): + assert md('Hello
World') == 'Hello\n\n---\n\nWorld' From 55fb96e3c056ad6f43217232dd489a0bad893654 Mon Sep 17 00:00:00 2001 From: AlexVonB Date: Sun, 2 May 2021 10:45:52 +0200 Subject: [PATCH 2/2] fix hr tests --- tests/test_conversions.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index fcb9bf3..9d25940 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -229,7 +229,9 @@ def test_hn_nested_img(): def test_hr(): - assert md('
hr') == 'hr' + assert md('Hello
World') == 'Hello\n\n---\n\nWorld' + assert md('Hello
World') == 'Hello\n\n---\n\nWorld' + assert md('

Hello

\n
\n

World

') == 'Hello\n\n\n\n\n---\n\n\nWorld\n\n' def test_head(): @@ -307,7 +309,3 @@ def test_strong_em_symbol(): def test_newline_style(): assert md('a
b
c', newline_style=BACKSLASH) == 'a\\\nb\\\nc' - - -def test_hr(): - assert md('Hello
World') == 'Hello\n\n---\n\nWorld'