Skip to content

Commit

Permalink
Merge branch 'release/2.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed May 22, 2016
2 parents b11fe7a + e4b808d commit 621e431
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
h1. Textile Changelog

h2. Version 2.3.2
* Bugfix: properly handle @":"@ as text, not a link.

h2. Version 2.3.1
* Regression bugfix: empty string input returns empty string again.

Expand All @@ -14,6 +17,7 @@ h2. Version 2.3.0
** Fix Markup not parsed if followed by certain characters ("#22":Markup not parsed if followed by certain characters)
* Convert testing over to "py.test":http://pytest.org/, improving unicode testing
* 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.
* Remove @head_offset@ option from parse. I'm not sure it ever existed in php-textile.

h2. Version 2.2.2

Expand Down
38 changes: 38 additions & 0 deletions tests/test_github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,41 @@ def test_github_issue_26():
result = textile.textile(text)
expect = ''
assert result == expect

def test_github_issue_27():
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.")"""
result = textile.textile(test)
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>"""
assert result == expect

def test_github_issue_28():
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:
<pre>
def parseWapProfile(self, url):
result = fetch.fetchURL(url)
soup = BeautifulStoneSoup(result['data'], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
try:
width, height = soup('prf:screensize')[0].contents[0].split('x')
except:
width = height = None
return {"width": width, "height": height}
</pre>
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."""
result = textile.textile(test)
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>
<pre>
def parseWapProfile(self, url):
result = fetch.fetchURL(url)
soup = BeautifulStoneSoup(result[&#39;data&#39;], convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
try:
width, height = soup(&#39;prf:screensize&#39;)[0].contents[0].split(&#39;x&#39;)
except:
width = height = None
return {&quot;width&quot;: width, &quot;height&quot;: height}
</pre>
\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>""")
assert result == expect
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
def test_encode_html():
result = utils.encode_html('''this is a "test" of text that's safe to '''
'put in an <html> attribute.')
expect = ('this is a &#34;test&#34; of text that&#39;s safe to put in an '
'&lt;html&gt; attribute.')
expect = ('this is a &quot;test&quot; of text that&#39;s safe to put in '
'an &lt;html&gt; attribute.')
assert result == expect

def test_has_raw_text():
Expand Down
8 changes: 7 additions & 1 deletion textile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ def markStartOfLinks(self, text):
# inline links between the link text and the url part and are much more
# infrequent than '"' characters so we have less possible links to
# process.
slices = text.split('":')
slice_re = re.compile(r'":(?={0})'.format(regex_snippets['char']))
slices = slice_re.split(text)
output = []

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

for s in slices:
# If there is no possible start quote then this slice is not
# a link
if '"' not in s:
output.append(s)
continue
# Cut this slice into possible starting points wherever we find
# a '"' character. Any of these parts could represent the start
# of the link text - we have to find which one.
Expand Down
2 changes: 1 addition & 1 deletion textile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def encode_html(text, quotes=True):

if quotes:
a = a + (("'", '&#39;'),
('"', '&#34;'))
('"', '&quot;'))

for k, v in a:
text = text.replace(k, v)
Expand Down
2 changes: 1 addition & 1 deletion textile/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '2.3.1'
VERSION = '2.3.2'

0 comments on commit 621e431

Please sign in to comment.