Skip to content

Commit bb9b319

Browse files
committed
bugfix for issue #30
1 parent 621e431 commit bb9b319

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

tests/test_github_issues.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ def parseWapProfile(self, url):
7979
8080
\t<p>Of course there&#8217;s a lot more error handling to do (and useful data to glean off the <a href="XML"><span class="caps">XML</span></a>), but being able to cut through all the usual parsing crap is immensely gratifying.</p>""")
8181
assert result == expect
82+
83+
def test_github_issue_30():
84+
text ='"Tëxtíle (Tëxtíle)":http://lala.com'
85+
result = textile.textile(text)
86+
expect = '\t<p><a href="http://lala.com" title="Tëxtíle">Tëxtíle</a></p>'
87+
assert result == expect

textile/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ def generate_tag(tag, content, attributes=None):
5757
if not tag:
5858
return content
5959
# FIXME: Kind of an ugly hack. There *must* be a cleaner way. I tried
60-
# adding text by assigning it to a.text. That results in non-ascii text
61-
# being html-entity encoded. Not bad, but not entirely matching
62-
# php-textile either.
60+
# adding text by assigning it to element_tag.text. That results in
61+
# non-ascii text being html-entity encoded. Not bad, but not entirely
62+
# matching php-textile either.
6363
try:
64-
element_tag = ElementTree.tostringlist(element, encoding=enc,
65-
method='html')
64+
element_tag = [v.decode(enc) for v in ElementTree.tostringlist(element,
65+
encoding=enc, method='html')]
6666
element_tag.insert(len(element_tag) - 1, content)
6767
element_text = ''.join(element_tag)
6868
except AttributeError:
6969
# Python 2.6 doesn't have the tostringlist method, so we have to treat
70-
# it different.
70+
# it differently.
7171
element_tag = ElementTree.tostring(element, encoding=enc)
7272
element_text = re.sub(r"<\?xml version='1.0' encoding='UTF-8'\?>\n",
7373
'', element_tag)

0 commit comments

Comments
 (0)