Skip to content

Commit 7857ece

Browse files
committed
Merge branch 'release/2.3.8'
2 parents 6f21d8d + 0725639 commit 7857ece

File tree

9 files changed

+87
-10
lines changed

9 files changed

+87
-10
lines changed

CHANGELOG.textile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
h1. Textile Changelog
22

3+
h2. Version 2.3.8
4+
* Bugfix: Fix process of string containing only whitespaces ("#40":https://github.com/textile/python-textile/issues/40)
5+
* Bugfix: Fix process of formatted text after lists ("#37":https://github.com/textile/python-textile/issues/37)
6+
* Test: Use sys.executable instead of 'python' to test the CLI ("#38":https://github.com/textile/python-textile/issues/38)
7+
8+
h2. Version 2.3.7
9+
* Bugfix: Don't assume pytest is available to be imported in setup.py ("#39":https://github.com/textile/python-textile/issues/39)
10+
11+
h2. Version 2.3.6
12+
* Packaging: @tests@ directory is correctly included in source-tarball. ("#33":https://github.com/textile/python-textile/issues/33)
13+
314
h2. Version 2.3.5
415
* Bugfix: Correctly handle unicode text in url query-strings. ("#36":https://github.com/textile/python-textile/issues/36)
516

@@ -8,7 +19,7 @@ h2. Version 2.3.4
819
* Remove misplaced shebang on non-callable files.
920
* Packaging: Add test-command to setup.py directly.
1021
* Packaging: Included the tests/ directory for source-tarballs, useful for packaging checks. ("#33":https://github.com/textile/python-textile/issues/33)
11-
* Add a cli tool `pytextile` which takes textile input and prints html output. See `pytextile -h` for details.
22+
* Add a cli tool @pytextile@ which takes textile input and prints html output. See @pytextile -h@ for details.
1223

1324
h2. Version 2.3.3
1425
* Bugfix: Unicode in URL titles no longer break everything ("#30":https://github.com/textile/python-textile/issues/30)

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ include MANIFEST.in
99
include pytest.ini
1010
include README.textile
1111
include requirements.txt
12+
recursive_include tests

setup.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
from setuptools import setup, find_packages
2+
from setuptools.command.test import test as TestCommand
23
import os
34
import sys
4-
import pytest
5+
6+
7+
class PyTest(TestCommand):
8+
user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
9+
10+
def initialize_options(self):
11+
TestCommand.initialize_options(self)
12+
self.pytest_args = []
13+
14+
def run_tests(self):
15+
import shlex
16+
#import here, cause outside the eggs aren't loaded
17+
import pytest
18+
errno = pytest.main(shlex.split(self.pytest_args))
19+
sys.exit(errno)
20+
521

622
def get_version():
723
basedir = os.path.dirname(__file__)
@@ -46,7 +62,7 @@ def get_version():
4662
entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
4763
setup_requires=['pytest-runner'],
4864
tests_require=['pytest', 'pytest-cov'],
49-
cmdclass = {'test': pytest},
65+
cmdclass = {'test': PyTest},
5066
include_package_data=True,
5167
zip_safe=False,
5268
)

tests/test_cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import six
22
import subprocess
3+
import sys
34

45
def test_console_script():
5-
command = ['python', '-m', 'textile', 'README.textile']
6+
command = [sys.executable, '-m', 'textile', 'README.textile']
67
try:
78
result = subprocess.check_output(command)
89
except AttributeError:

tests/test_github_issues.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,15 @@ def test_github_issue_36():
9191
result = textile.textile(text)
9292
expect = '\t<p><a href="https://www.google.com/search?q=Chögyam+Trungpa">Chögyam Trungpa</a></p>'
9393
assert result == expect
94+
95+
def test_github_issue_37():
96+
text = '# xxx\n# yyy\n*blah*'
97+
result = textile.textile(text)
98+
expect = '\t<p>\t<ol>\n\t\t<li>xxx</li>\n\t\t<li>yyy</li>\n\t</ol><br />\n<strong>blah</strong></p>'
99+
assert result == expect
100+
101+
def test_github_issue_40():
102+
text = '\r\n'
103+
result = textile.textile(text)
104+
expect = '\r\n'
105+
assert result == expect

textile/core.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def parse(self, text, rel=None, sanitize=False):
230230
self.unreferencedNotes = OrderedDict()
231231
self.notelist_cache = OrderedDict()
232232

233-
if text == '':
233+
if text.strip() == '':
234234
return text
235235

236236
if self.restricted:
@@ -298,6 +298,7 @@ def textileLists(self, text):
298298

299299
def fTextileList(self, match):
300300
text = re.split(r'\n(?=[*#;:])', match.group(), flags=re.M)
301+
# import pdb; pdb.set_trace()
301302
pt = ''
302303
result = []
303304
ls = OrderedDict()
@@ -309,8 +310,13 @@ def fTextileList(self, match):
309310

310311
m = re.search(r"^(?P<tl>[#*;:]+)(?P<st>_|\d+)?(?P<atts>{0})[ .]"
311312
"(?P<content>.*)$".format(cls_re_s), line, re.S)
312-
tl, start, atts, content = m.groups()
313-
content = content.strip()
313+
if m:
314+
tl, start, atts, content = m.groups()
315+
content = content.strip()
316+
else:
317+
result.append(line)
318+
break
319+
314320
nl = ''
315321
ltype = list_type(tl)
316322
tl_tags = {';': 'dt', ':': 'dd'}
@@ -365,7 +371,7 @@ def fTextileList(self, match):
365371
if tl not in ls:
366372
ls[tl] = 1
367373
itemtag = ("\n{0}\t<{1}>{2}".format(tabs, litem, content) if
368-
showitem else '')
374+
showitem else '')
369375
line = "<{0}l{1}{2}>{3}".format(ltype, atts, start, itemtag)
370376
else:
371377
line = ("\t<{0}{1}>{2}".format(litem, atts, content) if
@@ -811,7 +817,7 @@ def _closingsquarebracket(c, pop, popped, url_chars, counts, pre):
811817
"""If we find a closing square bracket we are going to see if it is
812818
balanced. If it is balanced with matching opening bracket then it
813819
is part of the URL else we spit it back out of the URL."""
814-
# If counts['['] is None, count the occurrences of '['
820+
# If counts['['] is None, count the occurrences of '['
815821
counts['['] = counts['['] or url.count('[')
816822

817823
if counts['['] == counts[']']:

textile/objects/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .block import Block
2+
from .list import List
23
from .table import Table
34

45
__all__ = ['Block', 'Table']

textile/objects/list.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from textile.utils import generate_tag
2+
3+
class List(object):
4+
def __init__(self, listtype, attributes={}):
5+
super(List, self).__init__()
6+
self.type = listtype
7+
self.attributes = attributes
8+
self.items = []
9+
10+
def add_item(self, tag, content, attributes={}):
11+
item = ListItem(tag, content, attributes)
12+
self.items.append(item.process())
13+
14+
def process(self):
15+
content = '\n\t\t{0}\n\t'.format('\n\t\t'.join(self.items))
16+
tag = generate_tag(self.type, content, self.attributes)
17+
return '\t{0}\n'.format(tag)
18+
19+
20+
class ListItem(object):
21+
def __init__(self, tag, content, attributes={}):
22+
super(ListItem, self).__init__()
23+
self.tag = tag
24+
self.content = content
25+
self.attributes = attributes
26+
27+
def process(self):
28+
tag = generate_tag(self.tag, self.content, self.attributes)
29+
return '{0}'.format(tag)

textile/version.py

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

0 commit comments

Comments
 (0)