Skip to content

Commit a1c31e5

Browse files
committed
Merge branch 'release/4.0.3'
2 parents 6cdcd52 + 64ab026 commit a1c31e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+978
-567
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
ignore =
3+
# line too long
4+
E501
5+
exclude =
6+
build/

.github/workflows/lint_and_test.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: python-textile
3+
4+
on: [push]
5+
6+
jobs:
7+
lint_and_test:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
12+
image_size: ['true', 'false']
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Python flake8 Lint
20+
uses: py-actions/flake8@v2.3.0
21+
- name: Install dependencies
22+
run: |
23+
imagesize=''
24+
pip install -U pytest pytest-cov coverage codecov
25+
if [[ ${{ matrix.image_size }} == true ]] ; then imagesize='[imagesize]' ; fi
26+
pip install -e ".${imagesize}"
27+
- name: run tests
28+
run: |
29+
pytest
30+
- name: Codecov
31+
uses: codecov/codecov-action@v4
32+
env:
33+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ develop-eggs
2121
.DS_Store
2222
*.swp
2323
.tox
24+
README.txt

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

CHANGELOG.textile

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

3+
h2. Version 4.0.3
4+
* Update supported Python versions to 3.8 - 3.12 ("#83":https://github.com/textile/python-textile/issues/83)
5+
* Replace html5lib with nh3 for html sanitization
6+
* General code cleanup
7+
* Bugfixes:
8+
** Wrong HTML output when "bc.." is the very last in the document ("#81":https://github.com/textile/python-textile/issues/81)
9+
* Other:
10+
** Use github actions instead of travis for automated testing
11+
312
h2. Version 4.0.2
413
* Bugfixes:
514
** Support non-http schemas in url refs ("#75":https://github.com/textile/python-textile/pull/75)

CONTRIBUTORS.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ Alex Shiels
77
Jason Samsa
88
Kurt Raschke
99
Dave Brondsema
10-
Dmitry Shachnev
10+
Dmitry Shachnev
11+
Kirill Mavreshko
12+
Brad Schoening

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
clean:
2+
$(RM) README.txt
3+
$(RM) -r ./dist ./build
4+
5+
generate_pypi_README:
6+
${VIRTUAL_ENV}/bin/pytextile README.textile | sed -e 's/^\t//' > README.txt
7+
8+
build: generate_pypi_README
9+
python -m build
10+
11+
upload_to_test: build
12+
twine check ./dist/*
13+
twine upload --repository test_textile ./dist/*
14+
15+
upload_to_prod: build
16+
twine check ./dist/*
17+
# for now, don't actually upload to prod PyPI, just output the command to do so.
18+
@echo "twine upload --repository textile ./dist/*"

README.textile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
!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!
1+
!https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml/badge.svg(python-textile)!:https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml !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!
22

33
h1. python-textile
44

5-
python-textile is a Python port of "Textile":http://txstyle.org/, Dean Allen's humane web text generator.
5+
python-textile is a Python port of "Textile":https://textile-lang.com/, Dean Allen's humane web text generator.
66

77
h2. Installation
88

99
@pip install textile@
1010

1111
Dependencies:
12-
* "html5lib":https://pypi.org/project/html5lib/
12+
* "nh3":https://pypi.org/project/nh3/
1313
* "regex":https://pypi.org/project/regex/ (The regex package causes problems with PyPy, and is not installed as a dependency in such environments. If you are upgrading a textile install on PyPy which had regex previously included, you may need to uninstall it.)
1414

1515
Optional dependencies include:
@@ -42,16 +42,16 @@ bc.. import textile
4242

4343
h3. Notes:
4444

45-
* Active development supports Python 3.5 or later.
45+
* Active development supports Python 3.8 or later.
4646

4747
h3. Running Tests
4848

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

5151
When textile is installed locally:
5252

53-
bc.. pytest
53+
bc. pytest
5454

5555
When textile is not installed locally:
5656

57-
bc.. PYTHONPATH=. pytest
57+
bc. PYTHONPATH=. pytest

pyproject.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools-scm", "nh3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "textile"
7+
authors = [
8+
{ name = "Dennis Burke", email = "ikirudennis@gmail.com"}
9+
]
10+
description = 'Textile processing for python.'
11+
classifiers = [
12+
'Development Status :: 5 - Production/Stable',
13+
'Environment :: Web Environment',
14+
'Intended Audience :: Developers',
15+
'License :: OSI Approved :: BSD License',
16+
'Operating System :: OS Independent',
17+
'Programming Language :: Python',
18+
'Programming Language :: Python :: 3',
19+
'Programming Language :: Python :: 3 :: Only',
20+
'Programming Language :: Python :: 3.8',
21+
'Programming Language :: Python :: 3.9',
22+
'Programming Language :: Python :: 3.10',
23+
'Programming Language :: Python :: 3.11',
24+
'Programming Language :: Python :: 3.12',
25+
'Topic :: Software Development :: Libraries :: Python Modules',
26+
]
27+
dynamic = ["version",]
28+
dependencies = [
29+
'nh3',
30+
'regex>1.0; implementation_name != "pypy"',
31+
]
32+
requires-python = '>=3.8'
33+
keywords = ['textile', 'text', 'html markup']
34+
# Use the following command to generate a README.txt which is compatible with
35+
# pypi's readme rendering:
36+
# pytextile README.textile | sed -e 's/^\t//' > README.txt
37+
readme = {file = 'README.txt', content-type = 'text/markdown'}
38+
39+
[project.optional-dependencies]
40+
develop = ['pytest', 'pytest-cov']
41+
imagesize = ['Pillow>=3.0.0',]
42+
43+
[project.urls]
44+
Homepage = "https://github.com/textile/python-textile"
45+
Repository = "https://github.com/textile/python-textile.git"
46+
Issues = "https://github.com/textile/python-textile/issues"
47+
48+
[project.scripts]
49+
pytextile = "textile.__main__:main"
50+
51+
[tool.setuptools.dynamic]
52+
version = {attr = "textile.__version__"}

setup.py

Lines changed: 0 additions & 53 deletions
This file was deleted.
File renamed without changes.

tests/fixtures/README.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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://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>
1+
<p><a href="https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml"><img alt="python-textile" src="https://github.com/textile/python-textile/actions/workflows/lint_and_test.yml/badge.svg" title="python-textile" /></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>
22

33
<h1>python-textile</h1>
44

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>
5+
<p>python-textile is a Python port of <a href="https://textile-lang.com/">Textile</a>, Dean Allen&#8217;s humane web text generator.</p>
66

77
<h2>Installation</h2>
88

99
<p><code>pip install textile</code></p>
1010

1111
<p>Dependencies:
1212
<ul>
13-
<li><a href="https://pypi.org/project/html5lib/">html5lib</a></li>
13+
<li><a href="https://pypi.org/project/nh3/">nh3</a></li>
1414
<li><a href="https://pypi.org/project/regex/">regex</a> (The regex package causes problems with PyPy, and is not installed as a dependency in such environments. If you are upgrading a textile install on PyPy which had regex previously included, you may need to uninstall it.)</li>
1515
</ul></p>
1616

@@ -47,7 +47,7 @@
4747
<h3>Notes:</h3>
4848

4949
<ul>
50-
<li>Active development supports Python 3.5 or later.</li>
50+
<li>Active development supports Python 3.8 or later.</li>
5151
</ul>
5252

5353
<h3>Running Tests</h3>
@@ -56,8 +56,8 @@
5656

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

59-
<pre><code>pytest
59+
<pre><code>pytest</code></pre>
6060

61-
When textile is not installed locally:</code></pre>
61+
<p>When textile is not installed locally:</p>
6262

63-
<pre>PYTHONPATH=. pytest</pre>
63+
<pre><code>PYTHONPATH=. pytest</code></pre>

tests/test_attributes.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from typing import OrderedDict
12
from textile.utils import parse_attributes
2-
import re
3+
34

45
def test_parse_attributes():
56
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
@@ -13,3 +14,11 @@ def test_parse_attributes():
1314
assert parse_attributes('<') == {'style': 'text-align:left;'}
1415
assert parse_attributes('(c#i)') == {'class': 'c', 'id': 'i'}
1516
assert parse_attributes('\\2 100', element='col') == {'span': '2', 'width': '100'}
17+
18+
19+
def test_parse_attributes_edge_cases():
20+
result = parse_attributes('(:c#i)')
21+
expect = OrderedDict({'id': 'i'})
22+
assert result == expect
23+
24+
assert parse_attributes('(<)') == OrderedDict()

tests/test_block.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import unicode_literals
2-
31
import textile
42
from textile.objects import Block
53

@@ -8,6 +6,7 @@
86
except ImportError:
97
from ordereddict import OrderedDict
108

9+
1110
def test_block():
1211
t = textile.Textile()
1312
result = t.block('h1. foobar baby')
@@ -16,15 +15,14 @@ def test_block():
1615

1716
b = Block(t, "bq", "", None, "", "Hello BlockQuote")
1817
expect = ('blockquote', OrderedDict(), 'p', OrderedDict(),
19-
'Hello BlockQuote')
18+
'Hello BlockQuote')
2019
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
2120
assert result == expect
2221

2322
b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote")
24-
citation = '{0}1:url'.format(t.uid)
2523
expect = ('blockquote', OrderedDict([('cite',
26-
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
27-
'Hello BlockQuote')
24+
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
25+
'Hello BlockQuote')
2826
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
2927
assert result == expect
3028

@@ -40,6 +38,7 @@ def test_block():
4038
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
4139
assert result == expect
4240

41+
4342
def test_block_tags_false():
4443
t = textile.Textile(block_tags=False)
4544
assert t.block_tags is False
@@ -48,13 +47,15 @@ def test_block_tags_false():
4847
expect = 'test'
4948
assert result == expect
5049

50+
5151
def test_blockcode_extended():
5252
input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test'
5353
expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>\n\n\t<p>test</p>'
5454
t = textile.Textile()
5555
result = t.parse(input)
5656
assert result == expect
5757

58+
5859
def test_blockcode_in_README():
5960
with open('README.textile') as f:
6061
readme = ''.join(f.readlines())
@@ -63,13 +64,15 @@ def test_blockcode_in_README():
6364
expect = ''.join(f.readlines())
6465
assert result == expect
6566

67+
6668
def test_blockcode_comment():
6769
input = '###.. block comment\nanother line\n\np. New line'
6870
expect = '\t<p>New line</p>'
6971
t = textile.Textile()
7072
result = t.parse(input)
7173
assert result == expect
7274

75+
7376
def test_extended_pre_block_with_many_newlines():
7477
"""Extra newlines in an extended pre block should not get cut down to only
7578
two."""

0 commit comments

Comments
 (0)