From 76ba349fb499e3395109b31c693878c3c5e0672b Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 10:41:58 -0400 Subject: [PATCH 1/7] fix issue #27 --- tests/test_github_issues.py | 9 +++++++++ textile/core.py | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 29fc1b04..83f0f436 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -41,3 +41,12 @@ 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":Radar:4581709, 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""" + assert result == expect diff --git a/textile/core.py b/textile/core.py index dc5b13ac..5cac161b 100644 --- a/textile/core.py +++ b/textile/core.py @@ -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: @@ -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. From d9ed964f066a5fb94b0278f1204be2c730ac66bd Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 10:45:16 -0400 Subject: [PATCH 2/7] noting removal of `head_offset` in changelog. --- CHANGELOG.textile | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index c9466fce..d49c68a3 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -14,6 +14,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 From e4fa841a175072b5a62554358c5b019ecce1ac82 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 11:09:55 -0400 Subject: [PATCH 3/7] simplifying the actual link in test_github_issue_27 that link isn't part of the issue and is producing strange output on py26, from which I'm having trouble getting consistent results. --- tests/test_github_issues.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 83f0f436..8969b7f5 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -44,9 +44,9 @@ def test_github_issue_26(): def test_github_issue_27(): test=""" -* Folders with ":" in their names are displayed with a forward slash "/" instead. (Filed as "#4581709":Radar:4581709, which was considered "normal behaviour" - quote: "Please note that Finder presents the 'Carbon filesystem' view, regardless of the underlying filesystem.") +* 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
    \n\t\t
  • Folders with “:” in their names are displayed with a forward slash “/” instead. (Filed as #4581709, which was considered “normal behaviour” – quote: “Please note that Finder presents the ‘Carbon filesystem’ view, regardless of the underlying filesystem.”)
  • \n\t
""" + expect = """\t
    \n\t\t
  • Folders with “:” in their names are displayed with a forward slash “/” instead. (Filed as #4581709, which was considered “normal behaviour” – quote: “Please note that Finder presents the ‘Carbon filesystem’ view, regardless of the underlying filesystem.”)
  • \n\t
""" assert result == expect From 288493d06f84c1b0be82417acc4011f0b6b70380 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 11:39:53 -0400 Subject: [PATCH 4/7] add test for issue #28. --- tests/test_github_issues.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 8969b7f5..6c1f42d9 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -50,3 +50,35 @@ def test_github_issue_27(): result = textile.textile(test) expect = """\t
    \n\t\t
  • Folders with “:” in their names are displayed with a forward slash “/” instead. (Filed as #4581709, which was considered “normal behaviour” – quote: “Please note that Finder presents the ‘Carbon filesystem’ view, regardless of the underlying filesystem.”)
  • \n\t
""" 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: + +
+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}
+
+ +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

So here I am porting my ancient newspipe front-end to Snakelets and Python, and I’ve just trimmed down over 20 lines of PHP down to essentially one line of BeautifulSoup retrieval:

+ +
+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}
+
+ +\t

Of course there’s a lot more error handling to do (and useful data to glean off the XML), but being able to cut through all the usual parsing crap is immensely gratifying.

""") + assert result == expect From aa566497b8916f5814d4741fd262b1f94daa7f2d Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 18:03:25 -0400 Subject: [PATCH 5/7] convert double-quote to " within html attributes. Somehow, php-textile did this from the start while python-textile went with " instead. Now we match. --- tests/test_utils.py | 4 ++-- textile/utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 9acb3dc8..7f386a9b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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 attribute.') - expect = ('this is a "test" of text that's safe to put in an ' - '<html> attribute.') + expect = ('this is a "test" of text that's safe to put in ' + 'an <html> attribute.') assert result == expect def test_has_raw_text(): diff --git a/textile/utils.py b/textile/utils.py index 55a5de0c..d917e9e4 100644 --- a/textile/utils.py +++ b/textile/utils.py @@ -39,7 +39,7 @@ def encode_html(text, quotes=True): if quotes: a = a + (("'", '''), - ('"', '"')) + ('"', '"')) for k, v in a: text = text.replace(k, v) From e00e33f7dffb5f555f93c205e310f383e568a227 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sat, 21 May 2016 18:19:47 -0400 Subject: [PATCH 6/7] fix tests to match change in encode_html. --- tests/test_github_issues.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 6c1f42d9..fa14237e 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -43,16 +43,13 @@ def test_github_issue_26(): 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.") - -""" + 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
    \n\t\t
  • Folders with “:” in their names are displayed with a forward slash “/” instead. (Filed as #4581709, which was considered “normal behaviour” – quote: “Please note that Finder presents the ‘Carbon filesystem’ view, regardless of the underlying filesystem.”)
  • \n\t
""" 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: + 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:
 def parseWapProfile(self, url):
@@ -77,7 +74,7 @@ def parseWapProfile(self, url):
     width, height = soup('prf:screensize')[0].contents[0].split('x')
   except:
     width = height = None
-  return {"width": width, "height": height}
+  return {"width": width, "height": height}
 
\t

Of course there’s a lot more error handling to do (and useful data to glean off the XML), but being able to cut through all the usual parsing crap is immensely gratifying.

""") From e4b808dc69c86198fc54adb57a0286e6e9e46456 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Sun, 22 May 2016 09:52:41 -0400 Subject: [PATCH 7/7] bump version number and update changelog. --- CHANGELOG.textile | 3 +++ textile/version.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index d49c68a3..06f8e8da 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -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. diff --git a/textile/version.py b/textile/version.py index 7e696978..a5ac6164 100644 --- a/textile/version.py +++ b/textile/version.py @@ -1 +1 @@ -VERSION = '2.3.1' +VERSION = '2.3.2'