Skip to content

Commit a474bb9

Browse files
committed
merge py26 branch
2 parents fad5467 + 7ba0dca commit a474bb9

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

README.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ python-textile is a Python port of Textile, Dean Allen's humane web text generat
44

55
h2. Usage
66

7-
Install the 'textile' folder on your python path, or @pip install https://github.com/ikirudennis/python-textile/archive/v2.1.6.tar.gz@
7+
Install the 'textile' folder on your python path, or @pip install https://github.com/ikirudennis/python-textile/archive/v2.1.6-py26.tar.gz@
88

99
<pre>
1010
<code>

textile/functions.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@
2121
import re
2222
import uuid
2323
from sys import maxunicode, version_info
24-
from collections import OrderedDict
2524

2625
from textile.tools import sanitizer, imagesize
2726

2827

28+
# We're going to use the Python 2.7+ OrderedDict data type. Import it if it's
29+
# available, otherwise, use the included tool.
30+
try:
31+
from collections import OrderedDict
32+
except ImportError:
33+
from textile.tools import OrderedDict
34+
35+
2936
try:
3037
# Python 3
3138
from urllib.parse import urlparse, urlsplit, urlunsplit, quote, unquote
@@ -473,8 +480,11 @@ def fTable(self, match):
473480
colgrp, last_rgrp = '', ''
474481
c_row = 1
475482
rows = []
476-
for row in [x for x in re.split(r'\|\s*?$', match.group(3), flags=re.M)
477-
if x]:
483+
try:
484+
split = re.split(r'\|\s*?$', match.group(3), flags=re.M)
485+
except TypeError:
486+
split = re.compile(r'\|\s*?$', re.M).split(match.group(3))
487+
for row in [x for x in split if x]:
478488
row = row.lstrip()
479489

480490
# Caption -- only occurs on row 1, otherwise treat '|=. foo |...'
@@ -608,7 +618,10 @@ def lists(self, text):
608618
return pattern.sub(self.fList, bullet_pattern.sub('*', text))
609619

610620
def fList(self, match):
611-
text = re.split(r'\n(?=[*#;:])', match.group(), flags=re.M)
621+
try:
622+
text = re.split(r'\n(?=[*#;:])', match.group(), flags=re.M)
623+
except TypeError:
624+
text = re.compile(r'\n(?=[*#;:])', re.M).split(match.group())
612625
pt = ''
613626
result = []
614627
ls = OrderedDict()
@@ -1445,7 +1458,10 @@ def redcloth_list(self, text):
14451458
def fRCList(self, match):
14461459
"""Format a definition list."""
14471460
out = []
1448-
text = re.split(r'\n(?=[-])', match.group(), flags=re.M)
1461+
try:
1462+
text = re.split(r'\n(?=[-])', match.group(), flags=re.M)
1463+
except TypeError:
1464+
text = re.compile(r'\n(?=[-])', re.M).split(match.group())
14491465
for line in text:
14501466
# parse the attributes and content
14511467
m = re.match(r'^[-]+(%s)[ .](.*)$' % self.lc, line, re.M | re.S)

0 commit comments

Comments
 (0)