Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Merge 3c85db8 into c3dd139
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-mi committed Dec 11, 2016
2 parents c3dd139 + 3c85db8 commit 7945321
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion softhyphen/html.py
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
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>')
)

0 comments on commit 7945321

Please sign in to comment.