Skip to content

Commit e26c454

Browse files
committed
fix issue #58
1 parent 51dd3b2 commit e26c454

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

tests/test_github_issues.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ def test_github_issue_30():
8686
expect = '\t<p><a href="http://lala.com" title="Tëxtíle">Tëxtíle</a></p>'
8787
assert result == expect
8888

89+
text ='!http://lala.com/lol.gif(♡ imáges)!'
90+
result = textile.textile(text)
91+
expect = '\t<p><img alt="♡ imáges" src="http://lala.com/lol.gif" title="♡ imáges" /></p>'
92+
assert result == expect
93+
8994
def test_github_issue_36():
9095
text = '"Chögyam Trungpa":https://www.google.com/search?q=Chögyam+Trungpa'
9196
result = textile.textile(text)

textile/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def generate_tag(tag, content, attributes=None):
5050
content are strings, the attributes argument is a dictionary. As
5151
a convenience, if the content is ' /', a self-closing tag is generated."""
5252
content = six.text_type(content)
53+
# In PY2, ElementTree tostringlist only works with bytes, not with
54+
# unicode().
5355
enc = 'unicode'
5456
if six.PY2:
5557
enc = 'UTF-8'
@@ -63,6 +65,8 @@ def generate_tag(tag, content, attributes=None):
6365
try:
6466
element_tag = ElementTree.tostringlist(element, encoding=enc,
6567
method='html')
68+
if six.PY2:
69+
element_tag = [v.decode(enc) for v in element_tag]
6670
element_tag.insert(len(element_tag) - 1, content)
6771
element_text = ''.join(element_tag)
6872
except AttributeError:

0 commit comments

Comments
 (0)