[Python-modules-commits] [python-textile] 01/01: New upstream version 2.3.12

Dmitry Shachnev mitya57 at moszumanska.debian.org
Sat Jun 24 10:32:08 UTC 2017


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch upstream
in repository python-textile.

commit 9f58f34d6d1013d52cb956c234b8f322e1aadc8a
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Sat Jun 24 13:28:37 2017 +0300

    New upstream version 2.3.12
---
 .travis.yml                 |  1 +
 CHANGELOG.textile           | 30 +++++++++++++++++++++++++++++-
 MANIFEST.in                 | 11 +----------
 setup.py                    | 22 +++++++++++++++++++---
 tests/test_block.py         |  7 +++++++
 tests/test_cli.py           | 17 ++++++++++++++++-
 tests/test_github_issues.py | 41 ++++++++++++++++++++++++++++++++++++++++-
 tests/test_urls.py          |  8 ++++++++
 tests/test_values.py        |  4 ++--
 textile/__main__.py         |  6 ++++++
 textile/core.py             | 32 ++++++++++++++++++++------------
 textile/objects/block.py    |  5 +++--
 textile/version.py          |  2 +-
 13 files changed, 153 insertions(+), 33 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 7f40ce9..e01eb38 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,6 +9,7 @@ python:
   - "3.3"
   - "3.4"
   - "3.5"
+  - "3.6"
   - "pypy"
 # command to install dependencies
 install:
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index c822ed1..1150246 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,5 +1,33 @@
 h1. Textile Changelog
 
+h2. Version 2.3.12
+* Bugfix: Don't die on pre blocks with unicode characters. ("#43":https://github.com/textile/python-textile/issues/43)
+* Bugfix: Fix regressions introduced into the code between 2.2.2 and 2.3.11. (Special thanks to "@adam-iris":https://github.com/adam-iris for providing pull request "#44":https://github.com/textile/python-textile/pull/44)
+* Bugfix: Don't just die when processing poorly-formatted textile lists. ("#37":https://github.com/textile/python-textile/issues/37)
+* Add Python 3.6 to testing.
+* Add a "print the version string and exit" argument to the cli tool: @pytextile -v@
+
+h2. Version 2.3.11
+* Bugfix: Don't strip leading dot from image URIs ("#42":https://github.com/textile/python-textile/issues/42)
+
+h2. Version 2.3.10
+* Packaging: cleanup in MANIFEST.IN leads to better linux packaging, and smaller wheel size.
+
+h2. Version 2.3.9
+* Packaging: remove extraneous files from the source distribution upload.
+* Remove a lingering file from a feature branch for overhauling list handling.  This brings coverage back up to 100%
+
+h2. Version 2.3.8
+* Bugfix: Fix process of string containing only whitespaces ("#40":https://github.com/textile/python-textile/issues/40)
+* Bugfix: Fix process of formatted text after lists ("#37":https://github.com/textile/python-textile/issues/37)
+* Test: Use sys.executable instead of 'python' to test the CLI ("#38":https://github.com/textile/python-textile/issues/38)
+
+h2. Version 2.3.7
+* Bugfix: Don't assume pytest is available to be imported in setup.py ("#39":https://github.com/textile/python-textile/issues/39)
+
+h2. Version 2.3.6
+* Packaging: @tests@ directory is correctly included in source-tarball. ("#33":https://github.com/textile/python-textile/issues/33)
+
 h2. Version 2.3.5
 * Bugfix: Correctly handle unicode text in url query-strings. ("#36":https://github.com/textile/python-textile/issues/36)
 
@@ -8,7 +36,7 @@ h2. Version 2.3.4
 * Remove misplaced shebang on non-callable files.
 * Packaging: Add test-command to setup.py directly.
 * Packaging: Included the tests/ directory for source-tarballs, useful for packaging checks. ("#33":https://github.com/textile/python-textile/issues/33)
-* Add a cli tool `pytextile` which takes textile input and prints html output.  See `pytextile -h` for details.
+* Add a cli tool @pytextile@ which takes textile input and prints html output.  See @pytextile -h@ for details.
 
 h2. Version 2.3.3
 * Bugfix: Unicode in URL titles no longer break everything ("#30":https://github.com/textile/python-textile/issues/30)
diff --git a/MANIFEST.in b/MANIFEST.in
index b0f4cab..5ca56e8 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,11 +1,2 @@
-exclude .gitignore
-exclude TODO.textile
-exclude .travis.yml
-include CHANGELOG.textile
-include CONTRIBUTORS.txt
-include .coveragerc
-include LICENSE.txt
 include MANIFEST.in
-include pytest.ini
-include README.textile
-include requirements.txt
+include tests/fixtures/README.txt
diff --git a/setup.py b/setup.py
index b28294c..c12d3e0 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,23 @@
 from setuptools import setup, find_packages
+from setuptools.command.test import test as TestCommand
 import os
 import sys
-import pytest
+
+
+class PyTest(TestCommand):
+    user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]
+
+    def initialize_options(self):
+        TestCommand.initialize_options(self)
+        self.pytest_args = []
+
+    def run_tests(self):
+        import shlex
+        #import here, cause outside the eggs aren't loaded
+        import pytest
+        errno = pytest.main(shlex.split(self.pytest_args))
+        sys.exit(errno)
+
 
 def get_version():
     basedir = os.path.dirname(__file__)
@@ -36,6 +52,7 @@ setup(
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
     ],
     keywords='textile,text,html markup',
     install_requires=['six',],
@@ -46,8 +63,7 @@ setup(
     entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
     setup_requires=['pytest-runner'],
     tests_require=['pytest', 'pytest-cov'],
-    cmdclass = {'test': pytest},
+    cmdclass = {'test': PyTest},
     include_package_data=True,
     zip_safe=False,
 )
-
diff --git a/tests/test_block.py b/tests/test_block.py
index 0e6dc14..c69105c 100644
--- a/tests/test_block.py
+++ b/tests/test_block.py
@@ -62,3 +62,10 @@ def test_blockcode_in_README():
     with open('tests/fixtures/README.txt') as f:
         expect = ''.join(f.readlines())
     assert result == expect
+
+def test_blockcode_comment():
+    input = '###.. block comment\nanother line\n\np. New line'
+    expect = '\t<p>New line</p>'
+    t = textile.Textile()
+    result = t.parse(input)
+    assert result == expect
diff --git a/tests/test_cli.py b/tests/test_cli.py
index bc1e28d..8d37614 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,8 +1,11 @@
 import six
 import subprocess
+import sys
+
+import textile
 
 def test_console_script():
-    command = ['python', '-m', 'textile', 'README.textile']
+    command = [sys.executable, '-m', 'textile', 'README.textile']
     try:
         result = subprocess.check_output(command)
     except AttributeError:
@@ -14,3 +17,15 @@ def test_console_script():
     if type(result) == bytes:
         result = result.decode('utf-8')
     assert result == expect
+
+def test_version_string():
+    command = [sys.executable, '-m', 'textile', '-v']
+    try:
+        result = subprocess.check_output(command)
+    except AttributeError:
+        command[2] = 'textile.__main__'
+        result = subprocess.Popen(command,
+                stdout=subprocess.PIPE).communicate()[0]
+    if type(result) == bytes:
+        result = result.decode('utf-8')
+    assert result.strip() == textile.__version__
diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py
index bf9c339..012ee5d 100644
--- a/tests/test_github_issues.py
+++ b/tests/test_github_issues.py
@@ -27,7 +27,7 @@ bc.
   bar
 </foo>'''
     result = textile.textile(text)
-    expect = '\t<h1>xml example</h1>\n\n<pre><code>\n<foo>\n  bar\n</foo>\n</code></pre>'
+    expect = '\t<h1>xml example</h1>\n\n<pre><code>\n<foo>\n  bar\n</foo></code></pre>'
     assert result == expect
 
 def test_github_issue_22():
@@ -91,3 +91,42 @@ def test_github_issue_36():
     result = textile.textile(text)
     expect = '\t<p><a href="https://www.google.com/search?q=Chögyam+Trungpa">Chögyam Trungpa</a></p>'
     assert result == expect
+
+def test_github_issue_37():
+    text = '# xxx\n# yyy\n*blah*'
+    result = textile.textile(text)
+    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>'
+    assert result == expect
+
+    text = '*Highlights*\n\n* UNITEK Y-3705A Type-C Universal DockingStation Pro\n* USB3.0/RJ45/EARPHONE/MICROPHONE/HDMI 6 PORT HUB 1.2m Data Cable 5V 4A Power Adaptor\n*\n* Dimensions: 25cm x 13cm x 9cm\n* Weight: 0.7kg'
+    result = textile.textile(text)
+    expect = '''\t<p><strong>Highlights</strong></p>
+
+\t<ul>
+\t\t<li><span class="caps">UNITEK</span> Y-3705A Type-C Universal DockingStation Pro</li>
+\t\t<li>USB3.0/RJ45/EARPHONE/MICROPHONE/HDMI 6 <span class="caps">PORT</span> <span class="caps">HUB</span> 1.2m Data Cable 5V 4A Power Adaptor</li>
+\t</ul>
+*
+\t<ul>
+\t\t<li>Dimensions: 25cm x 13cm x 9cm</li>
+\t\t<li>Weight: 0.7kg</li>
+\t</ul>'''
+    assert result == expect
+
+def test_github_issue_40():
+    text = '\r\n'
+    result = textile.textile(text)
+    expect = '\r\n'
+    assert result == expect
+
+def test_github_issue_42():
+    text = '!./image.png!'
+    result = textile.textile(text)
+    expect = '\t<p><img alt="" src="./image.png" /></p>'
+    assert result == expect
+
+def test_github_issue_43():
+    text = 'pre. smart ‘quotes’ are not smart!'
+    result = textile.textile(text)
+    expect = '<pre>smart ‘quotes’ are not smart!</pre>'
+    assert result == expect
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 69bae4f..0ae78e6 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -46,6 +46,14 @@ def test_urls():
     expect = '\t<p>A link that starts with an h is <a href="/test/">handled</a> incorrectly.</p>'
     assert result == expect
 
+    result = t.parse('A link that starts with a space" raises":/test/ an exception.')
+    expect = '\t<p><a href="/test/">A link that starts with a space” raises</a> an exception.</p>'
+    assert result == expect
+
+    result = t.parse('A link that "contains a\nnewline":/test/ raises an exception.')
+    expect = '\t<p>A link that <a href="/test/">contains a\nnewline</a> raises an exception.</p>'
+    assert result == expect
+
 def test_rel_attribute():
     t = Textile(rel='nofollow')
     result = t.parse('"$":http://domain.tld')
diff --git a/tests/test_values.py b/tests/test_values.py
index a67cfa6..68a2dc1 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -219,7 +219,7 @@ xhtml_known_values = (
      '\t<p style="font-size:0.8em;"><strong>TxStyle</strong> is a documentation project of Textile 2.4 for <a href="http://texpattern.com">Textpattern <span class="caps">CMS</span></a>.</p>'),
     (""""Übermensch":http://de.wikipedia.org/wiki/Übermensch""", """\t<p><a href="http://de.wikipedia.org/wiki/%C3%9Cbermensch">Übermensch</a></p>"""),
     ("""Here is some text with a <!-- Commented out[1] --> block.\n\n<!-- Here is a single <span>line</span> comment block -->\n\n<!-- Here is a whole\nmultiline\n<span>HTML</span>\nComment\n-->\n\nbc. <!-- Here is a comment block in a code block. -->""",
-     """\t<p>Here is some text with a <!-- Commented out[1] --> block.</p>\n\n\t<p><!-- Here is a single <span>line</span> comment block --></p>\n\n\t<p><!-- Here is a whole\nmultiline\n<span>HTML</span>\nComment\n--></p>\n\n<pre><code><!-- Here is a comment block in a code block. -->\n</code></pre>"""),
+     """\t<p>Here is some text with a <!-- Commented out[1] --> block.</p>\n\n\t<p><!-- Here is a single <span>line</span> comment block --></p>\n\n\t<p><!-- Here is a whole\nmultiline\n<span>HTML</span>\nComment\n--></p>\n\n<pre><code><!-- Here is a comment block in a code block. --></code></pre>"""),
     (""""Textile(c)" is a registered(r) 'trademark' of Textpattern(tm) -- or TXP(That's textpattern!) -- at least it was - back in '88 when 2x4 was (+/-)5(o)C ... QED!\n\np{font-size: 200%;}. 2(1/4) 3(1/2) 4(3/4)""",
      """\t<p>“Textile©” is a registered® ‘trademark’ of Textpattern™ — or <acronym title="That’s textpattern!"><span class="caps">TXP</span></acronym> — at least it was – back in ’88 when 2×4 was ±5°C … <span class="caps">QED</span>!</p>\n\n\t<p style="font-size: 200%;">2¼ 3½ 4¾</p>"""),
     ("""|=. Testing colgroup and col syntax\n|:\\5. 80\n|a|b|c|d|e|\n\n|=. Testing colgroup and col syntax|\n|:\\5. 80|\n|a|b|c|d|e|""", """\t<table>\n\t<caption>Testing colgroup and col syntax</caption>\n\t<colgroup span="5" width="80">\n\t</colgroup>\n\t\t<tr>\n\t\t\t<td>a</td>\n\t\t\t<td>b</td>\n\t\t\t<td>c</td>\n\t\t\t<td>d</td>\n\t\t\t<td>e</td>\n\t\t</tr>\n\t</table>\n\n\t<table>\n\t<caption>Testing colgroup and col syntax</caption>\n\t<colgroup span="5" width="80">\n\t</colgroup>\ [...]
@@ -230,7 +230,7 @@ xhtml_known_values = (
     (""";(class#id) Term 1\n: Def 1\n: Def 2\n: Def 3""",
      """\t<dl class="class" id="id">\n\t\t<dt>Term 1</dt>\n\t\t<dd>Def 1</dd>\n\t\t<dd>Def 2</dd>\n\t\t<dd>Def 3</dd>\n\t</dl>"""),
     ("""*Here is a comment*\n\nHere is *(class)a comment*\n\n*(class)Here is a class* that is a little extended and is\n*followed* by a strong word!\n\nbc. ; Content-type: text/javascript\n; Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0\n; Expires: Sat, 24 Jul 2003 05:00:00 GMT\n; Last-Modified: Wed, 1 Jan 2025 05:00:00 GMT\n; Pragma: no-cache\n\n*123 test*\n\n*test 123*\n\n**123 test**\n\n**test 123**""",
-     """\t<p><strong>Here is a comment</strong></p>\n\n\t<p>Here is <strong class="class">a comment</strong></p>\n\n\t<p><strong class="class">Here is a class</strong> that is a little extended and is<br />\n<strong>followed</strong> by a strong word!</p>\n\n<pre><code>; Content-type: text/javascript\n; Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0\n; Expires: Sat, 24 Jul 2003 05:00:00 GMT\n; Last-Modified: Wed, 1 Jan 2025 05:00:00 GMT\n; Pragma [...]
+     """\t<p><strong>Here is a comment</strong></p>\n\n\t<p>Here is <strong class="class">a comment</strong></p>\n\n\t<p><strong class="class">Here is a class</strong> that is a little extended and is<br />\n<strong>followed</strong> by a strong word!</p>\n\n<pre><code>; Content-type: text/javascript\n; Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0\n; Expires: Sat, 24 Jul 2003 05:00:00 GMT\n; Last-Modified: Wed, 1 Jan 2025 05:00:00 GMT\n; Pragma [...]
     ("""#_(first#list) one\n# two\n# three\n\ntest\n\n#(ordered#list2).\n# one\n# two\n# three\n\ntest\n\n#_(class_4).\n# four\n# five\n# six\n\ntest\n\n#_ seven\n# eight\n# nine\n\ntest\n\n# one\n# two\n# three\n\ntest\n\n#22 22\n# 23\n# 24""",
      """\t<ol class="first" id="list" start="1">\n\t\t<li>one</li>\n\t\t<li>two</li>\n\t\t<li>three</li>\n\t</ol>\n\n\t<p>test</p>\n\n\t<ol class="ordered" id="list2">\n\t\t<li>one</li>\n\t\t<li>two</li>\n\t\t<li>three</li>\n\t</ol>\n\n\t<p>test</p>\n\n\t<ol class="class_4" start="4">\n\t\t<li>four</li>\n\t\t<li>five</li>\n\t\t<li>six</li>\n\t</ol>\n\n\t<p>test</p>\n\n\t<ol start="7">\n\t\t<li>seven</li>\n\t\t<li>eight</li>\n\t\t<li>nine</li>\n\t</ol>\n\n\t<p>test</p>\n\n\t<ol>\n\t\t<li> [...]
     ("""# one\n##3 one.three\n## one.four\n## one.five\n# two\n\ntest\n\n#_(continuation#section2).\n# three\n# four\n##_ four.six\n## four.seven\n# five\n\ntest\n\n#21 twenty-one\n# twenty-two""",
diff --git a/textile/__main__.py b/textile/__main__.py
index 481b976..1845961 100644
--- a/textile/__main__.py
+++ b/textile/__main__.py
@@ -13,12 +13,18 @@ def main():
                    'accepts input as a file or stdin and can write out to '
                    'a file or stdout.')
     parser = argparse.ArgumentParser(prog=prog, description=description)
+    parser.add_argument('-v', '--version', action='store_true',
+                        help='show the version number and exit')
     parser.add_argument('infile', nargs='?', type=argparse.FileType(),
                         help='a textile file to be converted')
     parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
                         help='write the output of infile to outfile')
     options = parser.parse_args()
 
+    if options.version:
+        print(textile.VERSION)
+        sys.exit()
+
     infile = options.infile or sys.stdin
     outfile = options.outfile or sys.stdout
     with infile:
diff --git a/textile/core.py b/textile/core.py
index 692cca4..695b7e7 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -230,7 +230,7 @@ class Textile(object):
         self.unreferencedNotes = OrderedDict()
         self.notelist_cache = OrderedDict()
 
-        if text == '':
+        if text.strip() == '':
             return text
 
         if self.restricted:
@@ -309,8 +309,13 @@ class Textile(object):
 
             m = re.search(r"^(?P<tl>[#*;:]+)(?P<st>_|\d+)?(?P<atts>{0})[ .]"
                     "(?P<content>.*)$".format(cls_re_s), line, re.S)
-            tl, start, atts, content = m.groups()
-            content = content.strip()
+            if m:
+                tl, start, atts, content = m.groups()
+                content = content.strip()
+            else:
+                result.append(line)
+                continue
+
             nl = ''
             ltype = list_type(tl)
             tl_tags = {';': 'dt', ':': 'dd'}
@@ -365,7 +370,7 @@ class Textile(object):
             if tl not in ls:
                 ls[tl] = 1
                 itemtag = ("\n{0}\t<{1}>{2}".format(tabs, litem, content) if
-                           showitem else '')
+                            showitem else '')
                 line = "<{0}l{1}{2}>{3}".format(ltype, atts, start, itemtag)
             else:
                 line = ("\t<{0}{1}>{2}".format(litem, atts, content) if
@@ -459,7 +464,7 @@ class Textile(object):
             else:
                 # if we're inside an extended block, add the text from the
                 # previous extension to the front
-                if ext:
+                if ext and out:
                     line = '{0}\n\n{1}'.format(out.pop(), line)
                 whitespace = ' \t\n\r\f\v'
                 if ext or not line[0] in whitespace:
@@ -488,7 +493,7 @@ class Textile(object):
                 cite = ''
                 graf = ''
 
-        if ext:
+        if ext and out:
             out.append(generate_tag(block.outer_tag, out.pop(),
                 block.outer_atts))
         return '\n\n'.join(out)
@@ -666,7 +671,10 @@ class Textile(object):
                             balanced = balanced - 1
                         if re.search(r'\S$', possibility, flags=re.U): # pragma: no branch
                             balanced = balanced + 1
-                        possibility = possible_start_quotes.pop()
+                        try:
+                            possibility = possible_start_quotes.pop()
+                        except IndexError:
+                            break
                     else:
                         # If quotes occur next to each other, we get zero
                         # length strings.  eg. ...""Open the door,
@@ -750,9 +758,9 @@ class Textile(object):
             $'''.format(cls_re_s, regex_snippets['space']), inner,
                 flags=re.X | re.U)
 
-        atts = m.group('atts') or ''
-        text = m.group('text') or '' or inner
-        title = m.group('title') or ''
+        atts = (m and m.group('atts')) or ''
+        text = (m and m.group('text')) or inner
+        title = (m and m.group('title')) or ''
 
         pop, tight = '', ''
         counts = { '[': None, ']': url.count(']'), '(': None, ')': None }
@@ -811,7 +819,7 @@ class Textile(object):
             """If we find a closing square bracket we are going to see if it is
             balanced.  If it is balanced with matching opening bracket then it
             is part of the URL else we spit it back out of the URL."""
-            # If counts['['] is None, count the occurrences of '[' 
+            # If counts['['] is None, count the occurrences of '['
             counts['['] = counts['['] or url.count('[')
 
             if counts['['] == counts[']']:
@@ -1010,7 +1018,7 @@ class Textile(object):
             \!                  # opening !
             (\<|\=|\>)?         # optional alignment atts
             ({0})               # optional style,class atts
-            (?:\. )?            # optional dot-space
+            (?:\.\s)?           # optional dot-space
             ([^\s(!]+)          # presume this is the src
             \s?                 # optional space
             (?:\(([^\)]+)\))?   # optional title
diff --git a/textile/objects/block.py b/textile/objects/block.py
index 920147a..89e6b2e 100644
--- a/textile/objects/block.py
+++ b/textile/objects/block.py
@@ -1,3 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
 try:
     from collections import OrderedDict
 except ImportError:
@@ -100,8 +103,6 @@ class Block(object):
             if self.tag == 'bc':
                 i_tag = 'code'
             content = encode_html(self.content)
-            if not self.ext:
-                content = '{0}\n'.format(content)
             self.content = self.textile.shelve(content)
             self.outer_tag = 'pre'
             self.outer_atts = self.attributes
diff --git a/textile/version.py b/textile/version.py
index b4ab188..ce59314 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '2.3.5'
+VERSION = '2.3.12'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-textile.git



More information about the Python-modules-commits mailing list