From c6f9c5df8c05e211c35e43c14f19cf27dfd9f447 Mon Sep 17 00:00:00 2001
From: Stephen Altamirano To run the test suite, use pytest. `pytest-cov` is required as well. When textile is installed locally: notelist({0})(?:\:([\w|{1}]))?([\^!]?)(\+?)'
- r'\.?[\s]*python-textile
From 6b787c951b65b5850f598ff348ef3b5402048177 Mon Sep 17 00:00:00 2001
From: Stephen Altamirano
\ No newline at end of file
+
+
+ Running Tests
+
+
+
+pytest
+
+When textile is not installed locally:PYTHONPATH=. pytest
\ No newline at end of file
From e66784a84ca2382c08591fbbfdc713adf8d0a90e Mon Sep 17 00:00:00 2001
From: Dennis Burke 
', match.group(3))
return '<{0}{1}>{2}{3}'.format(match.group(1), match.group(2), content,
- match.group(4))
+ match.group(4))
def block(self, text):
if not self.lite:
@@ -450,8 +449,8 @@ def block(self, text):
eat_whitespace = False
pattern = (r'^(?P
text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\n\ttest
' @@ -54,6 +57,7 @@ def test_blockcode_extended(): result = t.parse(input) assert result == expect + def test_blockcode_in_README(): with open('README.textile') as f: readme = ''.join(f.readlines()) @@ -62,6 +66,7 @@ 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 = '\tNew line
' From 73adb81c5cf614b80aebe4121a94648770e10909 Mon Sep 17 00:00:00 2001 From: Dennis BurkeYACC1
', html) is not None + def test_Footnote(): html = textile.textile('This is covered elsewhere[1].\n\nfn1. Down here, in fact.\n\nfn2. Here is another footnote.') assert re.search(r'^\tThis is covered elsewhere1.
\n\n\t1 Down here, in fact.
\n\n\t2 Here is another footnote.
$', html) is not None @@ -24,6 +26,7 @@ def test_Footnote(): html = textile.textile('''See[4!] for details.\n\nfn4^. Here are the details.''') assert re.search(r'^\tSee4 for details.
\n\n\t4 Here are the details.
$', html) is not None + def test_issue_35(): result = textile.textile('"z"') expect = '\t“z”
' @@ -33,8 +36,9 @@ def test_issue_35(): expect = '\t“ z”
' assert result == expect + def test_restricted(): - #Note that the HTML is escaped, thus rendering the " result = textile.textile_restricted(test) expect = "\tHere is some text.
\n<script>alert(‘hello world’)</script>
текст1
$', re.U).search(html) is not None + def test_autolinking(): test = """some text "test":http://www.google.com http://www.google.com "$":http://www.google.com""" result = """\tsome text test http://www.google.com www.google.com
""" @@ -104,6 +110,7 @@ def test_autolinking(): assert result == expect + def test_sanitize(): test = "a paragraph of benign text" result = "\ta paragraph of benign text
" @@ -120,14 +127,16 @@ def test_sanitize(): expect = textile.Textile(html_type='html5').parse(test, sanitize=True) assert result == expect + def test_imagesize(): - PIL = pytest.importorskip('PIL') # noqa: F841 + PIL = pytest.importorskip('PIL') # noqa: F841 test = "!http://www.google.com/intl/en_ALL/images/srpr/logo1w.png!" result = '\t
See2 for details, and later, reference it again2.
\n\n\t2 Here are the details.
$' assert re.compile(searchstring).search(html) is not None + def test_footnote_without_reflink(): html = textile.textile('''See[3!] for details.\n\nfn3. Here are the details.''') searchstring = r'^\tSee3 for details.
\n\n\t3 Here are the details.
$' assert re.compile(searchstring).search(html) is not None + def testSquareBrackets(): html = textile.textile("""1[^st^], 2[^nd^], 3[^rd^]. 2 log[~n~]\n\nA close[!http://textpattern.com/favicon.ico!]image.\nA tight["text":http://textpattern.com/]link.\nA ["footnoted link":http://textpattern.com/][182].""") searchstring = r'^\t1st, 2nd, 3rd. 2 logn
\n\n\tA closeimage.
\nA tighttextlink.
\nA footnoted link182.
A link that contains a\nnewline raises an exception.
' assert result == expect + def test_rel_attribute(): t = Textile(rel='nofollow') result = t.parse('"$":http://domain.tld') expect = '\t' assert result == expect + def test_quotes_in_link_text(): """quotes in link text are tricky.""" test = '""this is a quote in link text"":url' From d0b90435eb3f7f4bc17925544f962d14d92b908a Mon Sep 17 00:00:00 2001 From: Dennis Burkegoogle.com google.com blackhole@sun.comet
' assert result == expect + def test_github_issue_17(): result = textile.textile('!http://www.ox.ac.uk/favicon.ico!') expect = '\tThis is a link to a Wikipedia article about Textile.
' assert result == expect + def test_github_issue_21(): - text = '''h1. xml example + text = ('''h1. xml example -bc. +bc. ''' + '''\n<foo>\n bar\n</foo>'
assert result == expect
+
def test_github_issue_22():
text = '''_(artist-name)Ty Segall_’s'''
result = textile.textile(text)
expect = '\tTy Segall’s
' assert result == expect + def test_github_issue_26(): text = '' result = textile.textile(text) expect = '' assert result == expect + def test_github_issue_27(): test = """* Folders with ":" in their names are displayed with a forward slash "/" instead. (Filed as "#4581709":/test/link, which was considered "normal behaviour" - quote: "Please note that Finder presents the 'Carbon filesystem' view, regardless of the underlying filesystem.")""" result = textile.textile(test) expect = """\tOf course there’s a lot more error handling to do (and useful data to glean off the XML), but being able to cut through all the usual parsing crap is immensely gratifying.
""") assert result == expect + def test_github_issue_30(): - text ='"Tëxtíle (Tëxtíle)":http://lala.com' + text = '"Tëxtíle (Tëxtíle)":http://lala.com' result = textile.textile(text) expect = '\t' assert result == expect - text ='!http://lala.com/lol.gif(♡ imáges)!' + text = '!http://lala.com/lol.gif(♡ imáges)!' result = textile.textile(text) expect = '\t

smart ‘quotes’ are not smart!' assert result == expect + def test_github_issue_45(): """Incorrect transform unicode url""" text = '"test":https://myabstractwiki.ru/index.php/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0' @@ -143,6 +159,7 @@ def test_github_issue_45(): expect = '\t' assert result == expect + def test_github_issue_46(): """Key error on mal-formed numbered lists. CAUTION: both the input and the ouput are ugly.""" @@ -153,6 +170,7 @@ def test_github_issue_46(): result = textile.textile(text) assert result == expect + def test_github_issue_47(): """Incorrect wrap pre-formatted value""" text = '''pre.. word @@ -172,6 +190,7 @@ def test_github_issue_47(): yet anothe word''' assert result == expect + def test_github_issue_49(): """Key error on russian hash-route link""" s = '"link":https://ru.vuejs.org/v2/guide/components.html#Входные-параметры' @@ -179,6 +198,7 @@ def test_github_issue_49(): expect = '\t' assert result == expect + def test_github_issue_50(): """Incorrect wrap code with Java generics in pre""" test = ('pre.. public class Tynopet
This is some TEXT inside a "Code BLOCK"
@@ -299,6 +325,7 @@ def test_github_pull_61():
result = t.parse(test)
assert result == expect
+
def test_github_pull_62():
"""Fix for paragraph multiline, only last paragraph is rendered
correctly"""
@@ -341,6 +368,7 @@ def test_github_pull_62():
result = t.parse(test)
assert result == expect
+
def test_github_pull_63():
"""Forgot to set multiline_para to False"""
test = '''p.. First one 'is'
From ed17a4f0fd10acbb51a8a6c8af47efa7fa0fa6d4 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:36:35 -0500
Subject: [PATCH 055/257] flake8: whitespace cleanup
---
tests/test_cli.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 5f6e501f..57b2d5f9 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -3,28 +3,30 @@
import textile
+
def test_console_script():
command = [sys.executable, '-m', 'textile', 'README.textile']
try:
result = subprocess.check_output(command)
except AttributeError:
command[2] = 'textile.__main__'
- result = subprocess.Popen(command,
- stdout=subprocess.PIPE).communicate()[0]
+ result = subprocess.Popen(
+ command, stdout=subprocess.PIPE).communicate()[0]
with open('tests/fixtures/README.txt') as f:
expect = ''.join(f.readlines())
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]
+ result = subprocess.Popen(
+ command, stdout=subprocess.PIPE).communicate()[0]
if type(result) == bytes:
result = result.decode('utf-8')
assert result.strip() == textile.__version__
From b010a31482fceeb0fb228c959b18ce48be68aed1 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:52:50 -0500
Subject: [PATCH 056/257] flake8: whitespace cleanup
---
tests/test_attributes.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_attributes.py b/tests/test_attributes.py
index 0f5d0193..b07712f7 100644
--- a/tests/test_attributes.py
+++ b/tests/test_attributes.py
@@ -1,5 +1,6 @@
from textile.utils import parse_attributes
+
def test_parse_attributes():
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
assert parse_attributes('/1', element='td') == {'rowspan': '1'}
From ba71882313124d17d9d6deb87fd10a8cc250dbee Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:53:42 -0500
Subject: [PATCH 057/257] flake8: whitespace cleanup
---
tests/test_getimagesize.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_getimagesize.py b/tests/test_getimagesize.py
index 43f85e3a..3a3c0a9c 100644
--- a/tests/test_getimagesize.py
+++ b/tests/test_getimagesize.py
@@ -3,6 +3,7 @@
PIL = pytest.importorskip('PIL')
+
def test_imagesize():
assert getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110)
assert getimagesize("http://bad.domain/") == ''
From 00ac6423fcecc6d164a2cde1bb547dca8c0c59f8 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:55:41 -0500
Subject: [PATCH 058/257] flake8: whitespace cleanup
---
tests/test_glyphs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_glyphs.py b/tests/test_glyphs.py
index 56b0d272..ed50ad53 100644
--- a/tests/test_glyphs.py
+++ b/tests/test_glyphs.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_glyphs():
t = Textile()
From 19936d813275f19465fbb695559961f72a983cab Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:57:52 -0500
Subject: [PATCH 059/257] flake8: whitespace cleanup
---
tests/test_subclassing.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_subclassing.py b/tests/test_subclassing.py
index 9235e032..a7db99a3 100644
--- a/tests/test_subclassing.py
+++ b/tests/test_subclassing.py
@@ -1,10 +1,10 @@
import textile
+
def test_change_glyphs():
class TextilePL(textile.Textile):
glyph_definitions = dict(textile.Textile.glyph_definitions,
- quote_double_open = '„'
- )
+ quote_double_open='„')
test = 'Test "quotes".'
expect = '\tTest „quotes”.
'
From 5c61671087751271a37c8283c02e84a4f0f505df Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:58:40 -0500
Subject: [PATCH 060/257] flake8: whitespace cleanup
---
tests/test_imagesize.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_imagesize.py b/tests/test_imagesize.py
index 0a89b43a..e7d9d88b 100644
--- a/tests/test_imagesize.py
+++ b/tests/test_imagesize.py
@@ -1,10 +1,11 @@
import textile
+
def test_imagesize():
imgurl = 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png'
result = textile.tools.imagesize.getimagesize(imgurl)
try:
- import PIL # noqa: F401
+ import PIL # noqa: F401
expect = (275, 95)
assert result == expect
From 8db86d6149017837e1ad7d91d09303b70e2cfb75 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:17:17 -0500
Subject: [PATCH 061/257] flake8: whitespace cleanup
---
tests/test_textilefactory.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_textilefactory.py b/tests/test_textilefactory.py
index 846b9275..e9fc027f 100644
--- a/tests/test_textilefactory.py
+++ b/tests/test_textilefactory.py
@@ -1,6 +1,7 @@
from textile import textilefactory
import pytest
+
def test_TextileFactory():
f = textilefactory.TextileFactory()
result = f.process("some text here")
From db0626b36f14a85b715d00f19b51ef43eece419f Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:18:01 -0500
Subject: [PATCH 062/257] flake8: whitespace cleanup
---
tests/test_getRefs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_getRefs.py b/tests/test_getRefs.py
index d3cfcd72..8a22d4fb 100644
--- a/tests/test_getRefs.py
+++ b/tests/test_getRefs.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_getRefs():
t = Textile()
result = t.getRefs("some text [Google]http://www.google.com")
From d6d7f995aa35187215bea5a83ce5b7dab8305f9d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:18:34 -0500
Subject: [PATCH 063/257] flake8: whitespace cleanup
---
tests/test_footnoteRef.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_footnoteRef.py b/tests/test_footnoteRef.py
index c973ee7b..5ac2ea4b 100644
--- a/tests/test_footnoteRef.py
+++ b/tests/test_footnoteRef.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_footnoteRef():
t = Textile()
result = t.footnoteRef('foo[1]')
From 325014da65763d42dc86c50a99f17512ec143373 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:19:14 -0500
Subject: [PATCH 064/257] flake8: whitespace cleanup
---
tests/test_table.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_table.py b/tests/test_table.py
index 0a3cb0d6..1ea34e94 100644
--- a/tests/test_table.py
+++ b/tests/test_table.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_table():
t = Textile()
result = t.table('(rowclass). |one|two|three|\n|a|b|c|')
From cbb6bb71cf7c6165aadd1b29c59331542039e233 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:21:12 -0500
Subject: [PATCH 065/257] flake8: whitespace cleanup
---
tests/test_values.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/test_values.py b/tests/test_values.py
index 063ed3e9..5b2b7e34 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -309,12 +309,14 @@
('Hello ["(Mum) & dad"]', '\tHello [“(Mum) & dad”]
'),
)
+
@pytest.mark.parametrize("input, expected_output", xhtml_known_values)
def test_KnownValuesXHTML(input, expected_output):
# XHTML
output = textile.textile(input, html_type='xhtml')
assert output == expected_output
+
@pytest.mark.parametrize("input, expected_output", html_known_values)
def test_KnownValuesHTML(input, expected_output):
# HTML5
From 8cb3bf7b95f49af518a4a3231043f35be9788835 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:21:42 -0500
Subject: [PATCH 066/257] flake8: whitespace cleanup
---
tests/test_values.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/test_values.py b/tests/test_values.py
index 5b2b7e34..12dae557 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -35,7 +35,7 @@
('h3. Header 3', '\tHeader 3
'),
('An old text\n\nbq. A block quotation.\n\nAny old text''',
- '\tAn old text
\n\n\t\n\t\tA block quotation.
\n\t
\n\n\tAny old text
'),
+ '\tAn old text
\n\n\t\n\t\tA block quotation.
\n\t
\n\n\tAny old text
'),
('I _believe_ every word.', '\tI believe every word.
'),
@@ -70,8 +70,8 @@
('p[fr]. rouge', '\trouge
'),
('I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%.',
- '\tI seriously blushed
\nwhen I sprouted'
- ' that
\ncorn stalk from my
\ncabeza.
'),
+ '\tI seriously blushed
\nwhen I sprouted'
+ ' that
\ncorn stalk from my
\ncabeza.
'),
('p<. align left', '\talign left
'),
@@ -226,7 +226,7 @@
("""table(#dvds){border-collapse:collapse}. Great films on DVD employing Textile summary, caption, thead, tfoot, two tbody elements and colgroups\n|={font-size:140%;margin-bottom:15px}. DVDs with two Textiled tbody elements\n|:\\3. 100 |{background:#ddd}|250||50|300|\n|^(header).\n|_. Title |_. Starring |_. Director |_. Writer |_. Notes |\n|~(footer).\n|\\5=. This is the tfoot, centred |\n|-(toplist){background:#c5f7f6}.\n| _The Usual Suspects_ | Benicio Del Toro, Gabriel Byrne, Stephen Baldwin, Kevin Spacey | Bryan Singer | Chris McQaurrie | One of the finest films ever made |\n| _Se7en_ | Morgan Freeman, Brad Pitt, Kevin Spacey | David Fincher | Andrew Kevin Walker | Great psychological thriller |\n| _Primer_ | David Sullivan, Shane Carruth | Shane Carruth | Shane Carruth | Amazing insight into trust and human psychology
rather than science fiction. Terrific! |\n| _District 9_ | Sharlto Copley, Jason Cope | Neill Blomkamp | Neill Blomkamp, Terri Tatchell | Social commentary layered on thick,\nbut boy is it done well |\n|-(medlist){background:#e7e895;}.\n| _Arlington Road_ | Tim Robbins, Jeff Bridges | Mark Pellington | Ehren Kruger | Awesome study in neighbourly relations |\n| _Phone Booth_ | Colin Farrell, Kiefer Sutherland, Forest Whitaker | Joel Schumacher | Larry Cohen | Edge-of-the-seat stuff in this\nshort but brilliantly executed thriller |""",
"""\t\n\tDVDs with two Textiled tbody elements \n\t\n\t \n\t \n\t \n\t \n\t \n\t \n\t\n\t\t\n\t\t\tTitle \n\t\t\tStarring \n\t\t\tDirector \n\t\t\tWriter \n\t\t\tNotes \n\t\t \n\t\n\t\n\t\t\n\t\t\tThis is the tfoot, centred \n\t\t \n\t\n\t\n\t\t\n\t\t\t The Usual Suspects \n\t\t\t Benicio Del Toro, Gabriel Byrne, Stephen Baldwin, Kevin Spacey \n\t\t\t Bryan Singer \n\t\t\t Chris McQaurrie \n\t\t\t One of the finest films ever made \n\t\t \n\t\t\n\t\t\t Se7en \n\t\t\t Morgan Freeman, Brad Pitt, Kevin Spacey \n\t\t\t David Fincher \n\t\t\t Andrew Kevin Walker \n\t\t\t Great psychological thriller \n\t\t \n\t\t\n\t\t\t Primer \n\t\t\t David Sullivan, Shane Carruth \n\t\t\t Shane Carruth \n\t\t\t Shane Carruth \n\t\t\t Amazing insight into trust and human psychology
\nrather than science fiction. Terrific! \n\t\t \n\t\t\n\t\t\t District 9 \n\t\t\t Sharlto Copley, Jason Cope \n\t\t\t Neill Blomkamp \n\t\t\t Neill Blomkamp, Terri Tatchell \n\t\t\t Social commentary layered on thick,
\nbut boy is it done well \n\t\t \n\t\n\t\n\t\t\n\t\t\t Arlington Road \n\t\t\t Tim Robbins, Jeff Bridges \n\t\t\t Mark Pellington \n\t\t\t Ehren Kruger \n\t\t\t Awesome study in neighbourly relations \n\t\t \n\t\t\n\t\t\t Phone Booth \n\t\t\t Colin Farrell, Kiefer Sutherland, Forest Whitaker \n\t\t\t Joel Schumacher \n\t\t\t Larry Cohen \n\t\t\t Edge-of-the-seat stuff in this
\nshort but brilliantly executed thriller \n\t\t \n\t\n\t
"""),
("""-(hot) *coffee* := Hot _and_ black\n-(hot#tea) tea := Also hot, but a little less black\n-(cold) milk := Nourishing beverage for baby cows.\nCold drink that goes great with cookies. =:\n\n-(hot) coffee := Hot and black\n-(hot#tea) tea := Also hot, but a little less black\n-(cold) milk :=\nNourishing beverage for baby cows.\nCold drink that goes great with cookies. =:""",
- """\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\t- Nourishing beverage for baby cows.
\nCold drink that goes great with cookies. \n
\n\n\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\tNourishing beverage for baby cows.
\nCold drink that goes great with cookies.
\n
"""),
+ """\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\t- Nourishing beverage for baby cows.
\nCold drink that goes great with cookies. \n
\n\n\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\tNourishing beverage for baby cows.
\nCold drink that goes great with cookies.
\n
"""),
(""";(class#id) Term 1\n: Def 1\n: Def 2\n: Def 3""",
"""\t\n\t\t- Term 1
\n\t\t- Def 1
\n\t\t- Def 2
\n\t\t- Def 3
\n\t
"""),
("""*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**""",
@@ -258,8 +258,8 @@
('I __know__.\nI **really** __know__.', '\tI know.
\nI really know.
'),
("I'm %{color:red}unaware%\nof most soft drinks.", '\tI’m unaware
\nof most soft drinks.
'),
('I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%.',
- '\tI seriously blushed
\nwhen I sprouted'
- ' that
\ncorn stalk from my
\ncabeza.
'),
+ '\tI seriously blushed
\nwhen I sprouted'
+ ' that
\ncorn stalk from my
\ncabeza.
'),
('\n\na.gsub!( /, "" )\n\n
',
'\n\na.gsub!( /</, "" )\n\n
'),
('\n\nh3. Sidebar\n\n"Hobix":http://hobix.com/\n"Ruby":http://ruby-lang.org/\n\n\n\n'
From 1b65dc74c51493f6167d661338112b5506c11f33 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:22:50 -0500
Subject: [PATCH 067/257] flake8: whitespace cleanup
---
tests/test_utils.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 7f386a9b..a6e88f8a 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -3,21 +3,25 @@
from textile import utils
+
def test_encode_html():
result = utils.encode_html('''this is a "test" of text that's safe to '''
- 'put in an attribute.')
+ 'put in an attribute.')
expect = ('this is a "test" of text that's safe to put in '
- 'an <html> attribute.')
+ 'an <html> attribute.')
assert result == expect
+
def test_has_raw_text():
assert utils.has_raw_text('foo bar biz baz
') is False
assert utils.has_raw_text(' why yes, yes it does') is True
+
def test_is_rel_url():
assert utils.is_rel_url("http://www.google.com/") is False
assert utils.is_rel_url("/foo") is True
+
def test_generate_tag():
result = utils.generate_tag('span', 'inner text', {'class': 'test'})
expect = 'inner text'
From 30c4eef40b5a5391802287a49f34e73914a5425e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:25:27 -0500
Subject: [PATCH 068/257] turn flake8 warnings and errors back on
---
.flake8 | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.flake8 b/.flake8
index 07c24d1c..9f8ccc38 100644
--- a/.flake8
+++ b/.flake8
@@ -2,8 +2,5 @@
ignore =
# line too long
E501
- # temporarily ignore warnings and errors
- W
- E
exclude =
build/
From 157ff1edac900c1135ca0b6f2d6f5830ffa60894 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:35:36 -0500
Subject: [PATCH 069/257] use environment vars as intended
maybe this will fix a warning about unexpected inputs ???
---
.github/workflows/lint_and_test.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 437820dc..f82f4c2f 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -20,9 +20,10 @@ jobs:
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
+ env:
+ IMAGESIZE: ${{ matrix.image-size }}
run: |
imagesize=''
- IMAGESIZE=${{ matrix.image-size }}
pip install -U pytest pytest-cov coverage codecov
if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
From a4b09ab08ec36087ac66c694f185545a76e31ca0 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:42:24 -0500
Subject: [PATCH 070/257] further testing of environment variables
---
.github/workflows/lint_and_test.yml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index f82f4c2f..5ba1e869 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
- image-size: ['true', 'false']
+ image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
@@ -20,12 +20,10 @@ jobs:
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
- env:
- IMAGESIZE: ${{ matrix.image-size }}
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
- if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
+ if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
From 674ed26891970f213a0e692cab1e21da502348a3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:44:45 -0500
Subject: [PATCH 071/257] This is probably the source of the `unexpected
inputs` warning
---
.github/workflows/lint_and_test.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 5ba1e869..47ce8cf5 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -16,7 +16,6 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- image-size: ${{ matrix.image-size }}
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
From 16b70594b23947ccc3c4154369727215e0a7e4b6 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:49:10 -0500
Subject: [PATCH 072/257] add pypy3 to github actions
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 47ce8cf5..0db7ea80 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
+ python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
From cdfa9490bea32b33bde09dac83ff3b219fafd4d8 Mon Sep 17 00:00:00 2001
From: Kirill Mavreshko
Date: Wed, 31 Aug 2022 12:56:49 +0500
Subject: [PATCH 073/257] Fix wrong output when "bc.." is the last block #81
---
tests/fixtures/README.txt | 2 +-
tests/test_values.py | 8 ++++++++
textile/core.py | 9 ++++-----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index 61dc0f01..949db700 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -60,4 +60,4 @@
When textile is not installed locally:
-PYTHONPATH=. pytest\ No newline at end of file +
PYTHONPATH=. pytest
\ No newline at end of file
diff --git a/tests/test_values.py b/tests/test_values.py
index 063ed3e9..97928818 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -254,6 +254,14 @@
# A few extra cases for HTML4
html_known_values = (
+ ("pre.. The beginning\n\nbc.. This code\n\nis the last\n\nblock in the document\n",
+ "The beginning\n\n
This code\n\nis the last\n\nblock in the document"),
+ ("bc.. This code\n\nis not\n\nsurrounded by anything\n",
+ "This code\n\nis not\n\nsurrounded by anything"),
+ ("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\np.. post-code paragraph",
+ "Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\npost-code paragraph
"), + ("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\npre.. post-code non-p block", + "Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\npost-code non-p block"), ('I spoke.\nAnd none replied.', '\t
I spoke.
\nAnd none replied.
I know.
\nI really know.
I’m unaware
\nof most soft drinks.
\n\t\t'), ('Hello ["(Mum) & dad"]', '\tText…
\n\t
Hello [“(Mum) & dad”]
'), + # Dimensions + ( + ('[1/2] x [1/4] and (1/2)" x [1/4]" and (1/2)\' x (1/4)\'\n\n' + '(2 x 10) X (3 / 4) x (200 + 64)\n\n' + '1 x 1 = 1\n\n' + '1 x1 = 1\n\n' + '1x 1 = 1\n\n' + '1x1 = 1\n\n' + '1 X 1 = 1\n\n' + '1 X1 = 1\n\n' + '1X 1 = 1\n\n' + '1X1 = 1\n\n' + 'What is 1 x 1?\n\n' + 'What is 1x1?\n\n' + 'What is 1 X 1?\n\n' + 'What is 1X1?\n\n' + '1 x 2 x 3 = 6\n\n' + '1x2x3=6\n\n' + '1x2 x 1x3 = 6\n\n' + '2\' x 2\' = 4 sqft.\n\n' + '2\'x 2\' = 4 sqft.\n\n' + '2\' x2\' = 4 sqft.\n\n' + '2\'x2\' = 4 sqft.\n\n' + '2\' X 2\' = 4 sqft.\n\n' + '2\'X 2\' = 4 sqft.\n\n' + '2\' X2\' = 4 sqft.\n\n' + '2\'X2\' = 4 sqft.\n\n' + '2" x 2" = 4 sqin.\n\n' + '2"x 2" = 4 sqin.\n\n' + '2" x2" = 4 sqin.\n\n' + '2"x2" = 4 sqin.\n\n' + '2" X 2" = 4 sqin.\n\n' + '2"X 2" = 4 sqin.\n\n' + '2" X2" = 4 sqin.\n\n' + '2"X2" = 4in[^2^].\n\n' + 'What is 1.2 x 3.5?\n\n' + 'What is .2 x .5?\n\n' + 'What is 1.2x3.5?\n\n' + 'What is .2x.5?\n\n' + 'What is 1.2\' x3.5\'?\n\n' + 'What is .2"x .5"?\n\n' + '1 x $10.00 x -£ 1.23 x ¥20,000 x -¤120.00 x ฿1,000,000 x -€110,00\n\n'), + + ('\t½ × ¼ and ½” × ¼” and ½’ × ¼’
\n\n' + '\t(2 × 10) × (3 / 4) × (200 + 64)
\n\n' + '\t1 × 1 = 1
\n\n' + '\t1 ×1 = 1
\n\n' + '\t1× 1 = 1
\n\n' + '\t1×1 = 1
\n\n' + '\t1 × 1 = 1
\n\n' + '\t1 ×1 = 1
\n\n' + '\t1× 1 = 1
\n\n' + '\t1×1 = 1
\n\n' + '\tWhat is 1 × 1?
\n\n' + '\tWhat is 1×1?
\n\n' + '\tWhat is 1 × 1?
\n\n' + '\tWhat is 1×1?
\n\n' + '\t1 × 2 × 3 = 6
\n\n' + '\t1×2×3=6
\n\n' + '\t1×2 × 1×3 = 6
\n\n' + '\t2’ × 2’ = 4 sqft.
\n\n' + '\t2’× 2’ = 4 sqft.
\n\n' + '\t2’ ×2’ = 4 sqft.
\n\n' + '\t2’×2’ = 4 sqft.
\n\n' + '\t2’ × 2’ = 4 sqft.
\n\n' + '\t2’× 2’ = 4 sqft.
\n\n' + '\t2’ ×2’ = 4 sqft.
\n\n' + '\t2’×2’ = 4 sqft.
\n\n' + '\t2” × 2” = 4 sqin.
\n\n' + '\t2”× 2” = 4 sqin.
\n\n' + '\t2” ×2” = 4 sqin.
\n\n' + '\t2”×2” = 4 sqin.
\n\n' + '\t2” × 2” = 4 sqin.
\n\n' + '\t2”× 2” = 4 sqin.
\n\n' + '\t2” ×2” = 4 sqin.
\n\n' + '\t2”×2” = 4in2.
\n\n' + '\tWhat is 1.2 × 3.5?
\n\n' + '\tWhat is .2 × .5?
\n\n' + '\tWhat is 1.2×3.5?
\n\n' + '\tWhat is .2×.5?
\n\n' + '\tWhat is 1.2’ ×3.5’?
\n\n' + '\tWhat is .2”× .5”?
\n\n' + '\t1 × $10.00 × -£ 1.23 × ¥20,000 × -¤120.00 × ฿1,000,000 × -€110,00
') + ), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index 5e74b427..39daa1a9 100644 --- a/textile/core.py +++ b/textile/core.py @@ -47,6 +47,12 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): if regex_snippets['cur'] else r'') pre_result = [ + # dimension sign (before apostrophes/quotes are replaced) + (re.compile( + r'([0-9]+[\])]?[\'"]? ?)[x]( ?[\[(]?)' + r'(?=[+-]?{0}[0-9]*\.?[0-9]+)'.format(cur), + flags=re.I | re.U), + r'\1{dimension}\2'), # apostrophe's (re.compile( (r"(^|{0}|\))'({0})" if not is_initial @@ -97,12 +103,6 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): (re.compile(r'(\s?)--(\s?)'), r'\1{emdash}\2'), # en dash (re.compile(r' - '), r' {endash} '), - # dimension sign - (re.compile( - r'([0-9]+[\])]?[\'"]? ?)[x]( ?[\[(]?)' - r'(?=[+-]?{0}[0-9]*\.?[0-9]+)'.format(cur), - flags=re.I | re.U), - r'\1{dimension}\2'), # trademark (re.compile( r'(\b ?|{0}|^)[([]TM[])]'.format(regex_snippets['space']), diff --git a/textile/regex_strings.py b/textile/regex_strings.py index 470203cb..deb4a4a2 100644 --- a/textile/regex_strings.py +++ b/textile/regex_strings.py @@ -26,7 +26,10 @@ 'abr': r'{0}'.format(upper_re_s), 'nab': r'a-z', 'wrd': r'\w', - 'cur': r'', + # All codepoints identified as currency symbols + # by the [mrab-regex library](https://pypi.org/project/regex/) + # and the UNICODE standard. + 'cur': r'$¢-¥֏؋৲৳৻૱௹฿៛\u20a0-\u20cf\ua838﷼﹩$¢£¥₩', 'digit': r'\d', 'space': r'(?:\s|\v)', 'char': r'\S', From 6286b805039880d68ce6442b866ca759c6679496 Mon Sep 17 00:00:00 2001 From: Kirill Mavreshko“z”
' + expect = '\t“z”
' assert result == expect result = textile.textile('" z"') - expect = '\t“ z”
' + expect = '\t“ z”
' assert result == expect def test_restricted(): diff --git a/tests/test_values.py b/tests/test_values.py index 48e80069..b1d8ec90 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -14,7 +14,7 @@ ('I spoke.\nAnd none replied.', '\tI spoke.
\nAnd none replied.
“Observe!”
'), + ('"Observe!"', '\t“Observe!”
'), ('Observe -- very nice!', '\tObserve — very nice!
'), @@ -201,13 +201,13 @@ """\tThe Prisoner
"""), ("""p=. "An emphasised _word._" & "*A spanned phrase.*" """, - """\t“An emphasised word.” & “A spanned phrase.”
"""), + """\t“An emphasised word.” & “A spanned phrase.”
"""), ("""p=. "*Here*'s a word!" """, - """\t“Here’s a word!”
"""), + """\t“Here’s a word!”
"""), ("""p=. "Please visit our "Textile Test Page":http://textile.sitemonks.com" """, - """\t“Please visit our Textile Test Page”
"""), + """\t“Please visit our Textile Test Page”
"""), ("""| Foreign EXPÓŅÉNTIAL |""", """\t| Foreign EXPÓŅÉNTIAL | \n\t\t
What is .2”× .5”?
\n\n' '\t1 × $10.00 × -£ 1.23 × ¥20,000 × -¤120.00 × ฿1,000,000 × -€110,00
') ), + # Empty note lists + ('There should be nothing below.\n\nnotelist.', '\tThere should be nothing below.
\n\n\t'), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index 39daa1a9..221890dd 100644 --- a/textile/core.py +++ b/textile/core.py @@ -1304,8 +1304,9 @@ def fNoteLists(self, match): o.append(li) self.notelist_cache[index] = "\n".join(o) result = self.notelist_cache[index] - list_atts = pba(att, restricted=self.restricted) - result = 'There should be nothing below.
\n\n\t'), + # Empty things + (('\'\'\n\n""\n\n%%\n\n^^\n\n&&\n\n**\n\n__\n\n--\n\n++\n\n~~\n\n{}\n\n' + '[]\n\n()\n\n<>\n\n\\\\\n\n//\n\n??\n\n==\n\n@@\n\n##\n\n$$\n\n!!\n\n' + '::\n\n;;\n\n..\n\n,,\n\n||\n\n` `\n\n\' \'\n\n" "\n\n% %\n\n^ ^\n\n' + '& &\n\n* *\n\n_ _\n\n- -\n\n+ +\n\n~ ~\n\n{ }\n\n[ ]\n\n( )\n\n< >\n\n' + '\\ \\\n\n/ /\n\n? ?\n\n= =\n\n@ @\n\n# #\n\n$ $\n\n! !\n\n: :\n\n; ;\n\n' + '. .\n\n, ,'), + ("\t‘’
\n\n\t“”
\n\n\t%%
\n\n\t^^
\n\n\t" + "&&
\n\n\t**
\n\n\t__
\n\n\t—
\n\n\t++
\n\n\t" + "~~
\n\n\t{}
\n\n\t[]
\n\n\t()
\n\n\t<>
\n\n\t\\\\
\n\n\t" + "//
\n\n\t??
\n\n\t==
\n\n\t##
\n\n\t$$
\n\n\t" + "!!
\n\n\t::
\n\n\t;;
\n\n\t..
\n\n\t,,
\n\n\t" + "| \n\t\t |
` `
\n\n\t‘ ‘
\n\n\t" + "“ “
\n\n\t% %
\n\n\t^ ^
\n\n\t& &
\n\n\t" + "_ _
\n\n\t- -
\n\n\t+ +
\n\n\t~ ~
\n\n\t" + "{ }
\n\n\t[ ]
\n\n\t( )
\n\n\t< >
\n\n\t\\ \\
\n\n\t" + "/ /
\n\n\t? ?
\n\n\t= =
\n\n\t
$ $
\n\n\t! !
\n\n\t. .
\n\n\t, ,
")) ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index 221890dd..f3218092 100644 --- a/textile/core.py +++ b/textile/core.py @@ -97,8 +97,6 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): (re.compile(r'"'), r'{quote_double_open}'), # ellipsis (re.compile(r'([^.]?)\.{3}'), r'\1{ellipsis}'), - # ampersand - (re.compile(r'(\s?)&(\s)', re.U), r'\1{ampersand}\2'), # em dash (re.compile(r'(\s?)--(\s?)'), r'\1{emdash}\2'), # en dash @@ -622,10 +620,20 @@ def glyphs(self, text): text = text.rstrip('\n') result = [] replacers = self.initial_glyph_replacers + standalone_amp_re = re.compile(r'&(?!#?[a-z0-9]+;)', flags=re.I) + html_amp_symbol = self.glyph_definitions['ampersand'] # split the text by any angle-bracketed tags for i, line in enumerate(re.compile(r'(<[\w\/!?].*?>)', re.U).split( text)): if not i % 2: + if not self.restricted: + # Raw < > & chars have already been encoded + # when in restricted mode + line = ( + standalone_amp_re + .sub(html_amp_symbol, line) + .replace('<', '<') + .replace('>', '>')) for s, r in replacers: line = s.sub(r, line) result.append(line) From b8061b505e9359e90efc82b07d4e234208aefada Mon Sep 17 00:00:00 2001 From: Kirill MavreshkoTxStyle is a documentation project of Textile 2.4 for Textpattern CMS.
'), (""""Übermensch":http://de.wikipedia.org/wiki/Übermensch""", """\t"""), ("""Here is some text with a block.\n\n\n\n\n\nbc. """, - """\tHere is some text with a block.
\n\n\t\n\n\t\n\n<!-- Here is a comment block in a code block. -->"""),
+ """\tHere is some text with a block.
\n\n\n\n\n\n<!-- Here is a comment block in a code block. -->"""),
(""""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“Textile©” is a registered® ‘trademark’ of Textpattern™ — or TXP — at least it was – back in ’88 when 2×4 was ±5°C … QED!
\n\n\t2¼ 3½ 4¾
"""), ("""|=. 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| a | \n\t\t\tb | \n\t\t\tc | \n\t\t\td | \n\t\t\te | \n\t\t
| a | \n\t\t\tb | \n\t\t\tc | \n\t\t\td | \n\t\t\te | \n\t\t
{ }
\n\n\t[ ]
\n\n\t( )
\n\n\t< >
\n\n\t\\ \\
\n\n\t" "/ /
\n\n\t? ?
\n\n\t= =
\n\n\t
$ $
\n\n\t! !
\n\n\t. .
\n\n\t, ,
")) + ". .
\n\n\t, ,
")), + # A lone standing comment must be preserved as is: + # withouth wrapping it into a paragraph + (('An ordinary block.\n\n' + '\n'), + '\tAn ordinary block.
\n\n'), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/utils.py b/textile/utils.py index cd619ed4..06a51e72 100644 --- a/textile/utils.py +++ b/textile/utils.py @@ -14,6 +14,18 @@ from textile.regex_strings import valign_re_s, halign_re_s +# Regular expressions for stripping chunks of HTML, +# leaving only content not wrapped in a tag or a comment +RAW_TEXT_REVEALERS = ( + # The php version has orders the below list of tags differently. The + # important thing to note here is that the pre must occur before the p or + # else the regex module doesn't properly match pre-s. It only matches the + # p in pre. + re.compile(r'<(pre|p|blockquote|div|form|table|ul|ol|dl|h[1-6])[^>]*?>.*\1>', + re.S), + re.compile(r'<(hr|br)[^>]*?/>'), + re.compile(r''), +) def decode_high(text): """Decode encoded HTML entities.""" @@ -66,14 +78,10 @@ def generate_tag(tag, content, attributes=None): def has_raw_text(text): """checks whether the text has text not already enclosed by a block tag""" - # The php version has orders the below list of tags differently. The - # important thing to note here is that the pre must occur before the p or - # else the regex module doesn't properly match pre-s. It only matches the - # p in pre. - r = re.compile(r'<(pre|p|blockquote|div|form|table|ul|ol|dl|h[1-6])[^>]*?>.*\1>', - re.S).sub('', text.strip()).strip() - r = re.compile(r'<(hr|br)[^>]*?/>').sub('', r) - return '' != r + r = text.strip() + for pattern in RAW_TEXT_REVEALERS: + r = pattern.sub('', r).strip() + return r != '' def is_rel_url(url): """Identify relative urls.""" From b4c02b8c0c6e176c1dfe4a0dfb7b0ae2eaf7dae6 Mon Sep 17 00:00:00 2001 From: Kirill MavreshkoAn ordinary block.
\n\n'), + # Headers must be "breakable", just like paragraphs. + ('h1. Two line with *strong*\nheading\n', + '\t“test”
\n\n" + "\t“test”
\n\n" + "\ttest
")), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index 2c89eb91..f8e478ee 100644 --- a/textile/core.py +++ b/textile/core.py @@ -621,7 +621,9 @@ def glyphs(self, text): text = text.rstrip('\n') result = [] replacers = self.initial_glyph_replacers - standalone_amp_re = re.compile(r'&(?!#?[a-z0-9]+;)', flags=re.I) + standalone_amp_re = re.compile( + r"&(?!#[0-9]+;|#x[a-f0-9]+;|[a-z][a-z0-9]*;)", + flags=re.I) html_amp_symbol = self.glyph_definitions['ampersand'] # split the text by any angle-bracketed tags for i, line in enumerate(re.compile(r'(<[\w\/!?].*?>)', re.U).split( From a047b3b6ec7cae8ddd706a22f0aa958187b9fd1d Mon Sep 17 00:00:00 2001 From: Kirill MavreshkoThe Prisoner
"""), ("""p=. "An emphasised _word._" & "*A spanned phrase.*" """, - """\t“An emphasised word.” & “A spanned phrase.”
"""), + """\t“An emphasised word.” & “A spanned phrase.”
"""), ("""p=. "*Here*'s a word!" """, - """\t“Here’s a word!”
"""), + """\t“Here’s a word!”
"""), ("""p=. "Please visit our "Textile Test Page":http://textile.sitemonks.com" """, - """\t“Please visit our Textile Test Page”
"""), + """\t“Please visit our Textile Test Page”
"""), ("""| Foreign EXPÓŅÉNTIAL |""", """\t| Foreign EXPÓŅÉNTIAL | \n\t\t
“test”
\n\n" "\t“test”
\n\n" "\ttest
")), + # Nested and mixed multi-level ordered and unordered lists + (("* bullet\n" + "*# number\n" + "*# number\n" + "*#* bullet\n" + "*# number\n" + "*# number with\n" + "a break\n" + "* bullet\n" + "** okay"), + ("\ttest
\n\n\ttest
\n\n\t\t
| \n\t\t
\t
| \n\t\t
\n | \n\t\t
\t
| \n\t\t
\t
| \n\t\t
| \n\t\t
| table | \n\t\t\tmore | \n\t\t\tbadass | \n\t\t
|---|---|---|
| Horizontal span of 3 | \n\t\t||
| first | \n\t\t\tHAL | \n\t\t\t1 | \n\t\t
| some | \n\t\t\tstyled | \n\t\t\tcontent | \n\t\t
| spans 2 rows | \n\t\t\tthis is | \n\t\t\tquite a | \n\t\t
| deep test | \n\t\t\tdon’t you think? | \n\t\t|
| fifth | \n\t\t\tI’m a lumberjack | \n\t\t\t5 | \n\t\t
| sixth | \n\t\t\tbold italics | \n\t\t\t6 | \n\t\t
| \n"
+ "\t\t
Nourishing beverage for baby cows.
Here is a ‘spanned’ word.
'), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index 07fdf749..8214fc89 100644 --- a/textile/core.py +++ b/textile/core.py @@ -35,7 +35,7 @@ import re -def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): +def make_glyph_replacers(html_type, uid, glyph_defs): """ Generates a list of "replacers" (each is a pair consiting of a regular expression and a replacing pattern) that, @@ -55,8 +55,7 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): r'\1{dimension}\2'), # apostrophe's (re.compile( - (r"(^|{0}|\))'({0})" if not is_initial - else r"({0}|\))'({0})") + r"({0}|\))'({0})" .format(regex_snippets['wrd']), flags=re.U), r'\1{apostrophe}\2'), @@ -71,11 +70,7 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): r'\1{quote_single_open}'), # single closing (re.compile( - (r"(^|\S)'(?={0}|{1}|<|$)".format( - regex_snippets['space'], pnct_re_s) - if not is_initial - else r"(\S)'(?={0}|{1}|$)".format( - regex_snippets['space'], pnct_re_s)), + r"(\S)'(?={0}|{1}|<|$)".format(regex_snippets['space'], pnct_re_s), flags=re.U), r'\1{quote_single_close}'), # single opening @@ -86,11 +81,7 @@ def make_glyph_replacers(html_type, uid, glyph_defs, is_initial): r'\1{quote_double_open}'), # double closing (re.compile( - (r'(^|\S)"(?={0}|{1}|<|$)'.format( - regex_snippets['space'], pnct_re_s) - if not is_initial - else r'(\S)"(?={0}|{1}|<|$)'.format( - regex_snippets['space'], pnct_re_s)), + r'(\S)"(?={0}|{1}|<|$)'.format(regex_snippets['space'], pnct_re_s), flags=re.U), r'\1{quote_double_close}'), # double opening @@ -184,6 +175,10 @@ class Textile(object): 'plusminus': '±', } + spanWrappers = ( + ('[', ']'), + ) + def __init__(self, restricted=False, lite=False, noimage=False, get_sizes=False, html_type='xhtml', rel='', block_tags=True): """Textile properties that are common to regular textile and @@ -213,11 +208,7 @@ def __init__(self, restricted=False, lite=False, noimage=False, regex_snippets['space']) self.glyph_replacers = make_glyph_replacers( - html_type, self.uid, self.glyph_definitions, is_initial=False) - # Replacements that need to be made at the beginning - # of the string - self.initial_glyph_replacers = make_glyph_replacers( - html_type, self.uid, self.glyph_definitions, is_initial=True) + html_type, self.uid, self.glyph_definitions) if self.restricted is True: self.url_schemes = self.restricted_url_schemes @@ -279,6 +270,7 @@ def parse(self, text, rel=None, sanitize=False): if sanitize: text = sanitizer.sanitize(text) + text = self.retrieveTags(text) text = self.retrieveURLs(text) # if the text contains a break tag ({0}'.format(text)), after])
@@ -1174,6 +1193,7 @@ def fPre(self, match):
before, text, after = match.groups()
if after is None:
after = ''
+ before, after = self.getSpecialOptions(before, after)
# text needs to be escaped
text = encode_html(text)
return ''.join([before, '', self.shelve(text), '', after]) @@ -1192,6 +1212,7 @@ def fTextile(self, match): before, notextile, after = match.groups() if after is None: # pragma: no branch after = '' + before, after = self.getSpecialOptions(before, after) return ''.join([before, self.shelve(notextile), after]) def getHTMLComments(self, text): From 155e2b32ab955072940f085d591227a75d056bd9 Mon Sep 17 00:00:00 2001 From: Kirill Mavreshko
Goodbye.
"""), - ("""h2. A Definition list which covers the instance where a new definition list is created with a term without a definition\n\n- term :=\n- term2 := def""", """\t& test
'), diff --git a/textile/core.py b/textile/core.py index 8214fc89..c68f3440 100644 --- a/textile/core.py +++ b/textile/core.py @@ -1246,7 +1246,7 @@ def fRCList(self, match): text = re.split(r'\n(?=[-])', match.group(), flags=re.M) for line in text: # parse the attributes and content - m = re.match(r'^[-]+({0})[ .](.*)$'.format(cls_re_s), line, + m = re.match(r'^[-]+({0})\.? (.*)$'.format(cls_re_s), line, flags=re.M | re.S) if not m: continue @@ -1257,9 +1257,15 @@ def fRCList(self, match): atts = pba(atts, restricted=self.restricted) # split the content into the term and definition - xm = re.match(r'^(.*?)[\s]*:=(.*?)[\s]*(=:|:=)?[\s]*$', content, - re.S) - term, definition, ending = xm.groups() + xm = re.match( + r'^(.*?){0}*:=(.*?){0}*(=:|:=)?{0}*$' + .format(regex_snippets['space']), + content, + re.S) + if xm: + term, definition, _ = xm.groups() + else: + term, definition = content, '' # cleanup term = term.strip() definition = definition.strip(' ') @@ -1272,16 +1278,23 @@ def fRCList(self, match): dltag = "{0}
'.format(definition.lstrip()) - definition = definition.replace('\n', '{0}
'.format(definition) + term = term.replace('\n', 'Here is a ‘spanned’ word.
'), + # Using $-links with link aliases + ("\"$\":test\n[test]https://textpattern.com/start\n", + "\t"), + ('Please check on "$":test for any updates.\n[test]https://de.wikipedia.org/wiki/Übermensch', + '\tPlease check on de.wikipedia.org/wiki/Übermensch for any updates.
'), ) @pytest.mark.parametrize("input, expected_output", xhtml_known_values) diff --git a/textile/core.py b/textile/core.py index c68f3440..bf0b01b4 100644 --- a/textile/core.py +++ b/textile/core.py @@ -139,6 +139,13 @@ def make_glyph_replacers(html_type, uid, glyph_defs): for (regex_obj, replacement) in pre_result] +def human_readable_url(url): + if "://" in url: + url = url.split("://")[1] + elif ":" in url: + url = url.split(":")[1] + return url + class Textile(object): restricted_url_schemes = ('http', 'https', 'ftp', 'mailto') @@ -957,11 +964,14 @@ def _casesdefault(c, pop, popped, url_chars, counts, pre): return in_.replace('{0}linkStartMarker:'.format(self.uid), '') if text == '$': - text = url - if "://" in text: - text = text.split("://")[1] - elif ":" in text: - text = text.split(":")[1] + if valid_scheme: + text = human_readable_url(url) + else: + ref_url = self.urlrefs.get(url) + if ref_url is not None: + text = human_readable_url(ref_url) + else: + text = url text = text.strip() title = encode_html(title) From 05c59a787bb719304c74861cc4450d9cf51636e5 Mon Sep 17 00:00:00 2001 From: Kirill MavreshkoPlease check on de.wikipedia.org/wiki/Übermensch for any updates.
'), + # Make sure smileys don't get recognised as a definition list. + (":(\n\n:)\n\n:( \n:( \n:( \n:) \n\nPinocchio!\n:^)\n\nBaboon!\n:=)\n\nWink!\n;)\n\n:[ \n:]\n\n;(\nsomething\ndark side\n:) \n\n;(c)[de] Item", + '\t:(
\n\n\t:)
\n\n\t:(
\n:(
\n:(
\n:)
Pinocchio!
\n:^)
Baboon!
\n:=)
Wink!
\n;)
:[
\n:]
;(
\nsomething
\ndark side
\n:)
:(
\n\n\t:)
\n\n\t:(
\n:(
\n:(
\n:)
Pinocchio!
\n:^)
Baboon!
\n:=)
Wink!
\n;)
:[
\n:]
;(
\nsomething
\ndark side
\n:)
text1 text2
| A footer | diff --git a/tests/test_values.py b/tests/test_values.py index e14b23d7..298502fe 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -489,6 +489,17 @@ # Checking proper parsing of classes and IDs ("_(class1 class2#id1)text1_ -(foobarbaz#boom bang)text2-\n", '\t
![]() | \n\t\t\t | \n\t\t
| a | \n\t\t\tb | \n\t\t\tc | \n\t\t\td | \n\t\t\te | \n\t\t
| touch this! | \n\t\t\ttouch this! | \n\t\t
Scientists say the moon is slowly shrinking1.
\n\n\tScientists say the moon is slowly shrinking1.
\n\n\t
notelist({0})(?:\:([\w|{1}]))?([\^!]?)(\+?)' - r'\.?[\s]*
'.format(cls_re_s, syms_re_s), re.U) + r'\.?[\s]*'.format(cls_re_s, syms_re_s), re.U) text = text_re.sub(self.fNoteLists, text) return text @@ -1363,8 +1358,8 @@ def fNoteLists(self, match): atts = info['def']['atts'] content = info['def']['content'] li = ('\t\ttext\nmoretext\n\nevenmoretext\n\nmoremoretext\n\n\ttest
' @@ -54,6 +57,7 @@ def test_blockcode_extended(): result = t.parse(input) assert result == expect + def test_blockcode_in_README(): with open('README.textile') as f: readme = ''.join(f.readlines()) @@ -62,6 +66,7 @@ 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 = '\tNew line
' From 1ee596229be05950a1e1addcfb3226d4e4e4e794 Mon Sep 17 00:00:00 2001 From: Dennis BurkeYACC1
', html) is not None + def test_Footnote(): html = textile.textile('This is covered elsewhere[1].\n\nfn1. Down here, in fact.\n\nfn2. Here is another footnote.') assert re.search(r'^\tThis is covered elsewhere1.
\n\n\t1 Down here, in fact.
\n\n\t2 Here is another footnote.
$', html) is not None @@ -24,6 +26,7 @@ def test_Footnote(): html = textile.textile('''See[4!] for details.\n\nfn4^. Here are the details.''') assert re.search(r'^\tSee4 for details.
\n\n\t4 Here are the details.
$', html) is not None + def test_issue_35(): result = textile.textile('"z"') expect = '\t“z”
' @@ -33,8 +36,9 @@ def test_issue_35(): expect = '\t“ z”
' assert result == expect + def test_restricted(): - #Note that the HTML is escaped, thus rendering the " result = textile.textile_restricted(test) expect = "\tHere is some text.
\n<script>alert(‘hello world’)</script>
текст1
$', re.U).search(html) is not None + def test_autolinking(): test = """some text "test":http://www.google.com http://www.google.com "$":http://www.google.com""" result = """\tsome text test http://www.google.com www.google.com
""" @@ -104,6 +110,7 @@ def test_autolinking(): assert result == expect + def test_sanitize(): test = "a paragraph of benign text" result = "\ta paragraph of benign text
" @@ -120,14 +127,16 @@ def test_sanitize(): expect = textile.Textile(html_type='html5').parse(test, sanitize=True) assert result == expect + def test_imagesize(): - PIL = pytest.importorskip('PIL') # noqa: F841 + PIL = pytest.importorskip('PIL') # noqa: F841 test = "!http://www.google.com/intl/en_ALL/images/srpr/logo1w.png!" result = '\t
See2 for details, and later, reference it again2.
\n\n\t2 Here are the details.
$' assert re.compile(searchstring).search(html) is not None + def test_footnote_without_reflink(): html = textile.textile('''See[3!] for details.\n\nfn3. Here are the details.''') searchstring = r'^\tSee3 for details.
\n\n\t3 Here are the details.
$' assert re.compile(searchstring).search(html) is not None + def testSquareBrackets(): html = textile.textile("""1[^st^], 2[^nd^], 3[^rd^]. 2 log[~n~]\n\nA close[!http://textpattern.com/favicon.ico!]image.\nA tight["text":http://textpattern.com/]link.\nA ["footnoted link":http://textpattern.com/][182].""") searchstring = r'^\t1st, 2nd, 3rd. 2 logn
\n\n\tA closeimage.
\nA tighttextlink.
\nA footnoted link182.
A link that contains a\nnewline raises an exception.
' assert result == expect + def test_rel_attribute(): t = Textile(rel='nofollow') result = t.parse('"$":http://domain.tld') expect = '\t' assert result == expect + def test_quotes_in_link_text(): """quotes in link text are tricky.""" test = '""this is a quote in link text"":url' From ae01636248e974b2cc9b5028d570d9a7e7d03ab3 Mon Sep 17 00:00:00 2001 From: Dennis Burkegoogle.com google.com blackhole@sun.comet
' assert result == expect + def test_github_issue_17(): result = textile.textile('!http://www.ox.ac.uk/favicon.ico!') expect = '\tThis is a link to a Wikipedia article about Textile.
' assert result == expect + def test_github_issue_21(): - text = '''h1. xml example + text = ('''h1. xml example -bc. +bc. ''' + '''\n<foo>\n bar\n</foo>'
assert result == expect
+
def test_github_issue_22():
text = '''_(artist-name)Ty Segall_’s'''
result = textile.textile(text)
expect = '\tTy Segall’s
' assert result == expect + def test_github_issue_26(): text = '' result = textile.textile(text) expect = '' assert result == expect + def test_github_issue_27(): test = """* Folders with ":" in their names are displayed with a forward slash "/" instead. (Filed as "#4581709":/test/link, which was considered "normal behaviour" - quote: "Please note that Finder presents the 'Carbon filesystem' view, regardless of the underlying filesystem.")""" result = textile.textile(test) expect = """\tOf course there’s a lot more error handling to do (and useful data to glean off the XML), but being able to cut through all the usual parsing crap is immensely gratifying.
""") assert result == expect + def test_github_issue_30(): - text ='"Tëxtíle (Tëxtíle)":http://lala.com' + text = '"Tëxtíle (Tëxtíle)":http://lala.com' result = textile.textile(text) expect = '\t' assert result == expect - text ='!http://lala.com/lol.gif(♡ imáges)!' + text = '!http://lala.com/lol.gif(♡ imáges)!' result = textile.textile(text) expect = '\t

smart ‘quotes’ are not smart!' assert result == expect + def test_github_issue_45(): """Incorrect transform unicode url""" text = '"test":https://myabstractwiki.ru/index.php/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0' @@ -143,6 +159,7 @@ def test_github_issue_45(): expect = '\t' assert result == expect + def test_github_issue_46(): """Key error on mal-formed numbered lists. CAUTION: both the input and the ouput are ugly.""" @@ -153,6 +170,7 @@ def test_github_issue_46(): result = textile.textile(text) assert result == expect + def test_github_issue_47(): """Incorrect wrap pre-formatted value""" text = '''pre.. word @@ -172,6 +190,7 @@ def test_github_issue_47(): yet anothe word''' assert result == expect + def test_github_issue_49(): """Key error on russian hash-route link""" s = '"link":https://ru.vuejs.org/v2/guide/components.html#Входные-параметры' @@ -179,6 +198,7 @@ def test_github_issue_49(): expect = '\t' assert result == expect + def test_github_issue_50(): """Incorrect wrap code with Java generics in pre""" test = ('pre.. public class Tynopet
This is some TEXT inside a "Code BLOCK"
@@ -299,6 +325,7 @@ def test_github_pull_61():
result = t.parse(test)
assert result == expect
+
def test_github_pull_62():
"""Fix for paragraph multiline, only last paragraph is rendered
correctly"""
@@ -341,6 +368,7 @@ def test_github_pull_62():
result = t.parse(test)
assert result == expect
+
def test_github_pull_63():
"""Forgot to set multiline_para to False"""
test = '''p.. First one 'is'
From f15dc31edef29df3b140070be1d64f3e6205272e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:36:35 -0500
Subject: [PATCH 158/257] flake8: whitespace cleanup
---
tests/test_cli.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 5f6e501f..57b2d5f9 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -3,28 +3,30 @@
import textile
+
def test_console_script():
command = [sys.executable, '-m', 'textile', 'README.textile']
try:
result = subprocess.check_output(command)
except AttributeError:
command[2] = 'textile.__main__'
- result = subprocess.Popen(command,
- stdout=subprocess.PIPE).communicate()[0]
+ result = subprocess.Popen(
+ command, stdout=subprocess.PIPE).communicate()[0]
with open('tests/fixtures/README.txt') as f:
expect = ''.join(f.readlines())
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]
+ result = subprocess.Popen(
+ command, stdout=subprocess.PIPE).communicate()[0]
if type(result) == bytes:
result = result.decode('utf-8')
assert result.strip() == textile.__version__
From 8abe7f4e7b8acbf0efd3b25123221e6c16ff5aa0 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:52:50 -0500
Subject: [PATCH 159/257] flake8: whitespace cleanup
---
tests/test_attributes.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_attributes.py b/tests/test_attributes.py
index 0f5d0193..b07712f7 100644
--- a/tests/test_attributes.py
+++ b/tests/test_attributes.py
@@ -1,5 +1,6 @@
from textile.utils import parse_attributes
+
def test_parse_attributes():
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
assert parse_attributes('/1', element='td') == {'rowspan': '1'}
From ed28e7155fc48b13aeccf6d5160bec9d1553e91e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:53:42 -0500
Subject: [PATCH 160/257] flake8: whitespace cleanup
---
tests/test_getimagesize.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_getimagesize.py b/tests/test_getimagesize.py
index 43f85e3a..3a3c0a9c 100644
--- a/tests/test_getimagesize.py
+++ b/tests/test_getimagesize.py
@@ -3,6 +3,7 @@
PIL = pytest.importorskip('PIL')
+
def test_imagesize():
assert getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110)
assert getimagesize("http://bad.domain/") == ''
From 3c222b214ff9392623c2b4be856eeccb7eee5f1b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:55:41 -0500
Subject: [PATCH 161/257] flake8: whitespace cleanup
---
tests/test_glyphs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_glyphs.py b/tests/test_glyphs.py
index 56b0d272..ed50ad53 100644
--- a/tests/test_glyphs.py
+++ b/tests/test_glyphs.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_glyphs():
t = Textile()
From 4304da9394c5d33f7724692797364b1172ea2082 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:57:52 -0500
Subject: [PATCH 162/257] flake8: whitespace cleanup
---
tests/test_subclassing.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_subclassing.py b/tests/test_subclassing.py
index 9235e032..a7db99a3 100644
--- a/tests/test_subclassing.py
+++ b/tests/test_subclassing.py
@@ -1,10 +1,10 @@
import textile
+
def test_change_glyphs():
class TextilePL(textile.Textile):
glyph_definitions = dict(textile.Textile.glyph_definitions,
- quote_double_open = '„'
- )
+ quote_double_open='„')
test = 'Test "quotes".'
expect = '\tTest „quotes”.
'
From 5c663e39ca1f7551f8e5304245abf9d5ea2e5d53 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:58:40 -0500
Subject: [PATCH 163/257] flake8: whitespace cleanup
---
tests/test_imagesize.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_imagesize.py b/tests/test_imagesize.py
index 0a89b43a..e7d9d88b 100644
--- a/tests/test_imagesize.py
+++ b/tests/test_imagesize.py
@@ -1,10 +1,11 @@
import textile
+
def test_imagesize():
imgurl = 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png'
result = textile.tools.imagesize.getimagesize(imgurl)
try:
- import PIL # noqa: F401
+ import PIL # noqa: F401
expect = (275, 95)
assert result == expect
From 0b66de8799a06a38068ea8c418d28d7bec080eb3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:17:17 -0500
Subject: [PATCH 164/257] flake8: whitespace cleanup
---
tests/test_textilefactory.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_textilefactory.py b/tests/test_textilefactory.py
index 846b9275..e9fc027f 100644
--- a/tests/test_textilefactory.py
+++ b/tests/test_textilefactory.py
@@ -1,6 +1,7 @@
from textile import textilefactory
import pytest
+
def test_TextileFactory():
f = textilefactory.TextileFactory()
result = f.process("some text here")
From 343e26d8a00e61a510b380145a213828ee4bae96 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:18:01 -0500
Subject: [PATCH 165/257] flake8: whitespace cleanup
---
tests/test_getRefs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_getRefs.py b/tests/test_getRefs.py
index d3cfcd72..8a22d4fb 100644
--- a/tests/test_getRefs.py
+++ b/tests/test_getRefs.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_getRefs():
t = Textile()
result = t.getRefs("some text [Google]http://www.google.com")
From fddda0ca1e73f73c588c2889b0a465a91f9d5f19 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:18:34 -0500
Subject: [PATCH 166/257] flake8: whitespace cleanup
---
tests/test_footnoteRef.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_footnoteRef.py b/tests/test_footnoteRef.py
index c973ee7b..5ac2ea4b 100644
--- a/tests/test_footnoteRef.py
+++ b/tests/test_footnoteRef.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_footnoteRef():
t = Textile()
result = t.footnoteRef('foo[1]')
From 739ee86698c6bf4357c9211365410c4f55f12569 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:19:14 -0500
Subject: [PATCH 167/257] flake8: whitespace cleanup
---
tests/test_table.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_table.py b/tests/test_table.py
index 0a3cb0d6..1ea34e94 100644
--- a/tests/test_table.py
+++ b/tests/test_table.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_table():
t = Textile()
result = t.table('(rowclass). |one|two|three|\n|a|b|c|')
From 0def35bc88b2b8c0f0385106787dd254bf6da838 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:21:12 -0500
Subject: [PATCH 168/257] flake8: whitespace cleanup
---
tests/test_values.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tests/test_values.py b/tests/test_values.py
index 5d159509..7ebd2c78 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -506,12 +506,14 @@
)
+
@pytest.mark.parametrize("input, expected_output", xhtml_known_values)
def test_KnownValuesXHTML(input, expected_output):
# XHTML
output = textile.textile(input, html_type='xhtml')
assert output == expected_output
+
@pytest.mark.parametrize("input, expected_output", html_known_values)
def test_KnownValuesHTML(input, expected_output):
# HTML5
From 5eea5a77cbdab22fd3c381410b75c5a2077d82ae Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:21:42 -0500
Subject: [PATCH 169/257] flake8: whitespace cleanup
---
tests/test_values.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/test_values.py b/tests/test_values.py
index 7ebd2c78..f08ac6fc 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -35,7 +35,7 @@
('h3. Header 3', '\tHeader 3
'),
('An old text\n\nbq. A block quotation.\n\nAny old text''',
- '\tAn old text
\n\n\t\n\t\tA block quotation.
\n\t
\n\n\tAny old text
'),
+ '\tAn old text
\n\n\t\n\t\tA block quotation.
\n\t
\n\n\tAny old text
'),
('I _believe_ every word.', '\tI believe every word.
'),
@@ -70,8 +70,8 @@
('p[fr]. rouge', '\trouge
'),
('I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%.',
- '\tI seriously blushed
\nwhen I sprouted'
- ' that
\ncorn stalk from my
\ncabeza.
'),
+ '\tI seriously blushed
\nwhen I sprouted'
+ ' that
\ncorn stalk from my
\ncabeza.
'),
('p<. align left', '\talign left
'),
@@ -226,7 +226,7 @@
("""table(#dvds){border-collapse:collapse}. Great films on DVD employing Textile summary, caption, thead, tfoot, two tbody elements and colgroups\n|={font-size:140%;margin-bottom:15px}. DVDs with two Textiled tbody elements\n|:\\3. 100 |{background:#ddd}|250||50|300|\n|^(header).\n|_. Title |_. Starring |_. Director |_. Writer |_. Notes |\n|~(footer).\n|\\5=. This is the tfoot, centred |\n|-(toplist){background:#c5f7f6}.\n| _The Usual Suspects_ | Benicio Del Toro, Gabriel Byrne, Stephen Baldwin, Kevin Spacey | Bryan Singer | Chris McQaurrie | One of the finest films ever made |\n| _Se7en_ | Morgan Freeman, Brad Pitt, Kevin Spacey | David Fincher | Andrew Kevin Walker | Great psychological thriller |\n| _Primer_ | David Sullivan, Shane Carruth | Shane Carruth | Shane Carruth | Amazing insight into trust and human psychology
rather than science fiction. Terrific! |\n| _District 9_ | Sharlto Copley, Jason Cope | Neill Blomkamp | Neill Blomkamp, Terri Tatchell | Social commentary layered on thick,\nbut boy is it done well |\n|-(medlist){background:#e7e895;}.\n| _Arlington Road_ | Tim Robbins, Jeff Bridges | Mark Pellington | Ehren Kruger | Awesome study in neighbourly relations |\n| _Phone Booth_ | Colin Farrell, Kiefer Sutherland, Forest Whitaker | Joel Schumacher | Larry Cohen | Edge-of-the-seat stuff in this\nshort but brilliantly executed thriller |""",
"""\t\n\tDVDs with two Textiled tbody elements \n\t\n\t \n\t \n\t \n\t \n\t \n\t \n\t\n\t\t\n\t\t\tTitle \n\t\t\tStarring \n\t\t\tDirector \n\t\t\tWriter \n\t\t\tNotes \n\t\t \n\t\n\t\n\t\t\n\t\t\tThis is the tfoot, centred \n\t\t \n\t\n\t\n\t\t\n\t\t\t The Usual Suspects \n\t\t\t Benicio Del Toro, Gabriel Byrne, Stephen Baldwin, Kevin Spacey \n\t\t\t Bryan Singer \n\t\t\t Chris McQaurrie \n\t\t\t One of the finest films ever made \n\t\t \n\t\t\n\t\t\t Se7en \n\t\t\t Morgan Freeman, Brad Pitt, Kevin Spacey \n\t\t\t David Fincher \n\t\t\t Andrew Kevin Walker \n\t\t\t Great psychological thriller \n\t\t \n\t\t\n\t\t\t Primer \n\t\t\t David Sullivan, Shane Carruth \n\t\t\t Shane Carruth \n\t\t\t Shane Carruth \n\t\t\t Amazing insight into trust and human psychology
\nrather than science fiction. Terrific! \n\t\t \n\t\t\n\t\t\t District 9 \n\t\t\t Sharlto Copley, Jason Cope \n\t\t\t Neill Blomkamp \n\t\t\t Neill Blomkamp, Terri Tatchell \n\t\t\t Social commentary layered on thick,
\nbut boy is it done well \n\t\t \n\t\n\t\n\t\t\n\t\t\t Arlington Road \n\t\t\t Tim Robbins, Jeff Bridges \n\t\t\t Mark Pellington \n\t\t\t Ehren Kruger \n\t\t\t Awesome study in neighbourly relations \n\t\t \n\t\t\n\t\t\t Phone Booth \n\t\t\t Colin Farrell, Kiefer Sutherland, Forest Whitaker \n\t\t\t Joel Schumacher \n\t\t\t Larry Cohen \n\t\t\t Edge-of-the-seat stuff in this
\nshort but brilliantly executed thriller \n\t\t \n\t\n\t
"""),
("""-(hot) *coffee* := Hot _and_ black\n-(hot#tea) tea := Also hot, but a little less black\n-(cold) milk := Nourishing beverage for baby cows.\nCold drink that goes great with cookies. =:\n\n-(hot) coffee := Hot and black\n-(hot#tea) tea := Also hot, but a little less black\n-(cold) milk :=\nNourishing beverage for baby cows.\nCold drink that goes great with cookies. =:""",
- """\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\t- Nourishing beverage for baby cows.
\nCold drink that goes great with cookies. \n
\n\n\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\tNourishing beverage for baby cows.
\nCold drink that goes great with cookies.
\n
"""),
+ """\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\t- Nourishing beverage for baby cows.
\nCold drink that goes great with cookies. \n
\n\n\n\t- coffee
\n\t- Hot and black
\n\t- tea
\n\t- Also hot, but a little less black
\n\t- milk
\n\tNourishing beverage for baby cows.
\nCold drink that goes great with cookies.
\n
"""),
(""";(class#id) Term 1\n: Def 1\n: Def 2\n: Def 3""",
"""\t\n\t\t- Term 1
\n\t\t- Def 1
\n\t\t- Def 2
\n\t\t- Def 3
\n\t
"""),
("""*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**""",
@@ -266,8 +266,8 @@
('I __know__.\nI **really** __know__.', '\tI know.
\nI really know.
'),
("I'm %{color:red}unaware%\nof most soft drinks.", '\tI’m unaware
\nof most soft drinks.
'),
('I seriously *{color:red}blushed*\nwhen I _(big)sprouted_ that\ncorn stalk from my\n%[es]cabeza%.',
- '\tI seriously blushed
\nwhen I sprouted'
- ' that
\ncorn stalk from my
\ncabeza.
'),
+ '\tI seriously blushed
\nwhen I sprouted'
+ ' that
\ncorn stalk from my
\ncabeza.
'),
('\n\na.gsub!( /, "" )\n\n
',
'\n\na.gsub!( /</, "" )\n\n
'),
('\n\nh3. Sidebar\n\n"Hobix":http://hobix.com/\n"Ruby":http://ruby-lang.org/\n\n\n\n'
From e0e488916e007595806364bb49eb175f53ce9243 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:22:50 -0500
Subject: [PATCH 170/257] flake8: whitespace cleanup
---
tests/test_utils.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 7f386a9b..a6e88f8a 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -3,21 +3,25 @@
from textile import utils
+
def test_encode_html():
result = utils.encode_html('''this is a "test" of text that's safe to '''
- 'put in an attribute.')
+ 'put in an attribute.')
expect = ('this is a "test" of text that's safe to put in '
- 'an <html> attribute.')
+ 'an <html> attribute.')
assert result == expect
+
def test_has_raw_text():
assert utils.has_raw_text('foo bar biz baz
') is False
assert utils.has_raw_text(' why yes, yes it does') is True
+
def test_is_rel_url():
assert utils.is_rel_url("http://www.google.com/") is False
assert utils.is_rel_url("/foo") is True
+
def test_generate_tag():
result = utils.generate_tag('span', 'inner text', {'class': 'test'})
expect = 'inner text'
From 1281ede405ae71b365c8c20ea02480006b7d543e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:25:27 -0500
Subject: [PATCH 171/257] turn flake8 warnings and errors back on
---
.flake8 | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.flake8 b/.flake8
index 07c24d1c..9f8ccc38 100644
--- a/.flake8
+++ b/.flake8
@@ -2,8 +2,5 @@
ignore =
# line too long
E501
- # temporarily ignore warnings and errors
- W
- E
exclude =
build/
From e60b72fe625a71289c731d8363a335e5c5fc7be2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:35:36 -0500
Subject: [PATCH 172/257] use environment vars as intended
maybe this will fix a warning about unexpected inputs ???
---
.github/workflows/lint_and_test.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 437820dc..f82f4c2f 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -20,9 +20,10 @@ jobs:
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
+ env:
+ IMAGESIZE: ${{ matrix.image-size }}
run: |
imagesize=''
- IMAGESIZE=${{ matrix.image-size }}
pip install -U pytest pytest-cov coverage codecov
if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
From bda9a67d44011734bf66ebd6b8a9599963b2ac2b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:42:24 -0500
Subject: [PATCH 173/257] further testing of environment variables
---
.github/workflows/lint_and_test.yml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index f82f4c2f..5ba1e869 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
- image-size: ['true', 'false']
+ image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
@@ -20,12 +20,10 @@ jobs:
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
- env:
- IMAGESIZE: ${{ matrix.image-size }}
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
- if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
+ if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
From 45257b6d8ddae53c281490c95b9d3a3ecb83cf7d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:44:45 -0500
Subject: [PATCH 174/257] This is probably the source of the `unexpected
inputs` warning
---
.github/workflows/lint_and_test.yml | 1 -
1 file changed, 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 5ba1e869..47ce8cf5 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -16,7 +16,6 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- image-size: ${{ matrix.image-size }}
- name: Python flake8 Lint
uses: py-actions/flake8@v1.2.0
- name: Install dependencies
From dd5982ee3345a638fb6db15547f1feb132b4b064 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 20:49:10 -0500
Subject: [PATCH 175/257] add pypy3 to github actions
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 47ce8cf5..0db7ea80 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
+ python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
From 060e7f46846d427e6674af9ddcb7ced8e1f2f7f3 Mon Sep 17 00:00:00 2001
From: Brad Schoening <5796692+bschoening@users.noreply.github.com>
Date: Mon, 22 Jul 2024 22:23:50 -0400
Subject: [PATCH 176/257] Update setup.py to support Python 3.8..3.12
---
setup.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup.py b/setup.py
index b405f28b..cbbb7747 100644
--- a/setup.py
+++ b/setup.py
@@ -28,11 +28,11 @@ def get_version():
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Programming Language :: Python :: 3.7',
'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',
],
keywords='textile,text,html markup',
From 3eb20497fec2bc31ee6184d2e64a2abab3568ab6 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:18:12 -0400
Subject: [PATCH 177/257] update versions to test against
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 0db7ea80..f488521f 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
+ python-version: [3.8, 3.9, 3.10, 3.11, 3.12, pypy3]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
From 3fc933a17814adf94a46f0fc651f1eb388ad2f77 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:22:46 -0400
Subject: [PATCH 178/257] make sure versions are interpreted as strings
3.10 was being interpreted as 3.1 with a trailing 0
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index f488521f..935d6883 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.8, 3.9, 3.10, 3.11, 3.12, pypy3]
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v2
From fe144a8ae0947cf941197eb0804984a4b4812cdc Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:26:09 -0400
Subject: [PATCH 179/257] use isinstance for type comparison
fixes a flake8 failure
---
tests/test_cli.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 57b2d5f9..5e6ab794 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -14,7 +14,7 @@ def test_console_script():
command, stdout=subprocess.PIPE).communicate()[0]
with open('tests/fixtures/README.txt') as f:
expect = ''.join(f.readlines())
- if type(result) == bytes:
+ if isinstance(result, bytes):
result = result.decode('utf-8')
assert result == expect
@@ -27,6 +27,6 @@ def test_version_string():
command[2] = 'textile.__main__'
result = subprocess.Popen(
command, stdout=subprocess.PIPE).communicate()[0]
- if type(result) == bytes:
+ if isinstance(result, bytes):
result = result.decode('utf-8')
assert result.strip() == textile.__version__
From dd353101a7116acd96594afac624d52d1c310b76 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:36:54 -0400
Subject: [PATCH 180/257] try the latest version of the github action
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 935d6883..96bfd6d3 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -17,7 +17,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Python flake8 Lint
- uses: py-actions/flake8@v1.2.0
+ uses: py-actions/flake8@v2.3.0
- name: Install dependencies
run: |
imagesize=''
From 5b44180a58def4527c29750cde59e2a8a482687e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:41:42 -0400
Subject: [PATCH 181/257] update other actions as well
---
.github/workflows/lint_and_test.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 96bfd6d3..c4d4aab6 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -11,9 +11,9 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]
image_size: ['true', 'false']
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Python flake8 Lint
From 9bb449a97e149428951d122156346cebbd7501a3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:54:17 -0400
Subject: [PATCH 182/257] fix version spec for pypy
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index c4d4aab6..cc2690b8 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v4
From 56c912b568ce24404f1291ddb068904b87bd7631 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:59:57 -0400
Subject: [PATCH 183/257] update to the latest version of the codecov action
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index cc2690b8..8cfec1fd 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -28,4 +28,4 @@ jobs:
run: |
pytest
- name: Codecov
- uses: codecov/codecov-action@v2.1.0
+ uses: codecov/codecov-action@v4
From dac1716210fe6d9b4c631ce3b8b861c75b381149 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 12:07:53 -0400
Subject: [PATCH 184/257] add codecov token which is stored as a secret
---
.github/workflows/lint_and_test.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 8cfec1fd..44a7c917 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -29,3 +29,5 @@ jobs:
pytest
- name: Codecov
uses: codecov/codecov-action@v4
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
From 07782366f00bcc723033a9aa42b72eb16de6ff0e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 12:58:55 -0400
Subject: [PATCH 185/257] update badge to github actions
---
README.textile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.textile b/README.textile
index 98f4fbde..797516c0 100644
--- a/README.textile
+++ b/README.textile
@@ -1,4 +1,4 @@
-!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
From 47a03ebbec92576fcdef1b681884b2cf3d16079f Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 13:01:08 -0400
Subject: [PATCH 186/257] update fixture to reflect README changes
---
tests/fixtures/README.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index 949db700..a4859438 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -1,4 +1,4 @@
-
+
python-textile
From c4308890fecc070622b963557507f98509e69460 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 13:59:53 -0400
Subject: [PATCH 187/257] update minimum supported python version
---
setup.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index cbbb7747..b14b9a60 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
-from setuptools import setup, find_packages
import os
+from setuptools import setup, find_packages
def get_version():
@@ -48,5 +48,5 @@ def get_version():
tests_require=['pytest', 'pytest-cov'],
include_package_data=True,
zip_safe=False,
- python_requires='>=3.5',
+ python_requires='>=3.8',
)
From f8533fae9964f744105a01769213ca00dd9d1ffb Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:15:18 -0400
Subject: [PATCH 188/257] codecov is reporting missing coverage in this file
testing to see if moving this import will have any affect
---
textile/tools/imagesize.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/textile/tools/imagesize.py b/textile/tools/imagesize.py
index 6fba73eb..ec724a2c 100644
--- a/textile/tools/imagesize.py
+++ b/textile/tools/imagesize.py
@@ -1,3 +1,5 @@
+from urllib.request import urlopen
+
def getimagesize(url):
"""
Attempts to determine an image's width and height, and returns a tuple,
@@ -11,8 +13,6 @@ def getimagesize(url):
except ImportError:
return ''
- from urllib.request import urlopen
-
try:
p = ImageFile.Parser()
f = urlopen(url)
From 1f32b74d233a3e3f6bfe134ea251ba5c4ab608ab Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:17:00 -0400
Subject: [PATCH 189/257] flake8 insists on two new lines
---
textile/tools/imagesize.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/textile/tools/imagesize.py b/textile/tools/imagesize.py
index ec724a2c..1d758cce 100644
--- a/textile/tools/imagesize.py
+++ b/textile/tools/imagesize.py
@@ -1,5 +1,6 @@
from urllib.request import urlopen
+
def getimagesize(url):
"""
Attempts to determine an image's width and height, and returns a tuple,
From db58e41ab37a3f0a158d4ace15a51dbbbfcf665e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:23:05 -0400
Subject: [PATCH 190/257] setting this back to what it was
---
textile/tools/imagesize.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/textile/tools/imagesize.py b/textile/tools/imagesize.py
index 1d758cce..6fba73eb 100644
--- a/textile/tools/imagesize.py
+++ b/textile/tools/imagesize.py
@@ -1,6 +1,3 @@
-from urllib.request import urlopen
-
-
def getimagesize(url):
"""
Attempts to determine an image's width and height, and returns a tuple,
@@ -14,6 +11,8 @@ def getimagesize(url):
except ImportError:
return ''
+ from urllib.request import urlopen
+
try:
p = ImageFile.Parser()
f = urlopen(url)
From 88042c5591818d4e4a6acf810029e7038e0aca5e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:23:21 -0400
Subject: [PATCH 191/257] debugging the value of imagesize
---
.github/workflows/lint_and_test.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 44a7c917..e9323726 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -24,6 +24,8 @@ jobs:
pip install -U pytest pytest-cov coverage codecov
if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
+ echo "INPUT_IMAGE_SIZE: ${INPUT_IMAGE_SIZE}"
+ echo "imagesize: ${imagesize}"
- name: run tests
run: |
pytest
From 9c23fdff323c62430f8633bbd90201895f338d0b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:25:23 -0400
Subject: [PATCH 192/257] more debugging
---
.github/workflows/lint_and_test.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index e9323726..f4795b27 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -24,6 +24,7 @@ jobs:
pip install -U pytest pytest-cov coverage codecov
if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
+ echo "image_size: ${image_size}"
echo "INPUT_IMAGE_SIZE: ${INPUT_IMAGE_SIZE}"
echo "imagesize: ${imagesize}"
- name: run tests
From 889432773d7a53dc23ffdfcbae43156bdca24b28 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:30:29 -0400
Subject: [PATCH 193/257] maybe this is the right way to reference matrix
values???
---
.github/workflows/lint_and_test.yml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index f4795b27..047e6d8d 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -24,9 +24,7 @@ jobs:
pip install -U pytest pytest-cov coverage codecov
if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- echo "image_size: ${image_size}"
- echo "INPUT_IMAGE_SIZE: ${INPUT_IMAGE_SIZE}"
- echo "imagesize: ${imagesize}"
+ echo "image_size: ${{ matrix.image_size }}"
- name: run tests
run: |
pytest
From c55d83b16203cd75047b0acc57cad0a892b73250 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:32:17 -0400
Subject: [PATCH 194/257] correct way to look up matrix value
---
.github/workflows/lint_and_test.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 047e6d8d..14ced37f 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -22,9 +22,8 @@ jobs:
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
- if [[ $INPUT_IMAGE_SIZE == true ]] ; then imagesize='[imagesize]' ; fi
+ if [[ ${{ matrix.image_size }} == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- echo "image_size: ${{ matrix.image_size }}"
- name: run tests
run: |
pytest
From abb0581805cb05301a5c6d06e2f604aec7f923b2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 14:55:42 -0400
Subject: [PATCH 195/257] flake8 cleanup
---
tests/test_values.py | 4 ++--
textile/core.py | 14 ++++----------
textile/objects/table.py | 2 +-
textile/utils.py | 4 ++--
4 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/tests/test_values.py b/tests/test_values.py
index f08ac6fc..62c797db 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -430,8 +430,8 @@
'\tTwo line with strong
\nheading
'),
# Non-standalone ampersands should not be escaped
(("“test”\n\n"
- "“test”\n\n"
- " test \n"),
+ "“test”\n\n"
+ " test \n"),
("\t“test”
\n\n"
"\t“test”
\n\n"
"\t test
")),
diff --git a/textile/core.py b/textile/core.py
index 1457c64e..9c93ad7c 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -209,11 +209,6 @@ def __init__(self, restricted=False, lite=False, noimage=False,
self.refIndex = 0
self.block_tags = block_tags
- cur = r''
- if regex_snippets['cur']: # pragma: no branch
- cur = r'(?:[{0}]{1}*)?'.format(regex_snippets['cur'],
- regex_snippets['space'])
-
self.glyph_replacers = make_glyph_replacers(
html_type, self.uid, self.glyph_definitions)
@@ -424,7 +419,7 @@ def fPBr(self, m):
re.compile(r"
{0}*\n(?![{0}|])".format(regex_snippets['space']),
re.I)
.sub("\n", content))
- content = re.compile(r"\n(?![\s|])").sub('
',content)
+ content = re.compile(r"\n(?![\s|])").sub('
', content)
return '<{0}{1}>{2}{3}'.format(m.group(1), m.group(2), content, m.group(4))
def doBr(self, match):
@@ -1122,11 +1117,11 @@ def storeTags(self, opentag, closetag=''):
tags = {}
self.refIndex += 1
self.refCache[self.refIndex] = opentag
- tags['open'] = self.uid + str(self.refIndex) + ':ospan ';
+ tags['open'] = self.uid + str(self.refIndex) + ':ospan '
self.refIndex += 1
self.refCache[self.refIndex] = closetag
- tags['close'] = ' ' + self.uid + str(self.refIndex) + ':cspan';
+ tags['close'] = ' ' + self.uid + str(self.refIndex) + ':cspan'
return tags
def retrieveTags(self, text):
@@ -1139,7 +1134,6 @@ def retrieveTags(self, text):
def fRetrieveTags(self, match):
return self.refCache[int(match.group('token'))]
-
def image(self, text):
pattern = re.compile(r"""
(?:[\[{{])? # pre
@@ -1363,7 +1357,7 @@ def fNoteLists(self, match):
content)
else:
li = ('\t\t{1} Undefined Note [#{2}]. '
- ).format(atts, links, info['seq'])
+ ).format(atts, links, info['seq'])
o.append(li)
if '+' == extras and self.unreferencedNotes:
for seq, info in self.unreferencedNotes.items():
diff --git a/textile/objects/table.py b/textile/objects/table.py
index 7a3d0cea..ba034f2a 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -5,7 +5,7 @@
from textile.regex_strings import (align_re_s, cls_re_s, regex_snippets,
table_span_re_s, valign_re_s, pnct_re_s)
-from textile.utils import generate_tag, parse_attributes
+from textile.utils import generate_tag, parse_attributes, pba
try:
import regex as re
diff --git a/textile/utils.py b/textile/utils.py
index 9a459a99..1a04182f 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -22,11 +22,12 @@
# else the regex module doesn't properly match pre-s. It only matches the
# p in pre.
re.compile(r'<(pre|p|blockquote|div|form|table|ul|ol|dl|h[1-6])[^>]*?>.*\1>',
- re.S),
+ re.S),
re.compile(r'<(hr|br)[^>]*?/>'),
re.compile(r''),
)
+
def decode_high(text):
"""Decode encoded HTML entities."""
text = '{0};'.format(text)
@@ -88,7 +89,6 @@ def has_raw_text(text):
return r != ''
-
def is_rel_url(url):
"""Identify relative urls."""
(scheme, netloc) = urlparse(url)[0:2]
From 82fe31acdd6333ca6b5f732e798190b504e55fcb Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 15:02:52 -0400
Subject: [PATCH 196/257] fix colgroup handling
---
textile/objects/table.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index ba034f2a..2471d3c4 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -57,19 +57,17 @@ def process(self):
# Colgroup -- A colgroup row will not necessarily end with a |.
# Hence it may include the next row of actual table data.
-
- gmtch = self.colgroup_re.match(row)
- if gmtch:
- cols = gmtch.group(1).replace('.', "")
- for idx, col in enumerate(cols.split("|")):
- gatts = pba(col.strip(), 'col', restricted=self.textile.restricted)
- self.colgroup += '\t ') if idx == 0 else (gatts + ' />'))
- self.colgroup += '\t'
- nl_index = row.find('\n')
- if nl_index >= 0:
- row = row[nl_index:].lstrip()
+ if row[:2] == '|:':
+ if '\n' in row:
+ colgroup_data, row = row[2:].split('\n')
else:
+ colgroup_data, row = row[2:], ''
+ colgroup_atts, cols = colgroup_data, None
+ if '|' in colgroup_data:
+ colgroup_atts, cols = colgroup_data.split('|', 1)
+ colgrp = Colgroup(cols, colgroup_atts, restricted=self.textile.restricted)
+ self.colgroup = colgrp.process()
+ if row == '':
continue
# search the row for a table group - thead, tfoot, or tbody
From 57e01fcfc89e1ff5dc6d04a86660f24567fe44b4 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 15:04:27 -0400
Subject: [PATCH 197/257] remove unused import
---
textile/objects/table.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index 2471d3c4..96adaedd 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -5,7 +5,7 @@
from textile.regex_strings import (align_re_s, cls_re_s, regex_snippets,
table_span_re_s, valign_re_s, pnct_re_s)
-from textile.utils import generate_tag, parse_attributes, pba
+from textile.utils import generate_tag, parse_attributes
try:
import regex as re
From 063aaab3fa8ba039557db658aa9297d100ce6841 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 15:22:02 -0400
Subject: [PATCH 198/257] fix formatting of captions and colgroups
---
textile/objects/table.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index 96adaedd..fcecb069 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -152,7 +152,7 @@ def __init__(self, capts, cap, row, restricted):
def process(self, cap):
tag = generate_tag('caption', cap.strip(), self.attributes)
- return '\t{0}\n\t'.format(tag)
+ return '\t{0}\n'.format(tag)
class Colgroup(object):
@@ -181,7 +181,7 @@ def process(self):
# tab between cols and a newline at the end
xml_declaration = "\n"
colgrp = colgrp.replace(xml_declaration, '')
- return colgrp.replace('><', '>\n\t<')
+ return f'\t{colgrp.replace('><', '>\n\t<')}'
class Row(object):
From 036f4ba34f6466b12d166735932db5ce00f53d37 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 15:25:01 -0400
Subject: [PATCH 199/257] fix f-string formatting
---
textile/objects/table.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index fcecb069..ac1da76e 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -181,7 +181,7 @@ def process(self):
# tab between cols and a newline at the end
xml_declaration = "\n"
colgrp = colgrp.replace(xml_declaration, '')
- return f'\t{colgrp.replace('><', '>\n\t<')}'
+ return f"\t{colgrp.replace('><', '>\n\t<')}"
class Row(object):
From 6e041ab237b2536e23f65cf3c87ede1aa3ffd19f Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 6 Aug 2024 15:26:57 -0400
Subject: [PATCH 200/257] further f-string formatting fix
---
textile/objects/table.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index ac1da76e..42644b5c 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -181,7 +181,8 @@ def process(self):
# tab between cols and a newline at the end
xml_declaration = "\n"
colgrp = colgrp.replace(xml_declaration, '')
- return f"\t{colgrp.replace('><', '>\n\t<')}"
+ colgrp = colgrp.replace('><', '>\n\t<')
+ return f"\t{colgrp}"
class Row(object):
From a10ace1feccf1296f53ae39234bf8e5c73dac772 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 15:01:30 -0400
Subject: [PATCH 201/257] add a test for a table which has a colgroup but no
caption
---
tests/test_values.py | 8 +++++++-
textile/objects/table.py | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tests/test_values.py b/tests/test_values.py
index 62c797db..957a42e9 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -503,7 +503,13 @@
# Table column with an emphasis should not be confused with a heading
('|_touch_ this!| _touch_ this! |',
'\t\n\t\t\n\t\t\ttouch this! \n\t\t\t touch this! \n\t\t \n\t
'),
-
+ # Table with colgroup but no caption
+ (("|:\\5. 80 |\x20\n"
+ "|a|b|c|d|e|\x20\n"),
+ ('\t\n'
+ '\t\n\t \n'
+ '\t\t\n\t\t\ta \n\t\t\tb \n\t\t\tc \n\t\t\td \n\t\t\te \n\t\t \n'
+ '\t
')),
)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index 42644b5c..a257bd0c 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -152,7 +152,7 @@ def __init__(self, capts, cap, row, restricted):
def process(self, cap):
tag = generate_tag('caption', cap.strip(), self.attributes)
- return '\t{0}\n'.format(tag)
+ return '\t{0}'.format(tag)
class Colgroup(object):
@@ -182,7 +182,7 @@ def process(self):
xml_declaration = "\n"
colgrp = colgrp.replace(xml_declaration, '')
colgrp = colgrp.replace('><', '>\n\t<')
- return f"\t{colgrp}"
+ return f"\n\t{colgrp}"
class Row(object):
From 0c2c0fa376faa0f457c7da4a09da83e978b1dc2b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 15:40:31 -0400
Subject: [PATCH 202/257] confirm that the extra newline from captions without
colgroups is fixed
---
tests/test_textile.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 0b2abcaf..8a5e4f8e 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -76,7 +76,6 @@ def test_restricted():
expect = '''\
\t
\tYour caption goes here
-
\t
\t\t
\t\t\tA footer
From 9c4013c22993219771bdc88a47d1652850a08b8c Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 16:17:27 -0400
Subject: [PATCH 203/257] hopefully this will cover a missing line in codecov
---
tests/test_values.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_values.py b/tests/test_values.py
index 957a42e9..8b6d36b3 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -247,6 +247,7 @@
"""\tA definition list
\n\n\t\n\t\t- Term 1
\n\t\t- Def 1
\n\t\t- Def 2
\n\t\t- Def 3\n\t\t
\n\t\t\t- Center
\n\t\t\t- NATO
\n\t\t\t- Subdef 1
\n\t\t\t- Subdef 2\n\t\t\t
\n\t\t\t\t- SubSub Term
\n\t\t\t\t- SubSub Def 1
\n\t\t\t\t- SubSub Def 2
\n\t\t\t\t- Subsub Def 3
\nWith newline \n\t\t\t\t- Subsub Def 4
\n\t\t\t
\n\t\t\t- Subdef 3
\n\t\t
\n\t\t- DEF 4
\n\t\t- Term 2
\n\t\t- Another def
\n\t\t- And another
\n\t\t- One more\n\t\t
\n\t\t\t- A def without a term
\n\t\t\t- More defness
\n\t\t
\n\t\t- Third term for good measure
\n\t\t- My definition of a boombastic jazz
\n\t
"""),
("""###. Here's a comment.\n\nh3. Hello\n\n###. And\nanother\none.\n\nGoodbye.""", """\tHello
\n\n\tGoodbye.
"""),
("""h2. A Definition list which covers the instance where a new definition list is created with a term without a definition\n\n- term :=\n- term2 := def""", """\tA Definition list which covers the instance where a new definition list is created with a term without a definition
\n\n\n\t- term
\n\t- term2
\n\t- def
\n
"""),
+ ("""h2. A definition list where one item in the list is missing a definition for the term\n\n- Markdown := a perfectly cromulent plaintext markup system\n- Textile :=""", """\tA definition list where one item in the list is missing a definition for the term
\n\n\n\t- Markdown
\n\t- a perfectly cromulent plaintext markup system
\n\t- Textile
\n
"""),
('!{height:20px;width:20px;}https://1.gravatar.com/avatar/!',
'\t
'),
('& test', '\t& test
'),
From a169a7c508b978e82c0816a8f9ffe30a0938f43e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 16:36:23 -0400
Subject: [PATCH 204/257] I don't think we have to worry about a possibly
malformed term
---
textile/core.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 9c93ad7c..64541875 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -1276,10 +1276,7 @@ def fRCList(self, match):
.format(regex_snippets['space']),
content,
re.S)
- if xm:
- term, definition, _ = xm.groups()
- else:
- term, definition = content, ''
+ term, definition, _ = xm.groups()
# cleanup
term = term.strip()
definition = definition.strip(' ')
From 52c1b8a4be6eb2e0df294c0b4c1ea0c751e8722e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 16:40:52 -0400
Subject: [PATCH 205/257] If only I had read the test on the line immediately
above this
---
tests/test_values.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_values.py b/tests/test_values.py
index 8b6d36b3..957a42e9 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -247,7 +247,6 @@
"""\tA definition list
\n\n\t\n\t\t- Term 1
\n\t\t- Def 1
\n\t\t- Def 2
\n\t\t- Def 3\n\t\t
\n\t\t\t- Center
\n\t\t\t- NATO
\n\t\t\t- Subdef 1
\n\t\t\t- Subdef 2\n\t\t\t
\n\t\t\t\t- SubSub Term
\n\t\t\t\t- SubSub Def 1
\n\t\t\t\t- SubSub Def 2
\n\t\t\t\t- Subsub Def 3
\nWith newline \n\t\t\t\t- Subsub Def 4
\n\t\t\t
\n\t\t\t- Subdef 3
\n\t\t
\n\t\t- DEF 4
\n\t\t- Term 2
\n\t\t- Another def
\n\t\t- And another
\n\t\t- One more\n\t\t
\n\t\t\t- A def without a term
\n\t\t\t- More defness
\n\t\t
\n\t\t- Third term for good measure
\n\t\t- My definition of a boombastic jazz
\n\t
"""),
("""###. Here's a comment.\n\nh3. Hello\n\n###. And\nanother\none.\n\nGoodbye.""", """\tHello
\n\n\tGoodbye.
"""),
("""h2. A Definition list which covers the instance where a new definition list is created with a term without a definition\n\n- term :=\n- term2 := def""", """\tA Definition list which covers the instance where a new definition list is created with a term without a definition
\n\n\n\t- term
\n\t- term2
\n\t- def
\n
"""),
- ("""h2. A definition list where one item in the list is missing a definition for the term\n\n- Markdown := a perfectly cromulent plaintext markup system\n- Textile :=""", """\tA definition list where one item in the list is missing a definition for the term
\n\n\n\t- Markdown
\n\t- a perfectly cromulent plaintext markup system
\n\t- Textile
\n
"""),
('!{height:20px;width:20px;}https://1.gravatar.com/avatar/!',
'\t
'),
('& test', '\t& test
'),
From 164c09e572b37dddb5bb4e724fa2f3c4fb320c5d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 18:37:37 -0400
Subject: [PATCH 206/257] add test cases to increase code coverage for
parse_attributes
---
tests/test_attributes.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/test_attributes.py b/tests/test_attributes.py
index b07712f7..fed235de 100644
--- a/tests/test_attributes.py
+++ b/tests/test_attributes.py
@@ -1,3 +1,4 @@
+from typing import OrderedDict
from textile.utils import parse_attributes
@@ -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()
From d3cc63cfc07782ea2a8fd4a0b06c1e7ddc1c4fc9 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 18:47:50 -0400
Subject: [PATCH 207/257] move human_readable_url function into utils
---
textile/core.py | 13 +++----------
textile/utils.py | 8 ++++++++
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 64541875..ea94ac18 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -25,8 +25,9 @@
from textile.regex_strings import (align_re_s, cls_re_s, pnct_re_s,
regex_snippets, syms_re_s, table_span_re_s)
from textile.utils import (decode_high, encode_high, encode_html, generate_tag,
- has_raw_text, is_rel_url, is_valid_url, list_type,
- normalize_newlines, parse_attributes, pba)
+ has_raw_text, human_readable_url, is_rel_url,
+ is_valid_url, list_type, normalize_newlines,
+ parse_attributes, pba)
from textile.objects import Block, Table
try:
@@ -139,14 +140,6 @@ def make_glyph_replacers(html_type, uid, glyph_defs):
for (regex_obj, replacement) in pre_result]
-def human_readable_url(url):
- if "://" in url:
- url = url.split("://")[1]
- elif ":" in url:
- url = url.split(":")[1]
- return url
-
-
class Textile(object):
restricted_url_schemes = ('http', 'https', 'ftp', 'mailto')
unrestricted_url_schemes = restricted_url_schemes + (
diff --git a/textile/utils.py b/textile/utils.py
index 1a04182f..7045bcba 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -89,6 +89,14 @@ def has_raw_text(text):
return r != ''
+def human_readable_url(url):
+ if "://" in url:
+ url = url.split("://")[1]
+ elif ":" in url:
+ url = url.split(":")[1]
+ return url
+
+
def is_rel_url(url):
"""Identify relative urls."""
(scheme, netloc) = urlparse(url)[0:2]
From f10d0aea01ff915876a012ba17b801ae35a15aa2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 18:59:53 -0400
Subject: [PATCH 208/257] add human_readable_url edge case test to increase
coverage
---
tests/test_utils.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index a6e88f8a..6ddb93f8 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -32,3 +32,7 @@ def test_generate_tag():
expect = 'Übermensch'
result = utils.generate_tag('a', text, attributes)
assert result == expect
+
+
+def test_human_readable_url_edge_case():
+ assert utils.human_readable_url('tel:1-800-555-1212') == '1-800-555-1212'
From 4d6fd237f2a06e860e931a9ace9c48b575ca2cb4 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 7 Aug 2024 19:25:04 -0400
Subject: [PATCH 209/257] closing the final edge case for complete coverage of
human_readable_url
---
tests/test_utils.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 6ddb93f8..b2e455b4 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -35,4 +35,5 @@ def test_generate_tag():
def test_human_readable_url_edge_case():
+ assert utils.human_readable_url('google.com') == 'google.com'
assert utils.human_readable_url('tel:1-800-555-1212') == '1-800-555-1212'
From 08dc3dc9ca0ddfae0072d395141b474a3672c8ec Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 12:57:57 -0400
Subject: [PATCH 210/257] update README regarding Python version support
---
README.textile | 2 +-
tests/fixtures/README.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.textile b/README.textile
index 797516c0..7362c73e 100644
--- a/README.textile
+++ b/README.textile
@@ -42,7 +42,7 @@ bc.. import textile
h3. Notes:
-* Active development supports Python 3.5 or later.
+* Active development supports Python 3.8 or later.
h3. Running Tests
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index a4859438..fd5ce43d 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -47,7 +47,7 @@
Notes:
- - Active development supports Python 3.5 or later.
+ - Active development supports Python 3.8 or later.
Running Tests
From dbdf43031b0c237b5117767356f78eeeab31ac12 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 12:59:26 -0400
Subject: [PATCH 211/257] update CHANGELOG in preparation for next release
---
CHANGELOG.textile | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index 43beedca..e13f6f5e 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,5 +1,12 @@
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)
+* 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)
From 247dbfad5909da3579367619242990b036213377 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 13:05:28 -0400
Subject: [PATCH 212/257] update url for textile-lang
---
README.textile | 2 +-
tests/fixtures/README.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.textile b/README.textile
index 7362c73e..1bb9087e 100644
--- a/README.textile
+++ b/README.textile
@@ -2,7 +2,7 @@
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
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index fd5ce43d..01d0209d 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -2,7 +2,7 @@
python-textile
- python-textile is a Python port of Textile, Dean Allen’s humane web text generator.
+ python-textile is a Python port of Textile, Dean Allen’s humane web text generator.
Installation
From 8b26327ad665cd48e990d92a41f044d711d062e8 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 13:30:10 -0400
Subject: [PATCH 213/257] update contributors list
---
CONTRIBUTORS.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 5624ae6a..90d949aa 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -7,4 +7,6 @@ Alex Shiels
Jason Samsa
Kurt Raschke
Dave Brondsema
-Dmitry Shachnev
\ No newline at end of file
+Dmitry Shachnev
+Kirill Mavreshko
+Brad Schoening
\ No newline at end of file
From 739f758befd3fe349f179c37a435ecaf2ebb2e7e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 15:46:51 -0400
Subject: [PATCH 214/257] replace old setup.py config with pyproject.toml
---
MANIFEST.in | 2 --
pyproject.toml | 43 +++++++++++++++++++++++++++++++++++++++++
setup.py | 52 --------------------------------------------------
3 files changed, 43 insertions(+), 54 deletions(-)
delete mode 100644 MANIFEST.in
create mode 100644 pyproject.toml
delete mode 100644 setup.py
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 5ca56e8d..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include MANIFEST.in
-include tests/fixtures/README.txt
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..fdb4bd75
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,43 @@
+[build-system]
+requires = ["setuptools", "setuptools-scm"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "textile"
+authors = [
+ { name = "Dennis Burke", email = "ikirudennis@gmail.com"}
+]
+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 = [
+ 'html5lib>=1.0.1',
+ 'regex>1.0; implementation_name != "pypy"',
+]
+requires-python = '>=3.8'
+keywords = ['textile', 'text', 'html', 'markup']
+
+[project.optional-dependencies]
+develop = ['pytest', 'pytest-cov']
+imagesize = ['Pillow>=3.0.0',]
+
+[python.scripts]
+pytextile = "textile.__main__:main"
+
+[tool.setuptools.dynamic]
+version = {attr = "textile.__version__"}
diff --git a/setup.py b/setup.py
deleted file mode 100644
index b14b9a60..00000000
--- a/setup.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import os
-from setuptools import setup, find_packages
-
-
-def get_version():
- basedir = os.path.dirname(__file__)
- with open(os.path.join(basedir, 'textile/version.py')) as f:
- variables = {}
- exec(f.read(), variables)
- return variables.get('VERSION')
- raise RuntimeError('No version info found.')
-
-
-setup(
- name='textile',
- version=get_version(),
- author='Dennis Burke',
- author_email='ikirudennis@gmail.com',
- description='Textile processing for python.',
- url='http://github.com/textile/python-textile',
- packages=find_packages(),
- 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',
- ],
- keywords='textile,text,html markup',
- install_requires=[
- 'html5lib>=1.0.1',
- 'regex>1.0; implementation_name != "pypy"',
- ],
- extras_require={
- 'develop': ['pytest', 'pytest-cov'],
- 'imagesize': ['Pillow>=3.0.0'],
- },
- entry_points={'console_scripts': ['pytextile=textile.__main__:main']},
- tests_require=['pytest', 'pytest-cov'],
- include_package_data=True,
- zip_safe=False,
- python_requires='>=3.8',
-)
From 8a5053e45c82e68299c2451f79fb0ac8e7b43532 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 8 Aug 2024 19:17:53 -0400
Subject: [PATCH 215/257] define the urls for the pypi project
---
pyproject.toml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/pyproject.toml b/pyproject.toml
index fdb4bd75..f8e13efe 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -36,6 +36,11 @@ keywords = ['textile', 'text', 'html', 'markup']
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"
+
[python.scripts]
pytextile = "textile.__main__:main"
From c758c633f56271ea58c27d3c09736996fa0dab61 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 11:27:55 -0400
Subject: [PATCH 216/257] replace html5lib with nh3
We're only using the santizer part of html5lib, and it's being
deprecated. It seems nh3 is the recommended replacement at this time.
This change eliminates a series of Deprecation Warnings.
---
pyproject.toml | 2 +-
tests/test_textile.py | 2 +-
textile/core.py | 11 ++++++-----
textile/tools/sanitizer.py | 11 -----------
4 files changed, 8 insertions(+), 18 deletions(-)
delete mode 100644 textile/tools/sanitizer.py
diff --git a/pyproject.toml b/pyproject.toml
index f8e13efe..5ef4a96a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -26,7 +26,7 @@ classifiers = [
]
dynamic = ["version",]
dependencies = [
- 'html5lib>=1.0.1',
+ 'nh3',
'regex>1.0; implementation_name != "pypy"',
]
requires-python = '>=3.8'
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 8a5e4f8e..a4ec90b7 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -117,7 +117,7 @@ def test_sanitize():
assert result == expect
test = """a paragraph of evil text
"""
- result = 'a paragraph of evil text
'
+ result = 'a paragraph of evil text
'
expect = textile.Textile().parse(test, sanitize=True)
assert result == expect
diff --git a/textile/core.py b/textile/core.py
index ea94ac18..e9d2955b 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -20,8 +20,9 @@
import uuid
from urllib.parse import urlparse, urlsplit, urlunsplit, quote, unquote
from collections import OrderedDict
+from nh3 import clean
-from textile.tools import sanitizer, imagesize
+from textile.tools import imagesize
from textile.regex_strings import (align_re_s, cls_re_s, pnct_re_s,
regex_snippets, syms_re_s, table_span_re_s)
from textile.utils import (decode_high, encode_high, encode_html, generate_tag,
@@ -236,12 +237,12 @@ def parse(self, text, rel=None, sanitize=False):
if self.block_tags:
if self.lite:
- self.blocktag_whitelist = ['bq', 'p']
+ self.blocktag_allowlist = set(['bq', 'p', 'br'])
text = self.block(text)
else:
- self.blocktag_whitelist = ['bq', 'p', 'bc', 'notextile',
+ self.blocktag_allowlist = set(['bq', 'p', 'br', 'bc', 'notextile',
'pre', 'h[1-6]', 'fn{0}+'.format(
- regex_snippets['digit']), '###']
+ regex_snippets['digit']), '###'])
text = self.block(text)
text = self.placeNoteLists(text)
else:
@@ -263,7 +264,7 @@ def parse(self, text, rel=None, sanitize=False):
text = text.replace('{0}:glyph:'.format(self.uid), '')
if sanitize:
- text = sanitizer.sanitize(text)
+ text = clean(text, tags=self.blocktag_allowlist)
text = self.retrieveTags(text)
text = self.retrieveURLs(text)
diff --git a/textile/tools/sanitizer.py b/textile/tools/sanitizer.py
deleted file mode 100644
index 3c7209c6..00000000
--- a/textile/tools/sanitizer.py
+++ /dev/null
@@ -1,11 +0,0 @@
-def sanitize(string):
- """
- Ensure that the text does not contain any malicious HTML code which might
- break the page.
- """
- from html5lib import parseFragment, serialize
-
- parsed = parseFragment(string)
- clean = serialize(parsed, sanitize=True, omit_optional_tags=False,
- quote_attr_values='always')
- return clean
From f6fbd530384d131be15eee73c88b4fa60c4de112 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 11:33:00 -0400
Subject: [PATCH 217/257] replace str.format with f-string
---
textile/core.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index e9d2955b..1b8cd662 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -241,8 +241,8 @@ def parse(self, text, rel=None, sanitize=False):
text = self.block(text)
else:
self.blocktag_allowlist = set(['bq', 'p', 'br', 'bc', 'notextile',
- 'pre', 'h[1-6]', 'fn{0}+'.format(
- regex_snippets['digit']), '###'])
+ 'pre', 'h[1-6]',
+ f'fn{regex_snippets['digit']}+', '###'])
text = self.block(text)
text = self.placeNoteLists(text)
else:
From 01b3e73a2fc97eecf774adeda3a9004b706fe181 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 11:34:37 -0400
Subject: [PATCH 218/257] fix formatting
---
textile/core.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/core.py b/textile/core.py
index 1b8cd662..711d08c5 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -242,7 +242,7 @@ def parse(self, text, rel=None, sanitize=False):
else:
self.blocktag_allowlist = set(['bq', 'p', 'br', 'bc', 'notextile',
'pre', 'h[1-6]',
- f'fn{regex_snippets['digit']}+', '###'])
+ f"fn{regex_snippets['digit']}+", '###'])
text = self.block(text)
text = self.placeNoteLists(text)
else:
From a716dfaece13f5f77c57d02afd79fe973a2744e2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 12:21:01 -0400
Subject: [PATCH 219/257] add nh3 to build requirements
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index 5ef4a96a..08ded127 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
[build-system]
-requires = ["setuptools", "setuptools-scm"]
+requires = ["setuptools", "setuptools-scm", "nh3"]
build-backend = "setuptools.build_meta"
[project]
From a47bd97e7244c4881fe25f50e414616a9a7ac4a3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 12:39:29 -0400
Subject: [PATCH 220/257] update README to reflect change of dependencies
---
README.textile | 2 +-
tests/fixtures/README.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.textile b/README.textile
index 1bb9087e..49df25e5 100644
--- a/README.textile
+++ b/README.textile
@@ -9,7 +9,7 @@ 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:
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index 01d0209d..bb0ad30b 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -10,7 +10,7 @@
Dependencies:
- - html5lib
+ - nh3
- 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.)
From 9f2b9352de20db5e7ab73f474829a989cffb2b15 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 14:30:44 -0400
Subject: [PATCH 221/257] remove `from __future__ import unicode_literals`
This is effectively a no-op in all supported python versions
---
tests/test_block.py | 2 --
tests/test_github_issues.py | 2 --
tests/test_textile.py | 1 -
tests/test_utils.py | 2 --
tests/test_values.py | 1 -
textile/__init__.py | 2 --
textile/core.py | 2 --
textile/objects/block.py | 2 --
textile/objects/table.py | 2 --
textile/regex_strings.py | 2 --
textile/textilefactory.py | 1 -
textile/utils.py | 2 --
12 files changed, 21 deletions(-)
diff --git a/tests/test_block.py b/tests/test_block.py
index 691d21a7..eed5441c 100644
--- a/tests/test_block.py
+++ b/tests/test_block.py
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
import textile
from textile.objects import Block
diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py
index c08d067f..6808054a 100644
--- a/tests/test_github_issues.py
+++ b/tests/test_github_issues.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
import textile
diff --git a/tests/test_textile.py b/tests/test_textile.py
index a4ec90b7..84e9ddf8 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
import pytest
import re
import textile
diff --git a/tests/test_utils.py b/tests/test_utils.py
index b2e455b4..952c7b4c 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from textile import utils
diff --git a/tests/test_values.py b/tests/test_values.py
index 957a42e9..7c19e116 100644
--- a/tests/test_values.py
+++ b/tests/test_values.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
import textile
import pytest
diff --git a/textile/__init__.py b/textile/__init__.py
index 08a242f7..16418739 100644
--- a/textile/__init__.py
+++ b/textile/__init__.py
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
from .core import textile, textile_restricted, Textile # noqa: F401
from .version import VERSION
diff --git a/textile/core.py b/textile/core.py
index 711d08c5..6d2c1e79 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
__copyright__ = """
Copyright (c) 2009, Jason Samsa, http://jsamsa.com/
Copyright (c) 2010, Kurt Raschke
diff --git a/textile/objects/block.py b/textile/objects/block.py
index 8f44ad1d..6d611ed1 100644
--- a/textile/objects/block.py
+++ b/textile/objects/block.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from collections import OrderedDict
try:
import regex as re
diff --git a/textile/objects/table.py b/textile/objects/table.py
index a257bd0c..72781ad1 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from xml.etree import ElementTree
from textile.regex_strings import (align_re_s, cls_re_s, regex_snippets,
diff --git a/textile/regex_strings.py b/textile/regex_strings.py
index 2e096fb2..c3691bb5 100644
--- a/textile/regex_strings.py
+++ b/textile/regex_strings.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
try:
# Use regex module for matching uppercase characters if installed,
# otherwise fall back to finding all the uppercase chars in a loop.
diff --git a/textile/textilefactory.py b/textile/textilefactory.py
index e5e2458e..3892988f 100644
--- a/textile/textilefactory.py
+++ b/textile/textilefactory.py
@@ -1,4 +1,3 @@
-from __future__ import unicode_literals
from .core import Textile
diff --git a/textile/utils.py b/textile/utils.py
index 7045bcba..b4516ea9 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
try:
import regex as re
except ImportError:
From 6544c68dcf96b93d353f906e60cdd8e76aa2ff13 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 14:35:17 -0400
Subject: [PATCH 222/257] remove unused variable
---
textile/core.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 6d2c1e79..8efdbeaf 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -149,8 +149,6 @@ class Textile(object):
note_index = 1
- doctype_whitelist = ['xhtml', 'html5']
-
glyph_definitions = {
'quote_single_open': '‘', # noqa: E241
'quote_single_close': '’', # noqa: E241
From 8b262811853a6ce2c71d05fcc40dd3a9a3d0eab5 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 14:58:22 -0400
Subject: [PATCH 223/257] move getimagesize into utils
And now the tools directory is no longer needed.
---
tests/test_getimagesize.py | 2 +-
tests/test_imagesize.py | 2 +-
textile/core.py | 9 ++++-----
textile/textilefactory.py | 5 +----
textile/tools/__init__.py | 0
textile/tools/imagesize.py | 27 ---------------------------
textile/utils.py | 29 +++++++++++++++++++++++++++++
7 files changed, 36 insertions(+), 38 deletions(-)
delete mode 100644 textile/tools/__init__.py
delete mode 100644 textile/tools/imagesize.py
diff --git a/tests/test_getimagesize.py b/tests/test_getimagesize.py
index 3a3c0a9c..4cafc9dc 100644
--- a/tests/test_getimagesize.py
+++ b/tests/test_getimagesize.py
@@ -1,4 +1,4 @@
-from textile.tools.imagesize import getimagesize
+from textile.utils import getimagesize
import pytest
PIL = pytest.importorskip('PIL')
diff --git a/tests/test_imagesize.py b/tests/test_imagesize.py
index e7d9d88b..cb3ad68a 100644
--- a/tests/test_imagesize.py
+++ b/tests/test_imagesize.py
@@ -3,7 +3,7 @@
def test_imagesize():
imgurl = 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png'
- result = textile.tools.imagesize.getimagesize(imgurl)
+ result = textile.utils.getimagesize(imgurl)
try:
import PIL # noqa: F401
diff --git a/textile/core.py b/textile/core.py
index 8efdbeaf..4a2594f8 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -20,13 +20,12 @@
from collections import OrderedDict
from nh3 import clean
-from textile.tools import imagesize
from textile.regex_strings import (align_re_s, cls_re_s, pnct_re_s,
regex_snippets, syms_re_s, table_span_re_s)
from textile.utils import (decode_high, encode_high, encode_html, generate_tag,
- has_raw_text, human_readable_url, is_rel_url,
- is_valid_url, list_type, normalize_newlines,
- parse_attributes, pba)
+ getimagesize, has_raw_text, human_readable_url,
+ is_rel_url, is_valid_url, list_type,
+ normalize_newlines, parse_attributes, pba)
from textile.objects import Block, Table
try:
@@ -1152,7 +1151,7 @@ def fImage(self, match):
title = ''
if not is_rel_url(url) and self.get_sizes:
- size = imagesize.getimagesize(url)
+ size = getimagesize(url)
if href:
href = self.shelveURL(href)
diff --git a/textile/textilefactory.py b/textile/textilefactory.py
index 3892988f..402bf868 100644
--- a/textile/textilefactory.py
+++ b/textile/textilefactory.py
@@ -20,10 +20,7 @@ def __init__(self, restricted=False, lite=False, sanitize=False,
self.method_parms['rel'] = 'nofollow'
if noimage is None:
- if restricted:
- noimage = True
- else:
- noimage = False
+ noimage = bool(restricted)
self.class_parms['noimage'] = noimage
self.method_parms['sanitize'] = sanitize
diff --git a/textile/tools/__init__.py b/textile/tools/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/textile/tools/imagesize.py b/textile/tools/imagesize.py
deleted file mode 100644
index 6fba73eb..00000000
--- a/textile/tools/imagesize.py
+++ /dev/null
@@ -1,27 +0,0 @@
-def getimagesize(url):
- """
- Attempts to determine an image's width and height, and returns a tuple,
- (width, height), in pixels or an empty string in case of failure.
- Requires that PIL is installed.
-
- """
-
- try:
- from PIL import ImageFile
- except ImportError:
- return ''
-
- from urllib.request import urlopen
-
- try:
- p = ImageFile.Parser()
- f = urlopen(url)
- while True:
- s = f.read(1024)
- if not s:
- break
- p.feed(s)
- if p.image:
- return p.image.size
- except (IOError, ValueError):
- return ''
diff --git a/textile/utils.py b/textile/utils.py
index b4516ea9..578af4ed 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -79,6 +79,35 @@ def generate_tag(tag, content, attributes=None):
return element_text
+def getimagesize(url):
+ """
+ Attempts to determine an image's width and height, and returns a tuple,
+ (width, height), in pixels or an empty string in case of failure.
+ Requires that PIL is installed.
+
+ """
+
+ try:
+ from PIL import ImageFile
+ except ImportError:
+ return ''
+
+ from urllib.request import urlopen
+
+ try:
+ p = ImageFile.Parser()
+ f = urlopen(url)
+ while True:
+ s = f.read(1024)
+ if not s:
+ break
+ p.feed(s)
+ if p.image:
+ return p.image.size
+ except (IOError, ValueError):
+ return ''
+
+
def has_raw_text(text):
"""checks whether the text has text not already enclosed by a block tag"""
r = text.strip()
From 05ec535ea96c4a5ac4fa41ea59b49933e5d6718b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 9 Aug 2024 15:31:49 -0400
Subject: [PATCH 224/257] update CHANGELOG
---
CHANGELOG.textile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index e13f6f5e..a3ff7424 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -2,6 +2,8 @@ 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:
From 8498638d1d550131d4676f602443f5d128b40f92 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sat, 17 Aug 2024 15:56:40 -0400
Subject: [PATCH 225/257] typo fix to allow pytextile cli tool installation
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index 08ded127..15f27c2d 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -41,7 +41,7 @@ Homepage = "https://github.com/textile/python-textile"
Repository = "https://github.com/textile/python-textile.git"
Issues = "https://github.com/textile/python-textile/issues"
-[python.scripts]
+[project.scripts]
pytextile = "textile.__main__:main"
[tool.setuptools.dynamic]
From e1de4a6e75c4533ac8786ba0620c7fd0b7b4851e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 18 Aug 2024 15:00:31 -0400
Subject: [PATCH 226/257] set project keywords to current values on pypi
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index 15f27c2d..5e7c2db0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -30,7 +30,7 @@ dependencies = [
'regex>1.0; implementation_name != "pypy"',
]
requires-python = '>=3.8'
-keywords = ['textile', 'text', 'html', 'markup']
+keywords = ['textile', 'text', 'html markup']
[project.optional-dependencies]
develop = ['pytest', 'pytest-cov']
From a3709a07bfeec29958d8059ea2d882157436bf00 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 18 Aug 2024 15:04:53 -0400
Subject: [PATCH 227/257] attempt adding rendered README to pypi project page
---
pyproject.toml | 1 +
1 file changed, 1 insertion(+)
diff --git a/pyproject.toml b/pyproject.toml
index 5e7c2db0..a2774e7a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,6 +31,7 @@ dependencies = [
]
requires-python = '>=3.8'
keywords = ['textile', 'text', 'html markup']
+readme = {file = 'tests/fixtures/README.txt', content-type = 'text/plain'}
[project.optional-dependencies]
develop = ['pytest', 'pytest-cov']
From 51fa5c9e29a96bb2ce851d4358f204479471b61a Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 18 Aug 2024 18:52:15 -0400
Subject: [PATCH 228/257] fix formatting in README
---
README.textile | 4 ++--
tests/fixtures/README.txt | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.textile b/README.textile
index 49df25e5..958ea63c 100644
--- a/README.textile
+++ b/README.textile
@@ -50,8 +50,8 @@ 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
diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt
index bb0ad30b..515cf860 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -56,8 +56,8 @@
When textile is installed locally:
-pytest
+pytest
-When textile is not installed locally:
+ When textile is not installed locally:
PYTHONPATH=. pytest
\ No newline at end of file
From 8aa13cb6389d7f2e3806c6cf97b11fad68357359 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 18 Aug 2024 18:52:50 -0400
Subject: [PATCH 229/257] upload a pandoc-converted version of the README to
pypi
---
pyproject.toml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index a2774e7a..50e2a57e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,7 +31,10 @@ dependencies = [
]
requires-python = '>=3.8'
keywords = ['textile', 'text', 'html markup']
-readme = {file = 'tests/fixtures/README.txt', content-type = 'text/plain'}
+# use pandoc to generate a markdown version of the README before uploading:
+# pandoc README.textile -o README.md
+# this kinda hurts to have to do this.
+readme = {file = 'README.md', content-type = 'text/markdown'}
[project.optional-dependencies]
develop = ['pytest', 'pytest-cov']
From 2f6f4de49d017a8aebef23a42768d3d1e487c894 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 18 Aug 2024 19:11:41 -0400
Subject: [PATCH 230/257] ignore converted README.md
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 2ea03521..9cc80d79 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ develop-eggs
.DS_Store
*.swp
.tox
+README.md
From 37225e1091197d37b373390b933548979cfd3502 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 19 Aug 2024 14:57:41 -0400
Subject: [PATCH 231/257] a better way to upload the README to pypi
---
pyproject.toml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 50e2a57e..caa03da1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,10 +31,10 @@ dependencies = [
]
requires-python = '>=3.8'
keywords = ['textile', 'text', 'html markup']
-# use pandoc to generate a markdown version of the README before uploading:
-# pandoc README.textile -o README.md
-# this kinda hurts to have to do this.
-readme = {file = 'README.md', content-type = 'text/markdown'}
+# 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']
From 53fb39ee2a08af904be1e069e04574e11b8016c0 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 19 Aug 2024 14:58:36 -0400
Subject: [PATCH 232/257] create a Makefile to ease building a release
---
Makefile | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 Makefile
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..fff95653
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+clean:
+ rm README.txt
+ rm -rf ./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/*"
From 0abea01888582c899202da6e5deceee50c60c797 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 19 Aug 2024 16:29:43 -0400
Subject: [PATCH 233/257] update which pypi README file to ignore
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 9cc80d79..7f97eb68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,4 @@ develop-eggs
.DS_Store
*.swp
.tox
-README.md
+README.txt
From f24f52fdd4410a382a96276a11f5b4e235d3438b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 19 Aug 2024 18:07:36 -0400
Subject: [PATCH 234/257] better name for the github action
we're not building, we're linting and testing
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 14ced37f..d6e13da3 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -4,7 +4,7 @@ name: python-textile
on: [push]
jobs:
- build:
+ lint_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
From e596255998c0a46bae29ad48733ccf8f735adc7d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Thu, 19 Sep 2024 16:58:53 -0400
Subject: [PATCH 235/257] add an __init__.py to the tests directory
Without this, when running tests locally, I get a warning from coverage
about `no data collected.`
It's not happening with the automated tests in github actions, and
googling the error seems to indicate that some people need this while
others don't. Not sure what's up, but at least, it shouldn't hurt
anything
---
tests/__init__.py | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/__init__.py
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
From a5cef1b554aea531f96e8bada992878b39d3ac11 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sat, 21 Sep 2024 15:30:28 -0400
Subject: [PATCH 236/257] bumping the version number for test.pypi upload
testing
---
textile/version.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/version.py b/textile/version.py
index f3c42a78..0374ae83 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '4.0.2'
+VERSION = '4.0.3rc1'
From e876ddd5a470b6899dd955e1ff505fac8ca7c917 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sat, 21 Sep 2024 16:06:00 -0400
Subject: [PATCH 237/257] a better way to handle the `make clean` task
Previously, make clean would fail if README.txt did not exist. This is
the recommended way to get around this and it just continues on silently
if there's nothing to be done
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index fff95653..7570eac3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
clean:
- rm README.txt
- rm -rf ./dist ./build
+ $(RM) README.txt
+ $(RM) -r ./dist ./build
generate_pypi_README:
${VIRTUAL_ENV}/bin/pytextile README.textile | sed -e 's/^\t//' > README.txt
From 64ab026e8a5f9cfd06186fe8a19bb64cd0218a1f Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sat, 21 Sep 2024 16:09:01 -0400
Subject: [PATCH 238/257] prepare the final version number for release
---
textile/version.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/version.py b/textile/version.py
index 0374ae83..ad53acbb 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '4.0.3rc1'
+VERSION = '4.0.3'
From 8c881404f514560b9402be06c8dec8569f6fff01 Mon Sep 17 00:00:00 2001
From: Samuel Lim
Date: Fri, 13 Feb 2026 14:31:22 +0100
Subject: [PATCH 239/257] Allow text blocks with spaces around first and last
newlines
---
CHANGELOG.textile | 6 ++++++
tests/test_textile.py | 6 ++++++
textile/core.py | 3 +--
textile/utils.py | 4 +++-
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index a3ff7424..61550605 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,5 +1,11 @@
+
h1. Textile Changelog
+h2. Version 4.0.4
+
+* Bugfixes:
+** Allow text blocks with spaces around first and last newlines
+
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
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 84e9ddf8..1916ec4f 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -242,3 +242,9 @@ def test_relURL():
t = textile.Textile()
t.restricted = True
assert t.relURL("gopher://gopher.com/") == '#'
+
+
+def test_whitespace_at_beginning_and_end():
+ expect = textile.textile(' \n Testing 1 2 3 \n ', html_type='html5')
+ result = '\tTesting 1 2 3
'
+ assert result == expect
diff --git a/textile/core.py b/textile/core.py
index 4a2594f8..fe9e2ea9 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -442,9 +442,8 @@ def block(self, text):
tag = 'p'
atts = cite = ext = ''
-
out = []
-
+ block = None
for line in text:
# the line is just whitespace, add it to the output, and move on
if not line.strip():
diff --git a/textile/utils.py b/textile/utils.py
index 578af4ed..2f2afd84 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -149,7 +149,9 @@ def list_type(list_string):
def normalize_newlines(string):
out = re.sub(r'\r\n?', '\n', string)
- out = re.compile(r'^[ \t]*\n', flags=re.M).sub('\n', out)
+ # strip spaces around first and last newline
+ out = re.compile(r'^[ \t]*\n[ \t]*', flags=re.M).sub('\n', out)
+ out = re.compile(r'[ \t]*\n[ \t]*$', flags=re.M).sub('\n', out)
out = out.strip('\n')
return out
From 550a76523eb3cfa2b53e1da933fc4566105735b2 Mon Sep 17 00:00:00 2001
From: Samuel Lim
Date: Fri, 13 Feb 2026 14:43:55 +0100
Subject: [PATCH 240/257] Updated changelog title
---
CHANGELOG.textile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index 61550605..a6a67da6 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,8 +1,7 @@
h1. Textile Changelog
-h2. Version 4.0.4
-
+h2. Development
* Bugfixes:
** Allow text blocks with spaces around first and last newlines
From b349498d68ebfc6a927f105de303c51af3e5e425 Mon Sep 17 00:00:00 2001
From: Samuel Lim
Date: Mon, 16 Feb 2026 11:14:56 +0100
Subject: [PATCH 241/257] Fix problem other way
---
tests/test_textile.py | 4 ++--
textile/core.py | 3 ++-
textile/utils.py | 4 +---
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 1916ec4f..25015ab1 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -245,6 +245,6 @@ def test_relURL():
def test_whitespace_at_beginning_and_end():
- expect = textile.textile(' \n Testing 1 2 3 \n ', html_type='html5')
- result = '\tTesting 1 2 3
'
+ result = textile.textile(' \n Testing 1 2 3 \n ', html_type='html5')
+ expect = ' Testing 1 2 3 \n '
assert result == expect
diff --git a/textile/core.py b/textile/core.py
index fe9e2ea9..4856e85d 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -443,7 +443,8 @@ def block(self, text):
tag = 'p'
atts = cite = ext = ''
out = []
- block = None
+ block = Block(self, tag, atts, ext, cite, '') # init block
+ block.eat = False # don't eat the next line after init block
for line in text:
# the line is just whitespace, add it to the output, and move on
if not line.strip():
diff --git a/textile/utils.py b/textile/utils.py
index 2f2afd84..578af4ed 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -149,9 +149,7 @@ def list_type(list_string):
def normalize_newlines(string):
out = re.sub(r'\r\n?', '\n', string)
- # strip spaces around first and last newline
- out = re.compile(r'^[ \t]*\n[ \t]*', flags=re.M).sub('\n', out)
- out = re.compile(r'[ \t]*\n[ \t]*$', flags=re.M).sub('\n', out)
+ out = re.compile(r'^[ \t]*\n', flags=re.M).sub('\n', out)
out = out.strip('\n')
return out
From 7ca3ebee4477390e6014f22cafb19a0b20882cf8 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 16 Feb 2026 12:36:27 -0500
Subject: [PATCH 242/257] update the versions of python to test against
notably, pypy3.10 can't run automated tests for nh3 anymore due to
another dependency (PyO3) dropping support for pypy3.10
---
.github/workflows/lint_and_test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index d6e13da3..685038fc 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"]
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.11"]
image_size: ['true', 'false']
steps:
- uses: actions/checkout@v4
From 3f44af0f41074ceaeafe0d41517d149e2c8c1fd9 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 16 Feb 2026 12:44:23 -0500
Subject: [PATCH 243/257] update supported versions
---
pyproject.toml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pyproject.toml b/pyproject.toml
index caa03da1..07531025 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,6 +22,8 @@ classifiers = [
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
+ 'Programming Language :: Python :: 3.13',
+ 'Programming Language :: Python :: 3.14',
'Topic :: Software Development :: Libraries :: Python Modules',
]
dynamic = ["version",]
From 13576f6c45ecc5947331fbb55be52694fa354795 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 16 Feb 2026 12:52:58 -0500
Subject: [PATCH 244/257] update contributors list and changelog
---
CHANGELOG.textile | 3 ++-
CONTRIBUTORS.txt | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index a6a67da6..92bacc17 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -2,8 +2,9 @@
h1. Textile Changelog
h2. Development
+* Update supported python versions to include 3.13, and 3.14. Minimum support for pypy has increased to pypy3.11.
* Bugfixes:
-** Allow text blocks with spaces around first and last newlines
+** Allow text blocks with spaces around first and last newlines ("#87":https://github.com/textile/python-textile/pull/87)
h2. Version 4.0.3
* Update supported Python versions to 3.8 - 3.12 ("#83":https://github.com/textile/python-textile/issues/83)
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 90d949aa..474e638f 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -9,4 +9,5 @@ Kurt Raschke
Dave Brondsema
Dmitry Shachnev
Kirill Mavreshko
-Brad Schoening
\ No newline at end of file
+Brad Schoening
+Samuel Lim
\ No newline at end of file
From 1a072441305bc9fb5819095970bfaff9a23c727d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 10 May 2026 16:40:07 -0400
Subject: [PATCH 245/257] bump version and update CHANGELOG
---
CHANGELOG.textile | 2 +-
textile/version.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index 92bacc17..6ca40c6a 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,7 +1,7 @@
h1. Textile Changelog
-h2. Development
+h2. Version 4.0.4
* Update supported python versions to include 3.13, and 3.14. Minimum support for pypy has increased to pypy3.11.
* Bugfixes:
** Allow text blocks with spaces around first and last newlines ("#87":https://github.com/textile/python-textile/pull/87)
diff --git a/textile/version.py b/textile/version.py
index ad53acbb..771faf86 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '4.0.3'
+VERSION = '4.0.4'
From d86b7554542ea3f8953bde86a5074119839de7de Mon Sep 17 00:00:00 2001
From: santhreal <64453045+santhreal@users.noreply.github.com>
Date: Fri, 17 Jul 2026 07:44:35 -0700
Subject: [PATCH 246/257] Don't crash on a link URL ending in '>'
A Textile link whose URL ends in '>' with no preceding closing tag
(e.g. "a":b>) raised a raw AttributeError: the '>' handler searched
for a trailing ' like other
trailing punctuation and push it out of the URL.
---
tests/test_urls.py | 13 +++++++++++++
textile/core.py | 3 +++
2 files changed, 16 insertions(+)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 1cd09f92..7b567911 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -69,3 +69,16 @@ def test_quotes_in_link_text():
result = t.parse(test)
expect = '\t“this is a quote in link text”
'
assert result == expect
+
+
+def test_link_url_ending_in_angle_bracket():
+ """A link whose URL ends in '>' with no closing tag used to raise a raw
+ AttributeError; the '>' should be pushed out of the URL like other
+ trailing punctuation."""
+ t = Textile()
+ assert t.parse('"a":b>') == '\ta>
'
+ assert t.parse('"x":http://x.com/>') == (
+ '\tx>
')
+ # A genuine trailing closing tag is still absorbed as before.
+ assert t.parse('"y":http://x.com/y')
diff --git a/textile/core.py b/textile/core.py
index 4856e85d..dad9bf15 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -888,6 +888,9 @@ def _rightanglebracket(c, pop, popped, url_chars, counts, pre):
urlLeft = ''.join(url_chars)
m = re.search(r'(?P.*)(?P<\/[a-z]+)$', urlLeft)
+ if m is None:
+ # Lone trailing '>' (no closing tag): pop it out the back.
+ return '{0}{1}'.format(c, pop), True, url_chars, counts, pre
url_chars = m.group('url_chars')
pop = '{0}{1}{2}'.format(m.group('tag'), c, pop)
popped = True
From 3fbdbf49cc4acab65de1fd433ca4d7274ff279d9 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sat, 18 Jul 2026 16:50:56 -0400
Subject: [PATCH 247/257] Align trailing angle bracket URL fix with upstream
php-textile reference behavior
---
tests/test_urls.py | 10 ++++++----
textile/core.py | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 7b567911..0972eaea 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -73,12 +73,14 @@ def test_quotes_in_link_text():
def test_link_url_ending_in_angle_bracket():
"""A link whose URL ends in '>' with no closing tag used to raise a raw
- AttributeError; the '>' should be pushed out of the URL like other
- trailing punctuation."""
+ AttributeError; the '>' should be dropped completely from the URL and
+ the output to align with reference php-textile."""
t = Textile()
- assert t.parse('"a":b>') == '\ta>
'
+ assert t.parse('"a":b>') == '\t'
assert t.parse('"x":http://x.com/>') == (
- '\tx>
')
+ '\t')
# A genuine trailing closing tag is still absorbed as before.
assert t.parse('"y":http://x.com/y')
+ assert t.parse('"y":http://x.com/') == (
+ '\t')
diff --git a/textile/core.py b/textile/core.py
index dad9bf15..ddfd91f0 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -889,8 +889,8 @@ def _rightanglebracket(c, pop, popped, url_chars, counts, pre):
m = re.search(r'(?P.*)(?P<\/[a-z]+)$', urlLeft)
if m is None:
- # Lone trailing '>' (no closing tag): pop it out the back.
- return '{0}{1}'.format(c, pop), True, url_chars, counts, pre
+ popped = True
+ return pop, popped, url_chars, counts, pre
url_chars = m.group('url_chars')
pop = '{0}{1}{2}'.format(m.group('tag'), c, pop)
popped = True
From 3a6ac67774160335106395f0b7ec854c2ceffd1c Mon Sep 17 00:00:00 2001
From: santhreal <64453045+santhreal@users.noreply.github.com>
Date: Sat, 18 Jul 2026 17:58:20 -0700
Subject: [PATCH 248/257] Don't crash or truncate Textile links to IPv6
literals
Bracketed IPv6 hosts were mishandled three ways: a balanced ] was
duplicated, trailing path/port after ] was stripped, and encode_url
cut the host at the first colon.
---
tests/test_urls.py | 10 ++++++++++
textile/core.py | 37 +++++++++++++++++++++++++++----------
2 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 1cd09f92..02bab436 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -69,3 +69,13 @@ def test_quotes_in_link_text():
result = t.parse(test)
expect = '\t“this is a quote in link text”
'
assert result == expect
+
+
+def test_ipv6_literal_link_keeps_single_closing_bracket():
+ import textile
+ out = textile.textile('"host":http://[2001:db8::1]/')
+ assert out == '\t'
+ out = textile.textile('"loopback":http://[::1]/')
+ assert out == '\t'
+ out = textile.textile('"port":http://[::1]:8080/')
+ assert out == '\t'
diff --git a/textile/core.py b/textile/core.py
index 4856e85d..1880466a 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -864,7 +864,12 @@ def fLink(self, m):
if (counts[']']):
m = re.search(r'(?P^.*\])(?!=)(?P.*?)$', url, flags=re.U)
url = m.group('url')
- tight = '{0}{1}'.format(m.group('end'), tight)
+ end = m.group('end')
+ # Keep port/path/query/fragment after a bracketed IPv6 (or similar) ].
+ if end.startswith((':', '/', '?', '#')):
+ url = '{0}{1}'.format(url, end)
+ end = ''
+ tight = '{0}{1}'.format(end, tight)
# Now we have the array of all the multi-byte chars in the url we will
# parse the uri backwards and pop off any chars that don't belong
@@ -901,8 +906,8 @@ def _closingsquarebracket(c, pop, popped, url_chars, counts, pre):
counts['['] = counts['['] or url.count('[')
if counts['['] == counts[']']:
- # It is balanced, so keep it
- url_chars.append(c)
+ # Balanced (e.g. IPv6 netloc); char already in url_chars.
+ pass
else:
# In the case of un-matched closing square brackets we just eat
# it
@@ -1001,13 +1006,25 @@ def encode_url(self, url):
parsed = urlsplit(url)
if parsed.netloc:
- # divide the netloc further
- netloc_pattern = re.compile(r"""
- (?:(?P[^:@]+)(?::(?P[^:@]+))?@)?
- (?P[^:]+)
- (?::(?P[0-9]+))?
- """, re.X | re.U)
- netloc_parsed = netloc_pattern.match(parsed.netloc).groupdict()
+ # Bracketed IPv6 netlocs contain colons; keep [addr] intact.
+ ipv6 = re.match(
+ r'^(?P\[[^\]]+\])(?::(?P[0-9]+))?$',
+ parsed.netloc,
+ )
+ if ipv6:
+ netloc_parsed = {
+ 'user': '',
+ 'password': '',
+ 'host': ipv6.group('host'),
+ 'port': ipv6.group('port') or '',
+ }
+ else:
+ netloc_pattern = re.compile(r"""
+ (?:(?P[^:@]+)(?::(?P[^:@]+))?@)?
+ (?P[^:]+)
+ (?::(?P[0-9]+))?
+ """, re.X | re.U)
+ netloc_parsed = netloc_pattern.match(parsed.netloc).groupdict()
else:
netloc_parsed = {'user': '', 'password': '', 'host': '', 'port': ''}
From 181fc0773f78ab3dc7f2a05e8f529d93da1a01de Mon Sep 17 00:00:00 2001
From: santhreal <64453045+santhreal@users.noreply.github.com>
Date: Sat, 18 Jul 2026 18:00:17 -0700
Subject: [PATCH 249/257] Prefer unmatched-only bracket pop in fLink
Invert the balanced-] branch and match existing test style.
---
tests/test_urls.py | 14 +++++++-------
textile/core.py | 8 ++------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 02bab436..4ef1a06c 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -72,10 +72,10 @@ def test_quotes_in_link_text():
def test_ipv6_literal_link_keeps_single_closing_bracket():
- import textile
- out = textile.textile('"host":http://[2001:db8::1]/')
- assert out == '\t'
- out = textile.textile('"loopback":http://[::1]/')
- assert out == '\t'
- out = textile.textile('"port":http://[::1]:8080/')
- assert out == '\t'
+ t = Textile()
+ assert t.parse('"host":http://[2001:db8::1]/') == (
+ '\t')
+ assert t.parse('"loopback":http://[::1]/') == (
+ '\t')
+ assert t.parse('"port":http://[::1]:8080/') == (
+ '\t')
diff --git a/textile/core.py b/textile/core.py
index 1880466a..92a0394f 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -905,12 +905,8 @@ def _closingsquarebracket(c, pop, popped, url_chars, counts, pre):
# If counts['['] is None, count the occurrences of '['
counts['['] = counts['['] or url.count('[')
- if counts['['] == counts[']']:
- # Balanced (e.g. IPv6 netloc); char already in url_chars.
- pass
- else:
- # In the case of un-matched closing square brackets we just eat
- # it
+ if counts['['] != counts[']']:
+ # Unmatched closing bracket: spit it out of the URL.
popped = True
url_chars.pop()
counts[']'] = counts[']'] - 1
From 2e707277ff3d590709ebdcd2642037969fb41707 Mon Sep 17 00:00:00 2001
From: santhreal <64453045+santhreal@users.noreply.github.com>
Date: Sat, 18 Jul 2026 18:05:24 -0700
Subject: [PATCH 250/257] Only reattach after ] when brackets are balanced
Unmatched ]? / ]/ prose pops stay on the master path.
---
tests/test_urls.py | 7 +++++++
textile/core.py | 5 +++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 4ef1a06c..8de73751 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -79,3 +79,10 @@ def test_ipv6_literal_link_keeps_single_closing_bracket():
'\t')
assert t.parse('"port":http://[::1]:8080/') == (
'\t')
+
+
+def test_unmatched_bracket_before_query_still_pops():
+ t = Textile()
+ # Master pops trailing after an unmatched ]; IPv6 reattach must not change that.
+ assert t.parse('"t":http://example.com/x]?q=1') == (
+ '\tt?q=1
')
diff --git a/textile/core.py b/textile/core.py
index 92a0394f..4b309579 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -865,8 +865,9 @@ def fLink(self, m):
m = re.search(r'(?P^.*\])(?!=)(?P.*?)$', url, flags=re.U)
url = m.group('url')
end = m.group('end')
- # Keep port/path/query/fragment after a bracketed IPv6 (or similar) ].
- if end.startswith((':', '/', '?', '#')):
+ # Reattach URL continuation only when ] is balanced (IPv6 netloc).
+ if (end.startswith((':', '/', '?', '#'))
+ and url.count('[') == url.count(']')):
url = '{0}{1}'.format(url, end)
end = ''
tight = '{0}{1}'.format(end, tight)
From 752f1c8802e8c41f7bc1d376a402c106c726ace7 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 20 Jul 2026 19:31:05 -0400
Subject: [PATCH 251/257] fix: resolve flake8 W503/W504 line break warnings in
core.py
---
textile/core.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 288cc89b..e6d4597b 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -866,8 +866,7 @@ def fLink(self, m):
url = m.group('url')
end = m.group('end')
# Reattach URL continuation only when ] is balanced (IPv6 netloc).
- if (end.startswith((':', '/', '?', '#'))
- and url.count('[') == url.count(']')):
+ if end.startswith((':', '/', '?', '#')) and url.count('[') == url.count(']'):
url = '{0}{1}'.format(url, end)
end = ''
tight = '{0}{1}'.format(end, tight)
From b24905d5f70e6f4b561318decdaa66d72913bb8a Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 20 Jul 2026 19:37:50 -0400
Subject: [PATCH 252/257] ci: enable automated testing for pull requests
targeting master and develop
---
.github/workflows/lint_and_test.yml | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index 685038fc..cf8f7818 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -1,7 +1,15 @@
---
name: python-textile
-on: [push]
+on:
+ push:
+ branches:
+ - master
+ - develop
+ pull_request:
+ branches:
+ - master
+ - develop
jobs:
lint_and_test:
From edbcd90032edd481f66dea34773636c34fd16e9b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 22 Jul 2026 17:27:47 -0400
Subject: [PATCH 253/257] fix: align bracket popping and trailing angle bracket
behavior with upstream php-textile
---
tests/test_urls.py | 10 ++++++----
textile/core.py | 12 ++++--------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 322d3096..c910a300 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -74,13 +74,13 @@ def test_quotes_in_link_text():
def test_ipv6_literal_link_keeps_single_closing_bracket():
t = Textile()
assert t.parse('"host":http://[2001:db8::1]/') == (
- '\t')
+ '\thost/
')
assert t.parse('"loopback":http://[::1]/') == (
- '\t')
+ '\t')
assert t.parse('"port":http://[::1]:8080/') == (
- '\t')
+ '\tport:8080/
')
assert t.parse('"creds":http://user:pass@[::1]:8080/') == (
- '\t')
+ '\tcreds:8080/
')
def test_unmatched_bracket_before_query_still_pops():
@@ -88,6 +88,8 @@ def test_unmatched_bracket_before_query_still_pops():
# Master pops trailing after an unmatched ]; IPv6 reattach must not change that.
assert t.parse('"t":http://example.com/x]?q=1') == (
'\tt?q=1
')
+ assert t.parse('"test":http://example.com/x]=foo') == (
+ '\t')
def test_link_url_ending_in_angle_bracket():
diff --git a/textile/core.py b/textile/core.py
index e6d4597b..028b9407 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -863,13 +863,9 @@ def fLink(self, m):
# balance
if (counts[']']):
m = re.search(r'(?P^.*\])(?!=)(?P.*?)$', url, flags=re.U)
- url = m.group('url')
- end = m.group('end')
- # Reattach URL continuation only when ] is balanced (IPv6 netloc).
- if end.startswith((':', '/', '?', '#')) and url.count('[') == url.count(']'):
- url = '{0}{1}'.format(url, end)
- end = ''
- tight = '{0}{1}'.format(end, tight)
+ if m:
+ url = m.group('url')
+ tight = '{0}{1}'.format(m.group('end'), tight)
# Now we have the array of all the multi-byte chars in the url we will
# parse the uri backwards and pop off any chars that don't belong
@@ -894,7 +890,7 @@ def _rightanglebracket(c, pop, popped, url_chars, counts, pre):
m = re.search(r'(?P.*)(?P<\/[a-z]+)$', urlLeft)
if m is None:
- popped = True
+ popped = False
return pop, popped, url_chars, counts, pre
url_chars = m.group('url_chars')
pop = '{0}{1}{2}'.format(m.group('tag'), c, pop)
From af2dcb2e82976c05a3d18ff91224cd8ee5d9bdf2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Tue, 18 Aug 2026 18:29:08 -0400
Subject: [PATCH 254/257] Fix attribute-value breakout XSS vulnerabilities in
restricted mode
- HTML-escape formatted attribute values in pba() to prevent tag/attribute breakout.
- HTML-escape the cite attribute in inline spans (fSpan) to prevent breakout.
- HTML-escape restored URLs in retrieveURL() to ensure safely escaped attributes (e.g. cite in blockquote) aren't bypassed during URL restoration.
- Add unit tests for all three breakout vectors in test_textile.py.
---
tests/test_textile.py | 15 +++++++++++++++
textile/core.py | 4 ++--
textile/utils.py | 2 +-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 25015ab1..842a71d9 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -95,6 +95,21 @@ def test_restricted():
assert result == expect
+ test = '_[x"onmouseover="alert(document.domain)]hover me_'
+ result = textile.textile_restricted(test)
+ expect = '\thover me
'
+ assert result == expect
+
+ test = 'bq.:http://example.com/"onmouseover="alert(document.domain) some quote'
+ result = textile.textile_restricted(test)
+ expect = '\t\n\t\tsome quote
\n\t
'
+ assert result == expect
+
+ test = '??:http://example.com/"onmouseover="alert(document.domain) hover me??'
+ result = textile.textile_restricted(test)
+ expect = '\thover me
'
+ assert result == expect
+
def test_unicode_footnote():
html = textile.textile('текст[1]')
diff --git a/textile/core.py b/textile/core.py
index 028b9407..ee3871b2 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -1107,7 +1107,7 @@ def fSpan(self, match):
tag = qtags[tag]
atts = pba(atts, restricted=self.restricted)
if cite:
- atts = '{0} cite="{1}"'.format(atts, cite.rstrip())
+ atts = '{0} cite="{1}"'.format(atts, encode_html(cite.rstrip(), quotes=True))
content = self.span(content)
opentag = '<{0}{1}>'.format(tag, atts)
@@ -1488,7 +1488,7 @@ def retrieveURL(self, match):
if url in self.urlrefs:
url = self.urlrefs[url]
- return url
+ return encode_html(url, quotes=True)
def _increment_link_index(self):
"""The self.linkIndex property needs to be incremented in various
diff --git a/textile/utils.py b/textile/utils.py
index 578af4ed..18dd681c 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -267,5 +267,5 @@ def pba(block_attributes, element=None, include_id=True, restricted=False):
attrs = parse_attributes(block_attributes, element, include_id, restricted)
if not attrs:
return ''
- result = ' '.join(['{0}="{1}"'.format(k, v) for k, v in attrs.items()])
+ result = ' '.join(['{0}="{1}"'.format(k, encode_html(str(v), quotes=True)) for k, v in attrs.items()])
return ' {0}'.format(result)
From d24b78e68a80a1bb10b26577b2cd74512069dcae Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Fri, 21 Aug 2026 18:11:30 -0400
Subject: [PATCH 255/257] Align language attribute validation and dropping
behavior with php-textile
---
tests/test_textile.py | 2 +-
tests/test_utils.py | 13 +++++++++++++
textile/utils.py | 8 +++++++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 842a71d9..049fb961 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -97,7 +97,7 @@ def test_restricted():
test = '_[x"onmouseover="alert(document.domain)]hover me_'
result = textile.textile_restricted(test)
- expect = '\thover me
'
+ expect = '\thover me
'
assert result == expect
test = 'bq.:http://example.com/"onmouseover="alert(document.domain) some quote'
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 952c7b4c..da87051a 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -35,3 +35,16 @@ def test_generate_tag():
def test_human_readable_url_edge_case():
assert utils.human_readable_url('google.com') == 'google.com'
assert utils.human_readable_url('tel:1-800-555-1212') == '1-800-555-1212'
+
+
+def test_parse_attributes_code():
+ # Test language parsing for code elements
+ assert utils.parse_attributes('[python]', element='code')['lang'] == 'python'
+ assert utils.parse_attributes('[py-3_9]', element='code')['lang'] == 'py-3_9'
+ assert 'lang' not in utils.parse_attributes('[python!]', element='code')
+
+ # Test language parsing for non-code elements
+ assert utils.parse_attributes('[fr]', element='p')['lang'] == 'fr'
+ assert utils.parse_attributes('[en-US]', element='p')['lang'] == 'en-US'
+ assert 'lang' not in utils.parse_attributes('[english]', element='p')
+
diff --git a/textile/utils.py b/textile/utils.py
index 18dd681c..cdd87fd0 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -193,7 +193,13 @@ def parse_attributes(block_attributes, element=None, include_id=True, restricted
m = re.search(r'\[([^\]]+)\]', matched, re.U)
if m:
- lang = m.group(1)
+ val = m.group(1)
+ if element == 'code':
+ if re.match(r'^[a-zA-Z0-9_-]+$', val):
+ lang = val
+ else:
+ if re.match(r'^[a-zA-Z]{2}(?:[\-_][a-zA-Z]{2})?$', val):
+ lang = val
matched = matched.replace(m.group(0), '')
m = re.search(r'\(([^()]+)\)', matched, re.U)
From daf2ae6a2dd7f336bcbe80aa7a38efca4c8cf03b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 11 Nov 2026 15:07:56 -0500
Subject: [PATCH 256/257] bump version to 4.0.5 and update CHANGELOG
---
CHANGELOG.textile | 4 ++++
textile/version.py | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.textile b/CHANGELOG.textile
index 6ca40c6a..c6de4040 100644
--- a/CHANGELOG.textile
+++ b/CHANGELOG.textile
@@ -1,6 +1,10 @@
h1. Textile Changelog
+h2. Version 4.0.5
+* Security Fixes:
+** Fix attribute-value breakout XSS vulnerabilities in restricted mode ("GHSA-892m-5p8f-3g3g":https://github.com/textile/python-textile/security/advisories/GHSA-892m-5p8f-3g3g)
+
h2. Version 4.0.4
* Update supported python versions to include 3.13, and 3.14. Minimum support for pypy has increased to pypy3.11.
* Bugfixes:
diff --git a/textile/version.py b/textile/version.py
index 771faf86..a2ea7167 100644
--- a/textile/version.py
+++ b/textile/version.py
@@ -1 +1 @@
-VERSION = '4.0.4'
+VERSION = '4.0.5'
From e14da682a8e342f045ea0318ca43e965068b7e59 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Wed, 11 Nov 2026 16:22:10 -0500
Subject: [PATCH 257/257] fix: resolve flake8 W391 blank line at end of file in
test_utils.py
---
tests/test_utils.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index da87051a..d9eda59d 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -47,4 +47,3 @@ def test_parse_attributes_code():
assert utils.parse_attributes('[fr]', element='p')['lang'] == 'fr'
assert utils.parse_attributes('[en-US]', element='p')['lang'] == 'en-US'
assert 'lang' not in utils.parse_attributes('[english]', element='p')
-