Skip to content

Commit 621e431

Browse files
committed
Merge branch 'release/2.3.2'
2 parents b11fe7a + e4b808d commit 621e431

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

CHANGELOG.textile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
h1. Textile Changelog
22

3+
h2. Version 2.3.2
4+
* Bugfix: properly handle @":"@ as text, not a link.
5+
36
h2. Version 2.3.1
47
* Regression bugfix: empty string input returns empty string again.
58

@@ -14,6 +17,7 @@ h2. Version 2.3.0
1417
** Fix Markup not parsed if followed by certain characters ("#22":Markup not parsed if followed by certain characters)
1518
* Convert testing over to "py.test":http://pytest.org/, improving unicode testing
1619
* Update functionality for tables, notelists, and footnotes. This involved a major reworking of parts of the code, but it should now match php-textile and txstyle.org precisely. Please file an issue for any bugs you come across.
20+
* Remove @head_offset@ option from parse. I'm not sure it ever existed in php-textile.
1721

1822
h2. Version 2.2.2
1923

tests/test_github_issues.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,41 @@ def test_github_issue_26():
4141
result = textile.textile(text)
4242
expect = ''
4343
assert result == expect
44+
45+
def test_github_issue_27():
46+
test = """* Folders with ":" in their names are displayed with a forward slash "/" instead. (Filed as "#4581709":/test/link, which was considered "normal behaviour" - quote: "Please note that Finder presents the 'Carbon filesystem' view, regardless of the underlying filesystem.")"""
47+
result = textile.textile(test)
48+
expect = """\t<ul>\n\t\t<li>Folders with &#8220;:&#8221; in their names are displayed with a forward slash &#8220;/&#8221; instead. (Filed as <a href="/test/link">#4581709</a>, which was considered &#8220;normal behaviour&#8221; &#8211; quote: &#8220;Please note that Finder presents the &#8216;Carbon filesystem&#8217; view, regardless of the underlying filesystem.&#8221;)</li>\n\t</ul>"""
49+
assert result == expect
50+
51+
def test_github_issue_28():
52+
test = """So here I am porting my ancient "newspipe":newspipe "front-end":blog/2006/09/30/0950 to "Snakelets":Snakelets and "Python":Python, and I've just trimmed down over 20 lines of "PHP":PHP down to essentially one line of "BeautifulSoup":BeautifulSoup retrieval:
53+
54+
<pre>
55+
def parseWapProfile(self, url):
56+
result = fetch.fetchURL(url)
57+
soup = BeautifulStoneSoup(result['data'], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
58+
try:
59+
width, height = soup('prf:screensize')[0].contents[0].split('x')
60+
except:
61+
width = height = None
62+
return {"width": width, "height": height}
63+
</pre>
64+
65+
Of course there's a lot more error handling to do (and useful data to glean off the "XML":XML), but being able to cut through all the usual parsing crap is immensely gratifying."""
66+
result = textile.textile(test)
67+
expect = ("""\t<p>So here I am porting my ancient <a href="newspipe">newspipe</a> <a href="blog/2006/09/30/0950">front-end</a> to <a href="Snakelets">Snakelets</a> and <a href="Python">Python</a>, and I&#8217;ve just trimmed down over 20 lines of <a href="PHP"><span class="caps">PHP</span></a> down to essentially one line of <a href="BeautifulSoup">BeautifulSoup</a> retrieval:</p>
68+
69+
<pre>
70+
def parseWapProfile(self, url):
71+
result = fetch.fetchURL(url)
72+
soup = BeautifulStoneSoup(result[&#39;data&#39;], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
73+
try:
74+
width, height = soup(&#39;prf:screensize&#39;)[0].contents[0].split(&#39;x&#39;)
75+
except:
76+
width = height = None
77+
return {&quot;width&quot;: width, &quot;height&quot;: height}
78+
</pre>
79+
80+
\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>""")
81+
assert result == expect

tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
def test_encode_html():
77
result = utils.encode_html('''this is a "test" of text that's safe to '''
88
'put in an <html> attribute.')
9-
expect = ('this is a &#34;test&#34; of text that&#39;s safe to put in an '
10-
'&lt;html&gt; attribute.')
9+
expect = ('this is a &quot;test&quot; of text that&#39;s safe to put in '
10+
'an &lt;html&gt; attribute.')
1111
assert result == expect
1212

1313
def test_has_raw_text():

textile/core.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ def markStartOfLinks(self, text):
610610
# inline links between the link text and the url part and are much more
611611
# infrequent than '"' characters so we have less possible links to
612612
# process.
613-
slices = text.split('":')
613+
slice_re = re.compile(r'":(?={0})'.format(regex_snippets['char']))
614+
slices = slice_re.split(text)
614615
output = []
615616

616617
if len(slices) > 1:
@@ -619,6 +620,11 @@ def markStartOfLinks(self, text):
619620
last_slice = slices.pop()
620621

621622
for s in slices:
623+
# If there is no possible start quote then this slice is not
624+
# a link
625+
if '"' not in s:
626+
output.append(s)
627+
continue
622628
# Cut this slice into possible starting points wherever we find
623629
# a '"' character. Any of these parts could represent the start
624630
# of the link text - we have to find which one.

textile/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def encode_html(text, quotes=True):
3939

4040
if quotes:
4141
a = a + (("'", '&#39;'),
42-
('"', '&#34;'))
42+
('"', '&quot;'))
4343

4444
for k, v in a:
4545
text = text.replace(k, v)

textile/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '2.3.1'
1+
VERSION = '2.3.2'

0 commit comments

Comments
 (0)