Skip to content
This repository was archived by the owner on Mar 26, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion softhyphen/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def hyphenate(html, language=None, hyphenator=None, blacklist_tags=(
# Recursively hyphenate each element
hyphenate_element(soup, hyphenator, blacklist_tags)

return six.text_type(soup)
return fix_linebreaks(six.text_type(soup))


# Constants
Expand Down Expand Up @@ -151,6 +151,10 @@ def get_hyphenator_for_language(language):
return Hyphenator(path)


def fix_linebreaks(html):
return html.replace('</br>', '')


# Test when standalone
def _test():
"""Run doctests"""
Expand Down
11 changes: 11 additions & 0 deletions softhyphen/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,14 @@ def test_russian_filter(self):
after,
six.u('<h1>\u043f\u0435&shy;\u0440\u0435.</h1>')
)

def test_linebreak_fix(self):
'''
Test that <br> tags are handled correctly.
'''
before = six.u('<p>Breaking<br>changes</p>')
after = hyphenate(before)
self.failUnlessEqual(
after,
six.u('<p>Break&shy;ing<br>changes</p>')
)