Skip to content

Commit

Permalink
Merge branch 'release/4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Nov 23, 2021
2 parents 23e7746 + 03ba820 commit 819fabb
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
# PyPy versions
- "pypy3"
# command to install dependencies
install:
- imagesize=''
- pip install -U coveralls pytest pytest-cov coverage codecov
- pip install -U pytest pytest-cov coverage codecov
- if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
- pip install -e ".${imagesize}"
# command to run tests
script: py.test
after_success:
- coveralls
- codecov
14 changes: 13 additions & 1 deletion README.textile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://coveralls.io/repos/github/textile/python-textile/badge.svg!:https://coveralls.io/github/textile/python-textile?branch=master !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile !https://img.shields.io/pypi/pyversions/textile! !https://img.shields.io/pypi/wheel/textile!

h1. python-textile

Expand Down Expand Up @@ -43,3 +43,15 @@ bc.. import textile
h3. Notes:

* Active development supports Python 3.5 or later.

h3. Running Tests

To run the test suite, use pytest. `pytest-cov` is required as well.

When textile is installed locally:

bc.. pytest

When textile is not installed locally:

bc.. PYTHONPATH=. pytest
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
testpaths = tests
addopts = --cov=textile --cov-report=html --cov-append --cov-report=term-missing
addopts = --cov=textile --cov-report=html --cov-append --cov-report=term-missing
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

20 changes: 2 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@
import sys


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__)
with open(os.path.join(basedir, 'textile/version.py')) as f:
Expand Down Expand Up @@ -48,6 +33,7 @@ def get_version():
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords='textile,text,html markup',
Expand All @@ -60,10 +46,8 @@ def get_version():
'imagesize': ['Pillow>=3.0.0'],
},
entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-cov'],
cmdclass = {'test': PyTest},
include_package_data=True,
zip_safe=False,
python_requires='~=3.5',
python_requires='>=3.5',
)
16 changes: 14 additions & 2 deletions tests/fixtures/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<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> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>
<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://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a> <img alt="" src="https://img.shields.io/pypi/pyversions/textile" /> <img alt="" src="https://img.shields.io/pypi/wheel/textile" /></p>

<h1>python-textile</h1>

Expand Down Expand Up @@ -48,4 +48,16 @@

<ul>
<li>Active development supports Python 3.5 or later.</li>
</ul>
</ul>

<h3>Running Tests</h3>

<p>To run the test suite, use pytest. `pytest-cov` is required as well.</p>

<p>When textile is installed locally:</p>

<pre><code>pytest

When textile is not installed locally:</code></pre>

<pre>PYTHONPATH=. pytest</pre>
10 changes: 10 additions & 0 deletions tests/test_getRefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ def test_getRefs():
result = t.urlrefs
expect = {'Google': 'http://www.google.com'}
assert result == expect

t2 = Textile()

result = t2.getRefs("my ftp [ftp]ftp://example.com")
expect = 'my ftp '
assert result == expect

result = t2.urlrefs
expect = {'ftp': 'ftp://example.com'}
assert result == expect
14 changes: 10 additions & 4 deletions textile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ def __init__(self, restricted=False, lite=False, noimage=False,
else:
self.url_schemes = self.unrestricted_url_schemes

all_schemes_re_s = '|'.join([
'(?:{0})'.format(scheme)
for scheme in self.url_schemes
])
self.url_ref_regex = re.compile(
r'(?:(?<=^)|(?<=\s))\[(.+)\]\s?((?:{0}:\/\/|\/)\S+)(?=\s|$)'.format(all_schemes_re_s),
re.U
)

def parse(self, text, rel=None, sanitize=False):
"""Parse the input text as textile and return html output."""
self.notes = OrderedDict()
Expand Down Expand Up @@ -612,10 +621,7 @@ def glyphs(self, text):

def getRefs(self, text):
"""Capture and store URL references in self.urlrefs."""
pattern = re.compile(r'(?:(?<=^)|(?<=\s))\[(.+)\]((?:http(?:s?):\/\/|\/)\S+)(?=\s|$)',
re.U)
text = pattern.sub(self.refs, text)
return text
return self.url_ref_regex.sub(self.refs, text)

def refs(self, match):
flag, url = match.groups()
Expand Down
2 changes: 1 addition & 1 deletion textile/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '4.0.1'
VERSION = '4.0.2'

0 comments on commit 819fabb

Please sign in to comment.