Skip to content

Commit 4d64d09

Browse files
committed
Merge branch 'release/2.3.4'
2 parents 621e431 + c08c78a commit 4d64d09

16 files changed

+190
-25
lines changed

CHANGELOG.textile

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

3+
h2. Version 2.3.4
4+
* Bugfix: fix an issue with extended block code
5+
* Remove misplaced shebang on non-callable files.
6+
* Packaging: Add test-command to setup.py directly.
7+
* Packaging: Included the tests/ directory for source-tarballs, useful for packaging checks. ("#33":https://github.com/textile/python-textile/issues/33)
8+
* Add a cli tool `pytextile` which takes textile input and prints html output. See `pytextile -h` for details.
9+
10+
h2. Version 2.3.3
11+
* Bugfix: Unicode in URL titles no longer break everything ("#30":https://github.com/textile/python-textile/issues/30)
12+
* Display DeprecationWarning when using textile on Python 2.6.
13+
314
h2. Version 2.3.2
415
* Bugfix: properly handle @":"@ as text, not a link.
516

MANIFEST.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exclude .gitignore
2+
exclude TODO.textile
3+
exclude .travis.yml
4+
include CHANGELOG.textile
5+
include CONTRIBUTORS.txt
6+
include .coveragerc
7+
include LICENSE.txt
8+
include MANIFEST.in
9+
include pytest.ini
10+
include README.textile
11+
include requirements.txt

README.textile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ Optional dependencies include:
1414

1515
h2. Usage
1616

17-
<pre>
18-
<code>
19-
>>> import textile
17+
bc.. import textile
2018
>>> s = """
2119
... _This_ is a *test.*
2220
...
@@ -38,8 +36,6 @@ h2. Usage
3836

3937
<p>Link to <a href="http://slashdot.org/">Slashdot</a></p>
4038
>>>
41-
</code>
42-
</pre>
4339

4440
h3. Notes:
4541

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from setuptools import setup, find_packages
22
import os
33
import sys
4+
import pytest
45

56
def get_version():
67
basedir = os.path.dirname(__file__)
@@ -13,6 +14,8 @@ def get_version():
1314
setup(
1415
name='textile',
1516
version=get_version(),
17+
author='Dennis Burke',
18+
author_email='ikirudennis@gmail.com',
1619
description='Textile processing for python.',
1720
url='http://github.com/textile/python-textile',
1821
packages=find_packages(),
@@ -40,8 +43,10 @@ def get_version():
4043
':python_version=="2.6"': ['ordereddict>=1.1'],
4144
'develop': ['regex', 'pytest', 'pytest-cov'],
4245
},
46+
entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
4347
setup_requires=['pytest-runner'],
4448
tests_require=['pytest', 'pytest-cov'],
49+
cmdclass = {'test': pytest},
4550
include_package_data=True,
4651
zip_safe=False,
4752
)

tests/fixtures/README.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<p><a href="https://travis-ci.org/textile/python-textile"><img alt="" src="https://travis-ci.org/textile/python-textile.svg" /></a> <a href="https://coveralls.io/github/textile/python-textile?branch=master"><img alt="" src="https://coveralls.io/repos/github/textile/python-textile/badge.svg" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a></p>
2+
3+
<h1>python-textile</h1>
4+
5+
<p>python-textile is a Python port of <a href="http://txstyle.org/">Textile</a>, Dean Allen&#8217;s humane web text generator.</p>
6+
7+
<h2>Installation</h2>
8+
9+
<p><code>pip install textile</code></p>
10+
11+
<p>Optional dependencies include:
12+
<ul>
13+
<li><a href="http://python-pillow.github.io/"><span class="caps">PIL</span>/Pillow</a> (for checking images size)</li>
14+
<li><a href="https://pypi.python.org/pypi/regex">regex</a> (for faster unicode-aware string matching).</li>
15+
</ul></p>
16+
17+
<h2>Usage</h2>
18+
19+
<pre><code>import textile
20+
&gt;&gt;&gt; s = &quot;&quot;&quot;
21+
... _This_ is a *test.*
22+
...
23+
... * One
24+
... * Two
25+
... * Three
26+
...
27+
... Link to &quot;Slashdot&quot;:http://slashdot.org/
28+
... &quot;&quot;&quot;
29+
&gt;&gt;&gt; html = textile.textile(s)
30+
&gt;&gt;&gt; print html
31+
&lt;p&gt;&lt;em&gt;This&lt;/em&gt; is a &lt;strong&gt;test.&lt;/strong&gt;&lt;/p&gt;
32+
33+
&lt;ul&gt;
34+
&lt;li&gt;One&lt;/li&gt;
35+
&lt;li&gt;Two&lt;/li&gt;
36+
&lt;li&gt;Three&lt;/li&gt;
37+
&lt;/ul&gt;
38+
39+
&lt;p&gt;Link to &lt;a href=&quot;http://slashdot.org/&quot;&gt;Slashdot&lt;/a&gt;&lt;/p&gt;
40+
&gt;&gt;&gt;</code></pre>
41+
42+
<h3>Notes:</h3>
43+
44+
<ul>
45+
<li>Active development supports Python 2.6 or later (including Python 3.2+).</li>
46+
</ul>

tests/test_block.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import unicode_literals
22

3-
from textile import Textile
3+
import textile
44
from textile.objects import Block
55

66
try:
@@ -9,7 +9,7 @@
99
from ordereddict import OrderedDict
1010

1111
def test_block():
12-
t = Textile()
12+
t = textile.Textile()
1313
result = t.block('h1. foobar baby')
1414
expect = '\t<h1>foobar baby</h1>'
1515
assert result == expect
@@ -41,9 +41,24 @@ def test_block():
4141
assert result == expect
4242

4343
def test_block_tags_false():
44-
t = Textile(block_tags=False)
44+
t = textile.Textile(block_tags=False)
4545
assert t.block_tags is False
4646

4747
result = t.parse('test')
4848
expect = 'test'
4949
assert result == expect
50+
51+
def test_blockcode_extended():
52+
input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test'
53+
expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>\n\n\t<p>test</p>'
54+
t = textile.Textile()
55+
result = t.parse(input)
56+
assert result == expect
57+
58+
def test_blockcode_in_README():
59+
with open('README.textile') as f:
60+
readme = ''.join(f.readlines())
61+
result = textile.textile(readme)
62+
with open('tests/fixtures/README.txt') as f:
63+
expect = ''.join(f.readlines())
64+
assert result == expect

tests/test_cli.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import six
2+
import subprocess
3+
4+
def test_console_script():
5+
command = ['python', '-m', 'textile', 'README.textile']
6+
try:
7+
result = subprocess.check_output(command)
8+
except AttributeError:
9+
command[2] = 'textile.__main__'
10+
result = subprocess.Popen(command,
11+
stdout=subprocess.PIPE).communicate()[0]
12+
with open('tests/fixtures/README.txt') as f:
13+
expect = ''.join(f.readlines())
14+
if type(result) == bytes:
15+
result = result.decode('utf-8')
16+
assert result == expect

tests/test_github_issues.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ def parseWapProfile(self, url):
7979
8080
\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>""")
8181
assert result == expect
82+
83+
def test_github_issue_30():
84+
text ='"Tëxtíle (Tëxtíle)":http://lala.com'
85+
result = textile.textile(text)
86+
expect = '\t<p><a href="http://lala.com" title="Tëxtíle">Tëxtíle</a></p>'
87+
assert result == expect

tests/test_values.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150

151151
('<script>alert("hello");</script>', '\t<p><script>alert(&#8220;hello&#8221;);</script></p>'),
152152

153-
('pre.. Hello\n\nHello Again\n\np. normal text', '<pre>Hello\n\nHello Again\n</pre>\n\n\t<p>normal text</p>'),
153+
('pre.. Hello\n\nHello Again\n\np. normal text', '<pre>Hello\n\nHello Again</pre>\n\n\t<p>normal text</p>'),
154154

155155
('<pre>this is in a pre tag</pre>', '<pre>this is in a pre tag</pre>'),
156156

@@ -180,7 +180,7 @@
180180

181181
('h2. A header\n\n\n\n\n\nsome text', '\t<h2>A header</h2>\n\n\t<p>some text</p>'),
182182

183-
('pre.. foo bar baz\nquux', '<pre>foo bar baz\nquux\n</pre>'),
183+
('pre.. foo bar baz\nquux', '<pre>foo bar baz\nquux</pre>'),
184184

185185
('line of text\n\n leading spaces',
186186
'\t<p>line of text</p>\n\n leading spaces'),
@@ -286,11 +286,11 @@
286286
# issue 2 escaping
287287
('"foo ==(bar)==":#foobar', '\t<p><a href="#foobar">foo (bar)</a></p>'),
288288
# issue 14 newlines in extended pre blocks
289-
("pre.. Hello\n\nAgain\n\np. normal text", '<pre>Hello\n\nAgain\n</pre>\n\n\t<p>normal text</p>'),
289+
("pre.. Hello\n\nAgain\n\np. normal text", '<pre>Hello\n\nAgain</pre>\n\n\t<p>normal text</p>'),
290290
# url with parentheses
291291
('"python":http://en.wikipedia.org/wiki/Python_(programming_language)', '\t<p><a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">python</a></p>'),
292292
# table with hyphen styles
293-
('table(linkblog-thumbnail).\n|(linkblog-thumbnail-cell). apple|bear|', '\t<table class="linkblog-thumbnail">\n\t\t<tr>\n\t\t\t<td class="linkblog-thumbnail-cell" style="vertical-align:middle;">apple</td>\n\t\t\t<td>bear</td>\n\t\t</tr>\n\t</table>'),
293+
('table(linkblog-thumbnail).\n|(linkblog-thumbnail-cell). apple|bear|', '\t<table class="linkblog-thumbnail">\n\t\t<tr>\n\t\t\t<td class="linkblog-thumbnail-cell">apple</td>\n\t\t\t<td>bear</td>\n\t\t</tr>\n\t</table>'),
294294
# issue 32 empty table cells
295295
("|thing|||otherthing|", "\t<table>\n\t\t<tr>\n\t\t\t<td>thing</td>\n\t\t\t<td></td>\n\t\t\t<td></td>\n\t\t\t<td>otherthing</td>\n\t\t</tr>\n\t</table>"),
296296
# issue 36 link reference names http and https

textile/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
from __future__ import unicode_literals
22

3+
import sys
4+
import warnings
5+
36
from .core import textile, textile_restricted, Textile
47
from .version import VERSION
58

69
__all__ = ['textile', 'textile_restricted']
710

811
__version__ = VERSION
12+
13+
14+
if sys.version_info[:2] == (2, 6):
15+
warnings.warn(
16+
"Python 2.6 is no longer supported by the Python core team, please "
17+
"upgrade your Python. A future version of textile will drop support "
18+
"for Python 2.6",
19+
DeprecationWarning
20+
)

0 commit comments

Comments
 (0)