Skip to content

Commit

Permalink
Merge branch 'release/4.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Sep 22, 2024
2 parents 6cdcd52 + 64ab026 commit a1c31e5
Show file tree
Hide file tree
Showing 44 changed files with 978 additions and 567 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
ignore =
# line too long
E501
exclude =
build/
33 changes: 33 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: python-textile

on: [push]

jobs:
lint_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Python flake8 Lint
uses: py-actions/[email protected]
- name: Install dependencies
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
if [[ ${{ matrix.image_size }} == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
pytest
- name: Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ develop-eggs
.DS_Store
*.swp
.tox
README.txt
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
h1. Textile Changelog

h2. Version 4.0.3
* Update supported Python versions to 3.8 - 3.12 ("#83":https://github.com/textile/python-textile/issues/83)
* Replace html5lib with nh3 for html sanitization
* General code cleanup
* Bugfixes:
** Wrong HTML output when "bc.." is the very last in the document ("#81":https://github.com/textile/python-textile/issues/81)
* Other:
** Use github actions instead of travis for automated testing

h2. Version 4.0.2
* Bugfixes:
** Support non-http schemas in url refs ("#75":https://github.com/textile/python-textile/pull/75)
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ Alex Shiels
Jason Samsa
Kurt Raschke
Dave Brondsema
Dmitry Shachnev
Dmitry Shachnev
Kirill Mavreshko
Brad Schoening
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
clean:
$(RM) README.txt
$(RM) -r ./dist ./build

generate_pypi_README:
${VIRTUAL_ENV}/bin/pytextile README.textile | sed -e 's/^\t//' > README.txt

build: generate_pypi_README
python -m build

upload_to_test: build
twine check ./dist/*
twine upload --repository test_textile ./dist/*

upload_to_prod: build
twine check ./dist/*
# for now, don't actually upload to prod PyPI, just output the command to do so.
@echo "twine upload --repository textile ./dist/*"
12 changes: 6 additions & 6 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
!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!
!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!

h1. python-textile

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

h2. Installation

@pip install textile@

Dependencies:
* "html5lib":https://pypi.org/project/html5lib/
* "nh3":https://pypi.org/project/nh3/
* "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.)

Optional dependencies include:
Expand Down Expand Up @@ -42,16 +42,16 @@ bc.. import textile

h3. Notes:

* Active development supports Python 3.5 or later.
* Active development supports Python 3.8 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
bc. pytest

When textile is not installed locally:

bc.. PYTHONPATH=. pytest
bc. PYTHONPATH=. pytest
52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[build-system]
requires = ["setuptools", "setuptools-scm", "nh3"]
build-backend = "setuptools.build_meta"

[project]
name = "textile"
authors = [
{ name = "Dennis Burke", email = "[email protected]"}
]
description = 'Textile processing for python.'
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Software Development :: Libraries :: Python Modules',
]
dynamic = ["version",]
dependencies = [
'nh3',
'regex>1.0; implementation_name != "pypy"',
]
requires-python = '>=3.8'
keywords = ['textile', 'text', 'html markup']
# Use the following command to generate a README.txt which is compatible with
# pypi's readme rendering:
# pytextile README.textile | sed -e 's/^\t//' > README.txt
readme = {file = 'README.txt', content-type = 'text/markdown'}

[project.optional-dependencies]
develop = ['pytest', 'pytest-cov']
imagesize = ['Pillow>=3.0.0',]

[project.urls]
Homepage = "https://github.com/textile/python-textile"
Repository = "https://github.com/textile/python-textile.git"
Issues = "https://github.com/textile/python-textile/issues"

[project.scripts]
pytextile = "textile.__main__:main"

[tool.setuptools.dynamic]
version = {attr = "textile.__version__"}
53 changes: 0 additions & 53 deletions setup.py

This file was deleted.

File renamed without changes.
14 changes: 7 additions & 7 deletions tests/fixtures/README.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<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>
<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>

<h1>python-textile</h1>

<p>python-textile is a Python port of <a href="http://txstyle.org/">Textile</a>, Dean Allen&#8217;s humane web text generator.</p>
<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>

<h2>Installation</h2>

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

<p>Dependencies:
<ul>
<li><a href="https://pypi.org/project/html5lib/">html5lib</a></li>
<li><a href="https://pypi.org/project/nh3/">nh3</a></li>
<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>
</ul></p>

Expand Down Expand Up @@ -47,7 +47,7 @@
<h3>Notes:</h3>

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

<h3>Running Tests</h3>
Expand All @@ -56,8 +56,8 @@

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

<pre><code>pytest
<pre><code>pytest</code></pre>

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

<pre>PYTHONPATH=. pytest</pre>
<pre><code>PYTHONPATH=. pytest</code></pre>
11 changes: 10 additions & 1 deletion tests/test_attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import OrderedDict
from textile.utils import parse_attributes
import re


def test_parse_attributes():
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
Expand All @@ -13,3 +14,11 @@ def test_parse_attributes():
assert parse_attributes('<') == {'style': 'text-align:left;'}
assert parse_attributes('(c#i)') == {'class': 'c', 'id': 'i'}
assert parse_attributes('\\2 100', element='col') == {'span': '2', 'width': '100'}


def test_parse_attributes_edge_cases():
result = parse_attributes('(:c#i)')
expect = OrderedDict({'id': 'i'})
assert result == expect

assert parse_attributes('(<)') == OrderedDict()
15 changes: 9 additions & 6 deletions tests/test_block.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import textile
from textile.objects import Block

Expand All @@ -8,6 +6,7 @@
except ImportError:
from ordereddict import OrderedDict


def test_block():
t = textile.Textile()
result = t.block('h1. foobar baby')
Expand All @@ -16,15 +15,14 @@ def test_block():

b = Block(t, "bq", "", None, "", "Hello BlockQuote")
expect = ('blockquote', OrderedDict(), 'p', OrderedDict(),
'Hello BlockQuote')
'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect

b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote")
citation = '{0}1:url'.format(t.uid)
expect = ('blockquote', OrderedDict([('cite',
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
'Hello BlockQuote')
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect

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


def test_block_tags_false():
t = textile.Textile(block_tags=False)
assert t.block_tags is False
Expand All @@ -48,13 +47,15 @@ def test_block_tags_false():
expect = 'test'
assert result == expect


def test_blockcode_extended():
input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test'
expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>\n\n\t<p>test</p>'
t = textile.Textile()
result = t.parse(input)
assert result == expect


def test_blockcode_in_README():
with open('README.textile') as f:
readme = ''.join(f.readlines())
Expand All @@ -63,13 +64,15 @@ def test_blockcode_in_README():
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


def test_extended_pre_block_with_many_newlines():
"""Extra newlines in an extended pre block should not get cut down to only
two."""
Expand Down
Loading

0 comments on commit a1c31e5

Please sign in to comment.