Repository: matthewwithanm/python-markdownify (python)

Issue:
`<br/>` in inline contexts does not evaluate to a separating space
Currently, `<br/>` in inline contexts (such as headings and table cells) evaluates to an empty string instead of a separating space:

```python
from markdownify import MarkdownConverter

def md(html, **options):
    return MarkdownConverter(heading_style="ATX").convert(html)

print(repr(md('<h1>foo<br />bar</h1>')))
# '# foobar'
#    ^^^^^^

print(repr(md('<td>foo<br />bar</td>')))
# ' foobar |'
#   ^^^^^^
```

In inline contexts, `<br/>` should evaluate to a separating space.

Pull request:
in inline contexts, resolve <br/> to a space instead of an empty string
Fixes #201. In inline contexts, `<br />` now resolves to a space instead of an empty string.

Unit tests were added to include this case.

Patch:
diff --git a/markdownify/__init__.py b/markdownify/__init__.py
index 69ec328..ac34ee5 100644
--- a/markdownify/__init__.py
+++ b/markdownify/__init__.py
@@ -443,7 +443,7 @@ class MarkdownConverter(object):
 
     def convert_br(self, el, text, parent_tags):
         if '_inline' in parent_tags:
-            return ""
+            return ' '
 
         if self.options['newline_style'].lower() == BACKSLASH:
             return '\\\n'


Test patch:
diff --git a/tests/test_conversions.py b/tests/test_conversions.py
index 6939329..0df8f57 100644
--- a/tests/test_conversions.py
+++ b/tests/test_conversions.py
@@ -79,6 +79,8 @@ def test_blockquote_nested():
 def test_br():
     assert md('a<br />b<br />c') == 'a  \nb  \nc'
     assert md('a<br />b<br />c', newline_style=BACKSLASH) == 'a\\\nb\\\nc'
+    assert md('<h1>foo<br />bar</h1>', heading_style=ATX) == '\n\n# foo bar\n\n'
+    assert md('<td>foo<br />bar</td>', heading_style=ATX) == ' foo bar |'
 
 
 def test_code():