From 0f400c195666ebeeabcb656c1260e55790bf7856 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 12:52:43 -0500
Subject: [PATCH 01/81] first stab at using github actions instead of travis-ci
---
.github/workflows/lint_and_test.yml | 28 ++++++++++++++++++++++++++++
.travis.yml | 23 -----------------------
2 files changed, 28 insertions(+), 23 deletions(-)
create mode 100644 .github/workflows/lint_and_test.yml
delete mode 100644 .travis.yml
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
new file mode 100644
index 0000000..f806d24
--- /dev/null
+++ b/.github/workflows/lint_and_test.yml
@@ -0,0 +1,28 @@
+---
+name: python-textile
+
+on: [push]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
+ image-size: ['true', 'false']
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ image-size: ${{ matrix.image-size }}
+ - name: Install dependencies
+ run: |
+ imagesize=''
+ pip install -U pytest pytest-cov coverage codecov
+ if [[ ${{ image-size }} == true ]] ; then imagesize='[imagesize]' ; fi
+ pip install -e ".${imagesize}"
+ - name: run tests
+ run: |
+ pytest
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 3f7d77c..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-dist: xenial # required for Python >= 3.7
-language: python
-env:
- - IMAGESIZE=true
- - IMAGESIZE=false
-python:
- - "3.5"
- - "3.6"
- - "3.7"
- - "3.8"
- - "3.9"
- # PyPy versions
- - "pypy3"
-# command to install dependencies
-install:
- - imagesize=''
- - pip install -U pytest pytest-cov coverage codecov
- - if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
- - pip install -e ".${imagesize}"
-# command to run tests
-script: py.test
-after_success:
- - codecov
From 8338fcbef6ae7998cd864459b069714d55b4291b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 12:55:08 -0500
Subject: [PATCH 02/81] maybe this fixes the job ???
---
.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 f806d24..e03c18a 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -21,7 +21,7 @@ jobs:
run: |
imagesize=''
pip install -U pytest pytest-cov coverage codecov
- if [[ ${{ image-size }} == true ]] ; then imagesize='[imagesize]' ; fi
+ if [[ ${{ matrix.image-size }} == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
From c2c42cd9ecd324725f55ceaa568930ce20bf5819 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 13:35:49 -0500
Subject: [PATCH 03/81] add codecov action to send data to codecov
---
.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 e03c18a..0e10375 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -26,3 +26,5 @@ jobs:
- name: run tests
run: |
pytest
+ - name: Codecov
+ uses: codecov/codecov-action@v2.1.0
From 6704c90ccd170c29d2f2a02e759bd14d6b179da4 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 13:36:47 -0500
Subject: [PATCH 04/81] indentation fix
---
.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 0e10375..78bac9c 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -27,4 +27,4 @@ jobs:
run: |
pytest
- name: Codecov
- uses: codecov/codecov-action@v2.1.0
+ uses: codecov/codecov-action@v2.1.0
From 5fc0780425a78b10e827c0bbdf74c752c4c05e74 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 14:03:29 -0500
Subject: [PATCH 05/81] add flake8 linting
---
.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 78bac9c..cec0b42 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -17,6 +17,8 @@ jobs:
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
run: |
imagesize=''
From 8102dad382a507ef8bab365b49cb21a7001cd6db Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 14:11:03 -0500
Subject: [PATCH 06/81] maybe we're not quite ready for linting
---
.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 cec0b42..ef6393c 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -17,8 +17,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
image-size: ${{ matrix.image-size }}
- - name: Python flake8 Lint
- uses: py-actions/flake8@v1.2.0
+ #- name: Python flake8 Lint
+ # uses: py-actions/flake8@v1.2.0
- name: Install dependencies
run: |
imagesize=''
From 0e50d699aa8b7e1733f99a46caab53fb3cccb806 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 14:11:35 -0500
Subject: [PATCH 07/81] testing out variables more like how we used to with
travis
---
.github/workflows/lint_and_test.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml
index ef6393c..16f06b2 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -21,9 +21,10 @@ jobs:
# uses: py-actions/flake8@v1.2.0
- name: Install dependencies
run: |
- imagesize=''
+ imagesize=''
+ IMAGESIZE=${{ matrix.image-size }}
pip install -U pytest pytest-cov coverage codecov
- if [[ ${{ matrix.image-size }} == true ]] ; then imagesize='[imagesize]' ; fi
+ if [[ $IMAGESIZE == true ]] ; then imagesize='[imagesize]' ; fi
pip install -e ".${imagesize}"
- name: run tests
run: |
From 7e84e94f6f07733be13dcebc6db23017f90ed697 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 14:28:00 -0500
Subject: [PATCH 08/81] flake8: cleanup unused imports
---
setup.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/setup.py b/setup.py
index 118c2fb..80488d2 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,5 @@
from setuptools import setup, find_packages
-from setuptools.command.test import test as TestCommand
import os
-import sys
def get_version():
From c796c60a32a2a806629373a863223ce0bd71d160 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 14:30:08 -0500
Subject: [PATCH 09/81] flake8: variable cleanup
---
tests/test_block.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_block.py b/tests/test_block.py
index 44f3ea2..613bf41 100644
--- a/tests/test_block.py
+++ b/tests/test_block.py
@@ -21,7 +21,6 @@ def test_block():
assert result == expect
b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote")
- citation = '{0}1:url'.format(t.uid)
expect = ('blockquote', OrderedDict([('cite',
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
'Hello BlockQuote')
From 95c29703eb92c01e97e50f3282ae41077f8e6a86 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:30:38 -0500
Subject: [PATCH 10/81] add flake8 config file
---
.flake8 | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 .flake8
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..07c24d1
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,9 @@
+[flake8]
+ignore =
+ # line too long
+ E501
+ # temporarily ignore warnings and errors
+ W
+ E
+exclude =
+ build/
From 9ef05332d372e7da3607145a7da6825cd660a3e9 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:31:19 -0500
Subject: [PATCH 11/81] flake8: inline ignore unused variable
---
tests/test_textile.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index 0c37690..cc4ce84 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -121,7 +121,7 @@ def test_sanitize():
assert result == expect
def test_imagesize():
- PIL = pytest.importorskip('PIL')
+ PIL = pytest.importorskip('PIL') # noqa: F841
test = "!http://www.google.com/intl/en_ALL/images/srpr/logo1w.png!"
result = '\t'
From 3159a32f5bc633a6d42ad81eb359fa4bae2b0450 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:35:19 -0500
Subject: [PATCH 12/81] flake8: remove unused import
---
tests/test_urls.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 7a9798e..39ff163 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from textile import Textile
-import re
def test_urls():
t = Textile()
From 3aa0de7d8e4c2ca35161b78362813f992b0c4513 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:41:44 -0500
Subject: [PATCH 13/81] flake8: remove unused import
---
tests/test_attributes.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_attributes.py b/tests/test_attributes.py
index 70da842..0f5d019 100644
--- a/tests/test_attributes.py
+++ b/tests/test_attributes.py
@@ -1,5 +1,4 @@
from textile.utils import parse_attributes
-import re
def test_parse_attributes():
assert parse_attributes('\\1', element='td') == {'colspan': '1'}
From 2283c8f34e3d54fffbeab884e4f168a58de4fbc3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:44:42 -0500
Subject: [PATCH 14/81] flake8: inline ignore unused import
---
tests/test_imagesize.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test_imagesize.py b/tests/test_imagesize.py
index 112989e..0a89b43 100644
--- a/tests/test_imagesize.py
+++ b/tests/test_imagesize.py
@@ -4,7 +4,7 @@ def test_imagesize():
imgurl = 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png'
result = textile.tools.imagesize.getimagesize(imgurl)
try:
- import PIL
+ import PIL # noqa: F401
expect = (275, 95)
assert result == expect
From 4804417121de191571429f5ca380e924617c6766 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:45:45 -0500
Subject: [PATCH 15/81] flake8: remove unused import
---
tests/test_footnoteRef.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test_footnoteRef.py b/tests/test_footnoteRef.py
index b773ad2..c973ee7 100644
--- a/tests/test_footnoteRef.py
+++ b/tests/test_footnoteRef.py
@@ -1,5 +1,4 @@
from textile import Textile
-import re
def test_footnoteRef():
t = Textile()
From 8e1a9ea088dcb1ceb608630dd65f72fef968fd55 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 15:49:47 -0500
Subject: [PATCH 16/81] flake8: inline ignore unused import
---
textile/regex_strings.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/regex_strings.py b/textile/regex_strings.py
index 470203c..b20fc82 100644
--- a/textile/regex_strings.py
+++ b/textile/regex_strings.py
@@ -4,7 +4,7 @@
try:
# Use regex module for matching uppercase characters if installed,
# otherwise fall back to finding all the uppercase chars in a loop.
- import regex as re
+ import regex as re # noqa: F401
upper_re_s = r'\p{Lu}'
regex_snippets = {
'acr': r'\p{Lu}\p{Nd}',
From 7c0394a269bee84ef13a62bf5eff4121da530c54 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:03:16 -0500
Subject: [PATCH 17/81] flake8: remove unused imports
---
textile/__init__.py | 3 ---
1 file changed, 3 deletions(-)
diff --git a/textile/__init__.py b/textile/__init__.py
index bb7829f..e7ea665 100644
--- a/textile/__init__.py
+++ b/textile/__init__.py
@@ -1,8 +1,5 @@
from __future__ import unicode_literals
-import sys
-import warnings
-
from .core import textile, textile_restricted, Textile
from .version import VERSION
From c1b08ac96436c5adde1b8b02ddd84470c22d0903 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:03:34 -0500
Subject: [PATCH 18/81] flake8: inline ignore unused import. It's actually used
farther down the line in the module.
---
textile/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/__init__.py b/textile/__init__.py
index e7ea665..9ca8a65 100644
--- a/textile/__init__.py
+++ b/textile/__init__.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from .core import textile, textile_restricted, Textile
+from .core import textile, textile_restricted, Textile # noqa: F401
from .version import VERSION
__all__ = ['textile', 'textile_restricted']
From cfcaa4fbcfb4ccc15ef23b017f00640a3049634b Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:08:51 -0500
Subject: [PATCH 19/81] flake8: inline ignores because it's not actually a
problem
---
textile/core.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 7b66af0..a8d5eb9 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -467,10 +467,12 @@ def block(self, text):
content = out[-2]
if not multiline_para:
- content = generate_tag(block.inner_tag, content,
- block.inner_atts)
- content = generate_tag(block.outer_tag, content,
- block.outer_atts)
+ # block will have been defined in a previous run of the
+ # loop
+ content = generate_tag(block.inner_tag, content, # noqa: F821
+ block.inner_atts) # noqa: F821
+ content = generate_tag(block.outer_tag, content, # noqa: F821
+ block.outer_atts) # noqa: F821
out[-2] = content
tag, atts, ext, cite, content = match.groups()
block = Block(self, **match.groupdict())
From 3e1442706e3a0d96b8259377793f45a370f38882 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:12:53 -0500
Subject: [PATCH 20/81] flake8: remove unused variables
---
textile/core.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/core.py b/textile/core.py
index a8d5eb9..936bebb 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -1298,7 +1298,7 @@ def fNoteLists(self, match):
def makeBackrefLink(self, info, g_links, i):
"""Given the pieces of a back reference link, create an tag."""
- atts, content, infoid, link = '', '', '', ''
+ link = ''
if 'def' in info:
link = info['def']['link']
backlink_type = link or g_links
From 7b1ac69f028355beed181da4b18c5a831dfe2fc9 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:14:15 -0500
Subject: [PATCH 21/81] flake8: 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 60b6804..ad95e48 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)
-from textile.utils import encode_html, generate_tag, parse_attributes
+from textile.utils import generate_tag, parse_attributes
try:
import regex as re
From a20b5676bda2c33dfee4b0b6adf581b662541b79 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:15:03 -0500
Subject: [PATCH 22/81] flake8: remove unused variable
---
textile/objects/table.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index ad95e48..882e040 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -161,7 +161,6 @@ def process(self):
colgroup = ElementTree.Element('colgroup', attrib=group_atts)
colgroup.text = '\n\t'
if self.cols is not None:
- has_newline = "\n" in self.cols
match_cols = self.cols.replace('.', '').split('|')
# colgroup is the first item in match_cols, the remaining items are
# cols.
From 70841f67bac5cc118791c5f16874b8b5e448f4d6 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 16:16:25 -0500
Subject: [PATCH 23/81] add flake8 linting back in now that `F` class
violations have been resolved
---
.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 16f06b2..437820d 100644
--- a/.github/workflows/lint_and_test.yml
+++ b/.github/workflows/lint_and_test.yml
@@ -17,8 +17,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
image-size: ${{ matrix.image-size }}
- #- name: Python flake8 Lint
- # uses: py-actions/flake8@v1.2.0
+ - name: Python flake8 Lint
+ uses: py-actions/flake8@v1.2.0
- name: Install dependencies
run: |
imagesize=''
From acd6cb9aa367da8e3e058b0333773f811e323490 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 17:01:46 -0500
Subject: [PATCH 24/81] flake8: various indentation cleanups
---
textile/regex_strings.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/textile/regex_strings.py b/textile/regex_strings.py
index b20fc82..68085d9 100644
--- a/textile/regex_strings.py
+++ b/textile/regex_strings.py
@@ -4,7 +4,7 @@
try:
# Use regex module for matching uppercase characters if installed,
# otherwise fall back to finding all the uppercase chars in a loop.
- import regex as re # noqa: F401
+ import regex as re # noqa: F401
upper_re_s = r'\p{Lu}'
regex_snippets = {
'acr': r'\p{Lu}\p{Nd}',
@@ -15,12 +15,12 @@
'digit': r'\p{N}',
'space': r'(?:\p{Zs}|\v)',
'char': r'(?:[^\p{Zs}\v])',
- }
+ }
except ImportError:
from sys import maxunicode
upper_re_s = "".join(
- [chr(c) for c in range(maxunicode) if chr(c).isupper()]
- )
+ [chr(c) for c in range(maxunicode) if chr(c).isupper()]
+ )
regex_snippets = {
'acr': r'{0}0-9'.format(upper_re_s),
'abr': r'{0}'.format(upper_re_s),
@@ -30,7 +30,7 @@
'digit': r'\d',
'space': r'(?:\s|\v)',
'char': r'\S',
- }
+ }
halign_re_s = r'(?:\<(?!>)|(?|\<\>|\=|[()]+(?! ))'
valign_re_s = r'[\-^~]'
@@ -43,10 +43,10 @@
table_span_re_s = r'(?:{0}|{1})*'.format(colspan_re_s, rowspan_re_s)
# regex string to match class, style and language attributes
cls_re_s = (r'(?:'
- r'{c}(?:{l}(?:{s})?|{s}(?:{l})?)?|'
- r'{l}(?:{c}(?:{s})?|{s}(?:{c})?)?|'
- r'{s}(?:{c}(?:{l})?|{l}(?:{c})?)?'
+ r'{c}(?:{l}(?:{s})?|{s}(?:{l})?)?|'
+ r'{l}(?:{c}(?:{s})?|{s}(?:{c})?)?|'
+ r'{s}(?:{c}(?:{l})?|{l}(?:{c})?)?'
r')?'
- ).format(c=class_re_s, s=style_re_s, l=language_re_s)
+ ).format(c=class_re_s, s=style_re_s, l=language_re_s)
pnct_re_s = r'[-!"#$%&()*+,/:;<=>?@\'\[\\\]\.^_`{|}~]'
syms_re_s = '¤§µ¶†‡•∗∴◊♠♣♥♦'
From e3d0c4afaf20d429a5838c4e651b9b6f7644d4e2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 17:04:00 -0500
Subject: [PATCH 25/81] flake8: spacing cleanup
---
textile/utils.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/textile/utils.py b/textile/utils.py
index 1b18945..fed1d51 100644
--- a/textile/utils.py
+++ b/textile/utils.py
@@ -20,10 +20,12 @@ def decode_high(text):
text = '{0};'.format(text)
return html.unescape(text)
+
def encode_high(text):
"""Encode the text so that it is an appropriate HTML entity."""
return ord(text)
+
def encode_html(text, quotes=True):
"""Return text that's safe for an HTML attribute."""
a = (
@@ -39,6 +41,7 @@ def encode_html(text, quotes=True):
text = text.replace(k, v)
return text
+
def generate_tag(tag, content, attributes=None):
"""Generate a complete html tag using the ElementTree module. tag and
content are strings, the attributes argument is a dictionary. As
@@ -59,11 +62,12 @@ def generate_tag(tag, content, attributes=None):
# non-ascii text being html-entity encoded. Not bad, but not entirely
# matching php-textile either.
element_tag = ElementTree.tostringlist(element, encoding=enc,
- method='html')
+ method='html')
element_tag.insert(len(element_tag) - 1, content)
element_text = ''.join(element_tag)
return element_text
+
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
@@ -75,17 +79,20 @@ def has_raw_text(text):
r = re.compile(r'<(hr|br)[^>]*?/>').sub('', r)
return '' != r
+
def is_rel_url(url):
"""Identify relative urls."""
(scheme, netloc) = urlparse(url)[0:2]
return not scheme and not netloc
+
def is_valid_url(url):
parsed = urlparse(url)
if parsed.scheme == '':
return True
return False
+
def list_type(list_string):
listtypes = {
list_string.startswith('*'): 'u',
@@ -95,6 +102,7 @@ def list_type(list_string):
}
return listtypes.get(True, False)
+
def normalize_newlines(string):
out = string.strip()
out = re.sub(r'\r\n?', '\n', out)
@@ -102,6 +110,7 @@ def normalize_newlines(string):
out = re.sub(r'"$', '" ', out)
return out
+
def parse_attributes(block_attributes, element=None, include_id=True, restricted=False):
vAlign = {'^': 'top', '-': 'middle', '~': 'bottom'}
hAlign = {'<': 'left', '=': 'center', '>': 'right', '<>': 'justify'}
@@ -195,6 +204,7 @@ def parse_attributes(block_attributes, element=None, include_id=True, restricted
result['width'] = width
return result
+
def pba(block_attributes, element=None, include_id=True, restricted=False):
"""Parse block attributes."""
attrs = parse_attributes(block_attributes, element, include_id, restricted)
From b85969ca6ddfc1f210179031827ba77a65317583 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 17:04:47 -0500
Subject: [PATCH 26/81] flake8: comment spacing cleanup
---
textile/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/__init__.py b/textile/__init__.py
index 9ca8a65..08a242f 100644
--- a/textile/__init__.py
+++ b/textile/__init__.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from .core import textile, textile_restricted, Textile # noqa: F401
+from .core import textile, textile_restricted, Textile # noqa: F401
from .version import VERSION
__all__ = ['textile', 'textile_restricted']
From 152a570721a31a5eb7fa8aae00721deb15fb2994 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 18:11:13 -0500
Subject: [PATCH 27/81] flake8: indentation cleanup
---
textile/core.py | 180 ++++++++++++++++++++++++------------------------
1 file changed, 91 insertions(+), 89 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 936bebb..4c8e8a2 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -23,10 +23,10 @@
from textile.tools import sanitizer, imagesize
from textile.regex_strings import (align_re_s, cls_re_s, pnct_re_s,
- regex_snippets, syms_re_s, table_span_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, is_rel_url, is_valid_url, list_type,
+ normalize_newlines, parse_attributes, pba)
from textile.objects import Block, Table
try:
@@ -37,8 +37,8 @@
class Textile(object):
restricted_url_schemes = ('http', 'https', 'ftp', 'mailto')
- unrestricted_url_schemes = restricted_url_schemes + ('file', 'tel',
- 'callto', 'sftp', 'data')
+ unrestricted_url_schemes = restricted_url_schemes + (
+ 'file', 'tel', 'callto', 'sftp', 'data')
btag = ('bq', 'bc', 'notextile', 'pre', 'h[1-6]', r'fn\d+', 'p', '###')
btag_lite = ('bq', 'bc', 'p')
@@ -71,7 +71,7 @@ class Textile(object):
}
def __init__(self, restricted=False, lite=False, noimage=False,
- get_sizes=False, html_type='xhtml', rel='', block_tags=True):
+ get_sizes=False, html_type='xhtml', rel='', block_tags=True):
"""Textile properties that are common to regular textile and
textile_restricted"""
self.restricted = restricted
@@ -96,7 +96,7 @@ def __init__(self, restricted=False, lite=False, noimage=False,
cur = r''
if regex_snippets['cur']: # pragma: no branch
cur = r'(?:[{0}]{1}*)?'.format(regex_snippets['cur'],
- regex_snippets['space'])
+ regex_snippets['space'])
# We'll be searching for characters that need to be HTML-encoded to
# produce properly valid html. These are the defaults that work in
@@ -105,7 +105,7 @@ def __init__(self, restricted=False, lite=False, noimage=False,
self.glyph_search = [
# apostrophe's
re.compile(r"(^|{0}|\))'({0})".format(regex_snippets['wrd']),
- flags=re.U),
+ flags=re.U),
# back in '88
re.compile(r"({0})'(\d+{1}?)\b(?![.]?[{1}]*?')".format(
regex_snippets['space'], regex_snippets['wrd']),
@@ -134,17 +134,18 @@ def __init__(self, restricted=False, lite=False, noimage=False,
# en dash
re.compile(r' - '),
# dimension sign
- re.compile(r'([0-9]+[\])]?[\'"]? ?)[x]( ?[\[(]?)'
+ re.compile(
+ r'([0-9]+[\])]?[\'"]? ?)[x]( ?[\[(]?)'
r'(?=[+-]?{0}[0-9]*\.?[0-9]+)'.format(cur), flags=re.I | re.U),
# trademark
- re.compile(r'(\b ?|{0}|^)[([]TM[])]'.format(regex_snippets['space']
- ), flags=re.I | re.U),
+ re.compile(r'(\b ?|{0}|^)[([]TM[])]'.format(regex_snippets['space']),
+ flags=re.I | re.U),
# registered
- re.compile(r'(\b ?|{0}|^)[([]R[])]'.format(regex_snippets['space']
- ), flags=re.I | re.U),
+ re.compile(r'(\b ?|{0}|^)[([]R[])]'.format(regex_snippets['space']),
+ flags=re.I | re.U),
# copyright
- re.compile(r'(\b ?|{0}|^)[([]C[])]'.format(regex_snippets['space']
- ), flags=re.I | re.U),
+ re.compile(r'(\b ?|{0}|^)[([]C[])]'.format(regex_snippets['space']),
+ flags=re.I | re.U),
# 1/2
re.compile(r'[([]1\/2[])]'),
# 1/4
@@ -160,9 +161,11 @@ def __init__(self, restricted=False, lite=False, noimage=False,
regex_snippets['abr'], regex_snippets['acr']), flags=re.U),
# 3+ uppercase
re.compile(r'({space}|^|[>(;-])([{abr}]{{3,}})([{nab}]*)'
- '(?={space}|{pnct}|<|$)(?=[^">]*?(<|$))'.format(**{ 'space':
- regex_snippets['space'], 'abr': regex_snippets['abr'],
- 'nab': regex_snippets['nab'], 'pnct': pnct_re_s}), re.U),
+ '(?={space}|{pnct}|<|$)(?=[^">]*?(<|$))'.format(
+ **{'space': regex_snippets['space'], 'abr':
+ regex_snippets['abr'], 'nab':
+ regex_snippets['nab'], 'pnct': pnct_re_s}),
+ re.U),
]
# These are the changes that need to be made for characters that occur
# at the beginning of the string.
@@ -172,10 +175,10 @@ def __init__(self, restricted=False, lite=False, noimage=False,
regex_snippets['wrd']), flags=re.U)
# single closing
self.glyph_search_initial[3] = re.compile(r"(\S)'(?={0}|{1}|$)".format(
- regex_snippets['space'], pnct_re_s), re.U)
+ regex_snippets['space'], pnct_re_s), re.U)
# double closing
self.glyph_search_initial[6] = re.compile(r'(\S)"(?={0}|{1}|<|$)'.format(
- regex_snippets['space'], pnct_re_s), re.U)
+ regex_snippets['space'], pnct_re_s), re.U)
self.glyph_replace = [x.format(**self.glyph_definitions) for x in (
r'\1{apostrophe}\2', # apostrophe's
@@ -201,7 +204,7 @@ def __init__(self, restricted=False, lite=False, noimage=False,
r'{plusminus}', # plus/minus
r'\1', # 3+ uppercase acronym
r'\1{0}:glyph:\2' # 3+ uppercase
- r'\3'.format(self.uid),
+ r'\3'.format(self.uid),
)]
if self.html_type == 'html5':
@@ -241,9 +244,9 @@ def parse(self, text, rel=None, sanitize=False):
self.blocktag_whitelist = ['bq', 'p']
text = self.block(text)
else:
- self.blocktag_whitelist = [ 'bq', 'p', 'bc', 'notextile',
- 'pre', 'h[1-6]',
- 'fn{0}+'.format(regex_snippets['digit']), '###']
+ self.blocktag_whitelist = ['bq', 'p', 'bc', 'notextile',
+ 'pre', 'h[1-6]', 'fn{0}+'.format(
+ regex_snippets['digit']), '###']
text = self.block(text)
text = self.placeNoteLists(text)
else:
@@ -280,9 +283,10 @@ def parse(self, text, rel=None, sanitize=False):
def table(self, text):
text = "{0}\n\n".format(text)
pattern = re.compile(r'^(?:table(?P_?{s}{a}{c})\.'
- r'(?P.*?)\n)?^(?P{a}{c}\.? ?\|.*\|)'
- r'[\s]*\n\n'.format(**{'s': table_span_re_s, 'a': align_re_s,
- 'c': cls_re_s}), flags=re.S | re.M | re.U)
+ r'(?P.*?)\n)?^(?P{a}{c}\.? ?\|.*\|)'
+ r'[\s]*\n\n'.format(
+ **{'s': table_span_re_s, 'a': align_re_s,
+ 'c': cls_re_s}), flags=re.S | re.M | re.U)
match = pattern.search(text)
if match:
table = Table(self, **match.groupdict())
@@ -291,7 +295,7 @@ def table(self, text):
def textileLists(self, text):
pattern = re.compile(r'^((?:[*;:]+|[*;:#]*#(?:_|\d+)?){0}[ .].*)$'
- r'(?![^#*;:])'.format(cls_re_s), re.U | re.M | re.S)
+ r'(?![^#*;:])'.format(cls_re_s), re.U | re.M | re.S)
return pattern.sub(self.fTextileList, text)
def fTextileList(self, match):
@@ -306,7 +310,7 @@ def fTextileList(self, match):
nextline = ''
m = re.search(r"^(?P[#*;:]+)(?P_|\d+)?(?P{0})[ .]"
- "(?P.*)$".format(cls_re_s), line, re.S)
+ "(?P.*)$".format(cls_re_s), line, re.S)
if m:
tl, start, atts, content = m.groups()
content = content.strip()
@@ -354,7 +358,7 @@ def fTextileList(self, match):
self.olstarts[tl] = 1
nm = re.match(r"^(?P[#\*;:]+)(_|[\d]+)?{0}"
- r"[ .].*".format(cls_re_s), nextline)
+ r"[ .].*".format(cls_re_s), nextline)
if nm:
nl = nm.group('nextlistitem')
@@ -374,7 +378,7 @@ def fTextileList(self, match):
if tl not in ls:
ls[tl] = 1
itemtag = ("\n{0}\t<{1}>{2}".format(tabs, litem, content) if
- showitem else '')
+ showitem else '')
line = "<{0}l{1}{2}>{3}".format(ltype, atts, start, itemtag)
else:
line = ("\t<{0}{1}>{2}".format(litem, atts, content) if
@@ -387,18 +391,13 @@ def fTextileList(self, match):
for k, v in reversed(list(ls.items())):
if len(k) > len(nl):
if v != 2:
- line = "{0}\n{1}{2}l>".format(line, tabs,
- list_type(k))
+ line = "{0}\n{1}{2}l>".format(
+ line, tabs, list_type(k))
if len(k) > 1 and v != 2:
line = "{0}{1}>".format(line, litem)
del ls[k]
# Remember the current Textile tag:
pt = tl
- # This else exists in the original php version. I'm not sure how
- # to come up with a case where the line would not match. I think
- # it may have been necessary due to the way php returns matches.
- # else:
- #line = "{0}\n".format(line)
result.append(line)
return self.doTagBr(litem, "\n".join(result))
@@ -414,7 +413,7 @@ def doBr(self, match):
content = re.sub(r'(.+)(?:(?)|(?))\n(?![#*;:\s|])',
r'\1
', 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{0})(?P{1}{2})\.(?P\.?)'
- r'(?::(?P\S+))? (?P.*)$'.format(tre,
- align_re_s, cls_re_s))
+ r'(?::(?P\S+))? (?P.*)$'.format(
+ tre, align_re_s, cls_re_s))
match = re.search(pattern, line, flags=re.S | re.U)
# tag specified on this line.
if match:
@@ -469,15 +468,15 @@ def block(self, text):
if not multiline_para:
# block will have been defined in a previous run of the
# loop
- content = generate_tag(block.inner_tag, content, # noqa: F821
- block.inner_atts) # noqa: F821
- content = generate_tag(block.outer_tag, content, # noqa: F821
- block.outer_atts) # noqa: F821
+ content = generate_tag(block.inner_tag, content, # noqa: F821
+ block.inner_atts) # noqa: F821
+ content = generate_tag(block.outer_tag, content, # noqa: F821
+ block.outer_atts) # noqa: F821
out[-2] = content
tag, atts, ext, cite, content = match.groups()
block = Block(self, **match.groupdict())
inner_block = generate_tag(block.inner_tag, block.content,
- block.inner_atts)
+ block.inner_atts)
# code tags and raw text won't be indented inside outer_tag.
if block.inner_tag != 'code' and not has_raw_text(inner_block):
inner_block = "\n\t\t{0}\n\t".format(inner_block)
@@ -485,7 +484,7 @@ def block(self, text):
line = block.content
else:
line = generate_tag(block.outer_tag, inner_block,
- block.outer_atts)
+ block.outer_atts)
# pre tags and raw text won't be indented.
if block.outer_tag != 'pre' and not has_raw_text(line):
line = "\t{0}".format(line)
@@ -517,7 +516,7 @@ def block(self, text):
line = block.content
else:
line = generate_tag(block.outer_tag, block.content,
- block.outer_atts)
+ block.outer_atts)
line = "\t{0}".format(line)
else:
if block.tag == 'pre' or block.inner_tag == 'code':
@@ -571,14 +570,15 @@ def block(self, text):
def footnoteRef(self, text):
# somehow php-textile gets away with not capturing the space.
return re.compile(r'(?<=\S)\[(?P{0}+)(?P!?)\]'
- r'(?P{1}?)'.format(regex_snippets['digit'],
- regex_snippets['space']), re.U).sub(self.footnoteID, text)
+ r'(?P{1}?)'.format(
+ regex_snippets['digit'], regex_snippets['space']),
+ re.U).sub(self.footnoteID, text)
def footnoteID(self, m):
fn_att = OrderedDict({'class': 'footnote'})
if m.group('id') not in self.fn:
- self.fn[m.group('id')] = '{0}{1}'.format(self.linkPrefix,
- self._increment_link_index())
+ self.fn[m.group('id')] = '{0}{1}'.format(
+ self.linkPrefix, self._increment_link_index())
fnid = self.fn[m.group('id')]
fn_att['id'] = 'fnrev{0}'.format(fnid)
fnid = self.fn[m.group('id')]
@@ -612,7 +612,7 @@ def glyphs(self, text):
searchlist = self.glyph_search_initial
# split the text by any angle-bracketed tags
for i, line in enumerate(re.compile(r'(<[\w\/!?].*?>)', re.U).split(
- text)):
+ text)):
if not i % 2:
for s, r in zip(searchlist, self.glyph_replace):
line = s.sub(r, line)
@@ -777,7 +777,7 @@ def markStartOfLinks(self, text):
# Re-assemble the link starts with a specific marker for the
# next regex.
o = '{0}{1}linkStartMarker:"{2}'.format(pre_link, self.uid,
- link_content)
+ link_content)
output.append(o)
# Add the last part back
@@ -819,7 +819,7 @@ def fLink(self, m):
) # end of $text
(?:\((?P[^)]+?)\))? # $title (if any)
$'''.format(cls_re_s, regex_snippets['space']), inner,
- flags=re.X | re.U)
+ flags=re.X | re.U)
atts = (m and m.group('atts')) or ''
text = (m and m.group('text')) or inner
@@ -914,20 +914,20 @@ def _casesdefault(c, pop, popped, url_chars, counts, pre):
return pop, popped, url_chars, counts, pre
cases = {
- '!': _endchar,
- '?': _endchar,
- ':': _endchar,
- ';': _endchar,
- '.': _endchar,
- ',': _endchar,
- '>': _rightanglebracket,
- ']': _closingsquarebracket,
- ')': _closingparenthesis,
- }
+ '!': _endchar,
+ '?': _endchar,
+ ':': _endchar,
+ ';': _endchar,
+ '.': _endchar,
+ ',': _endchar,
+ '>': _rightanglebracket,
+ ']': _closingsquarebracket,
+ ')': _closingparenthesis,
+ }
for c in url_chars[-1::-1]: # pragma: no branch
popped = False
- pop, popped, url_chars, counts, pre = cases.get(c,
- _casesdefault)(c, pop, popped, url_chars, counts, pre)
+ pop, popped, url_chars, counts, pre = cases.get(
+ c, _casesdefault)(c, pop, popped, url_chars, counts, pre)
first = False
if popped is False:
break
@@ -991,8 +991,7 @@ def encode_url(self, url):
""", re.X | re.U)
netloc_parsed = netloc_pattern.match(parsed.netloc).groupdict()
else:
- netloc_parsed = {'user': '', 'password': '', 'host': '', 'port':
- ''}
+ netloc_parsed = {'user': '', 'password': '', 'host': '', 'port': ''}
# encode each component
scheme = parsed.scheme
@@ -1008,7 +1007,7 @@ def encode_url(self, url):
# because the quote and unquote functions expects different input
# types: unicode strings for PY2 and str for PY3.
path_parts = (quote(unquote(pce), b'') for pce in
- parsed.path.split('/'))
+ parsed.path.split('/'))
path = '/'.join(path_parts)
# put it back together
@@ -1041,8 +1040,10 @@ def span(self, text):
(?P[{pnct}]*)
{tag}
(?P$|[\[\]}}<]|(?=[{pnct}]{{1,2}}[^0-9]|\s|\)))
- """.format(**{'tag': tag, 'cls': cls_re_s, 'pnct': pnct,
- 'space': regex_snippets['space']}), flags=re.X | re.U)
+ """.format(
+ **{'tag': tag, 'cls': cls_re_s, 'pnct': pnct, 'space':
+ regex_snippets['space']}
+ ), flags=re.X | re.U)
text = pattern.sub(self.fSpan, text)
self.span_depth = self.span_depth - 1
return text
@@ -1189,7 +1190,7 @@ def redcloth_list(self, text):
"""Parse the text for definition lists and send them to be
formatted."""
pattern = re.compile(r"^([-]+{0}[ .].*:=.*)$(?![^-])".format(cls_re_s),
- re.M | re.U | re.S)
+ re.M | re.U | re.S)
return pattern.sub(self.fRCList, text)
def fRCList(self, match):
@@ -1199,7 +1200,7 @@ def fRCList(self, match):
for line in text:
# parse the attributes and content
m = re.match(r'^[-]+({0})[ .](.*)$'.format(cls_re_s), line,
- flags=re.M | re.S)
+ flags=re.M | re.S)
if not m:
continue
@@ -1233,7 +1234,7 @@ def fRCList(self, match):
definition = self.graf(definition)
out.extend(['\t{1}'.format(atts, term),
- '\t{0}'.format(definition)])
+ '\t{0}'.format(definition)])
out.append('')
out = '\n'.join(out)
@@ -1256,7 +1257,7 @@ def placeNoteLists(self, text):
o = OrderedDict(sorted(o.items(), key=lambda t: t[0]))
self.notes = o
text_re = re.compile(r'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
@@ -1278,11 +1279,12 @@ def fNoteLists(self, match):
atts = info['def']['atts']
content = info['def']['content']
li = ('\t\t{1} '
- '{3}').format(atts, links, infoid,
- content)
+ '{3}').format(atts, links, infoid,
+ content)
else:
- li = ('\t\t{1} Undefined Note [#{2}].'
- ).format(atts, links, info['seq'])
+ li = (
+ '\t\t{1} Undefined Note [#{2}].'
+ ).format(atts, links, info['seq'])
o.append(li)
if '+' == extras and self.unreferencedNotes:
for seq, info in self.unreferencedNotes.items():
@@ -1316,7 +1318,7 @@ def makeBackrefLink(self, info, g_links, i):
for refid in info['refids']:
i_entity = decode_high(i_)
sup = """{1}""".format(
- refid, i_entity)
+ refid, i_entity)
if allow_inc:
i_ = i_ + 1
result.append(sup)
@@ -1332,13 +1334,14 @@ def fParseNoteDefs(self, m):
# Assign an id if the note reference parse hasn't found the label yet.
if label not in self.notes:
- self.notes[label] = {'id': '{0}{1}'.format(self.linkPrefix,
- self._increment_link_index())}
+ self.notes[label] = {'id': '{0}{1}'.format(
+ self.linkPrefix, self._increment_link_index())}
# Ignores subsequent defs using the same label
if 'def' not in self.notes[label]: # pragma: no branch
- self.notes[label]['def'] = {'atts': pba(att, restricted=self.restricted), 'content':
- self.graf(content), 'link': link}
+ self.notes[label]['def'] = {
+ 'atts': pba(att, restricted=self.restricted), 'content':
+ self.graf(content), 'link': link}
return ''
def noteRef(self, text):
@@ -1380,8 +1383,8 @@ def fParseNoteRefs(self, match):
# If we are referencing a note that hasn't had the definition parsed
# yet, then assign it an ID...
if not self.notes[label]['id']:
- self.notes[label]['id'] = '{0}{1}'.format(self.linkPrefix,
- self._increment_link_index())
+ self.notes[label]['id'] = '{0}{1}'.format(
+ self.linkPrefix, self._increment_link_index())
labelid = self.notes[label]['id']
# Build the link (if any)...
@@ -1447,5 +1450,4 @@ def textile_restricted(text, lite=True, noimage=True, html_type='xhtml'):
"""
return Textile(restricted=True, lite=lite, noimage=noimage,
- html_type=html_type, rel='nofollow').parse(
- text)
+ html_type=html_type, rel='nofollow').parse(text)
From 411d23d6d218041e86cf47bba1691f2e29585578 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 18:37:03 -0500
Subject: [PATCH 28/81] flake8: mostly whitespace cleanup
---
textile/core.py | 94 ++++++++++++++++++++++++-------------------------
1 file changed, 47 insertions(+), 47 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index 4c8e8a2..fad4f5d 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -48,26 +48,26 @@ class Textile(object):
doctype_whitelist = ['xhtml', 'html5']
glyph_definitions = {
- 'quote_single_open': '‘',
- 'quote_single_close': '’',
- 'quote_double_open': '“',
- 'quote_double_close': '”',
- 'apostrophe': '’',
- 'prime': '′',
- 'prime_double': '″',
- 'ellipsis': '…',
- 'ampersand': '&',
- 'emdash': '—',
- 'endash': '–',
- 'dimension': '×',
- 'trademark': '™',
- 'registered': '®',
- 'copyright': '©',
- 'half': '½',
- 'quarter': '¼',
- 'threequarters': '¾',
- 'degrees': '°',
- 'plusminus': '±',
+ 'quote_single_open': '‘', # noqa: E241
+ 'quote_single_close': '’', # noqa: E241
+ 'quote_double_open': '“', # noqa: E241
+ 'quote_double_close': '”', # noqa: E241
+ 'apostrophe': '’', # noqa: E241
+ 'prime': '′', # noqa: E241
+ 'prime_double': '″', # noqa: E241
+ 'ellipsis': '…', # noqa: E241
+ 'ampersand': '&', # noqa: E241
+ 'emdash': '—', # noqa: E241
+ 'endash': '–', # noqa: E241
+ 'dimension': '×', # noqa: E241
+ 'trademark': '™', # noqa: E241
+ 'registered': '®', # noqa: E241
+ 'copyright': '©', # noqa: E241
+ 'half': '½', # noqa: E241
+ 'quarter': '¼', # noqa: E241
+ 'threequarters': '¾', # noqa: E241
+ 'degrees': '°', # noqa: E241
+ 'plusminus': '±', # noqa: E241
}
def __init__(self, restricted=False, lite=False, noimage=False,
@@ -94,7 +94,7 @@ def __init__(self, restricted=False, lite=False, noimage=False,
self.block_tags = block_tags
cur = r''
- if regex_snippets['cur']: # pragma: no branch
+ if regex_snippets['cur']: # pragma: no branch
cur = r'(?:[{0}]{1}*)?'.format(regex_snippets['cur'],
regex_snippets['space'])
@@ -721,7 +721,7 @@ def markStartOfLinks(self, text):
linkparts = []
i = 0
- while balanced != 0 or i == 0: # pragma: no branch
+ while balanced != 0 or i == 0: # pragma: no branch
# Starting at the end, pop off the previous part of the
# slice's fragments.
@@ -730,9 +730,9 @@ def markStartOfLinks(self, text):
if len(possibility) > 0:
# did this part inc or dec the balanced count?
- if re.search(r'^\S|=$', possibility, flags=re.U): # pragma: no branch
+ if re.search(r'^\S|=$', possibility, flags=re.U): # pragma: no branch
balanced = balanced - 1
- if re.search(r'\S$', possibility, flags=re.U): # pragma: no branch
+ if re.search(r'\S$', possibility, flags=re.U): # pragma: no branch
balanced = balanced + 1
try:
possibility = possible_start_quotes.pop()
@@ -752,7 +752,7 @@ def markStartOfLinks(self, text):
try:
possibility = possible_start_quotes.pop()
- except IndexError: # pragma: no cover
+ except IndexError: # pragma: no cover
# If out of possible starting segments we back the
# last one from the linkparts array
linkparts.pop()
@@ -761,7 +761,7 @@ def markStartOfLinks(self, text):
# we have a closing ".
if (possibility == '' or possibility.endswith(' ')):
# force search exit
- balanced = 0;
+ balanced = 0
if balanced <= 0:
possible_start_quotes.append(possibility)
@@ -826,7 +826,7 @@ def fLink(self, m):
title = (m and m.group('title')) or ''
pop, tight = '', ''
- counts = { '[': None, ']': url.count(']'), '(': None, ')': None }
+ counts = {'[': None, ']': url.count(']'), '(': None, ')': None}
# Look for footnotes or other square-bracket delimited stuff at the end
# of the url...
@@ -893,13 +893,13 @@ def _closingsquarebracket(c, pop, popped, url_chars, counts, pre):
# it
popped = True
url_chars.pop()
- counts[']'] = counts[']'] - 1;
- if first: # pragma: no branch
+ counts[']'] = counts[']'] - 1
+ if first: # pragma: no branch
pre = ''
return pop, popped, url_chars, counts, pre
def _closingparenthesis(c, pop, popped, url_chars, counts, pre):
- if counts[')'] is None: # pragma: no branch
+ if counts[')'] is None: # pragma: no branch
counts['('] = url.count('(')
counts[')'] = url.count(')')
@@ -924,7 +924,7 @@ def _casesdefault(c, pop, popped, url_chars, counts, pre):
']': _closingsquarebracket,
')': _closingparenthesis,
}
- for c in url_chars[-1::-1]: # pragma: no branch
+ for c in url_chars[-1::-1]: # pragma: no branch
popped = False
pop, popped, url_chars, counts, pre = cases.get(
c, _casesdefault)(c, pop, popped, url_chars, counts, pre)
@@ -950,7 +950,7 @@ def _casesdefault(c, pop, popped, url_chars, counts, pre):
text = text.strip()
title = encode_html(title)
- if not self.noimage: # pragma: no branch
+ if not self.noimage: # pragma: no branch
text = self.image(text)
text = self.span(text)
text = self.glyphs(text)
@@ -1052,16 +1052,16 @@ def fSpan(self, match):
pre, tag, atts, cite, content, end, tail = match.groups()
qtags = {
- '*': 'strong',
- '**': 'b',
- '??': 'cite',
- '_': 'em',
- '__': 'i',
- '-': 'del',
- '%': 'span',
- '+': 'ins',
- '~': 'sub',
- '^': 'sup'
+ '*': 'strong', # noqa: E241
+ '**': 'b', # noqa: E241
+ '??': 'cite', # noqa: E241
+ '_': 'em', # noqa: E241
+ '__': 'i', # noqa: E241
+ '-': 'del', # noqa: E241
+ '%': 'span', # noqa: E241
+ '+': 'ins', # noqa: E241
+ '~': 'sub', # noqa: E241
+ '^': 'sup' # noqa: E241
}
tag = qtags[tag]
@@ -1164,7 +1164,7 @@ def noTextile(self, text):
def fTextile(self, match):
before, notextile, after = match.groups()
- if after is None: # pragma: no branch
+ if after is None: # pragma: no branch
after = ''
return ''.join([before, self.shelve(notextile), after])
@@ -1252,7 +1252,7 @@ def placeNoteLists(self, text):
else:
self.unreferencedNotes[label] = info
- if o: # pragma: no branch
+ if o: # pragma: no branch
# sort o by key
o = OrderedDict(sorted(o.items(), key=lambda t: t[0]))
self.notes = o
@@ -1268,9 +1268,9 @@ def fNoteLists(self, match):
index = '{0}{1}{2}'.format(g_links, extras, start_char)
result = ''
- if index not in self.notelist_cache: # pragma: no branch
+ if index not in self.notelist_cache: # pragma: no branch
o = []
- if self.notes: # pragma: no branch
+ if self.notes: # pragma: no branch
for seq, info in self.notes.items():
links = self.makeBackrefLink(info, g_links, start_char)
atts = ''
@@ -1338,7 +1338,7 @@ def fParseNoteDefs(self, m):
self.linkPrefix, self._increment_link_index())}
# Ignores subsequent defs using the same label
- if 'def' not in self.notes[label]: # pragma: no branch
+ if 'def' not in self.notes[label]: # pragma: no branch
self.notes[label]['def'] = {
'atts': pba(att, restricted=self.restricted), 'content':
self.graf(content), 'link': link}
From ba2736d51ea5e6b67edcfe757ceec0ea31e17e76 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 18:47:46 -0500
Subject: [PATCH 29/81] flake8: warning cleanup
---
textile/core.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/textile/core.py b/textile/core.py
index fad4f5d..6721d83 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -996,8 +996,9 @@ def encode_url(self, url):
# encode each component
scheme = parsed.scheme
user = netloc_parsed['user'] and quote(netloc_parsed['user'])
- password = (netloc_parsed['password'] and
- quote(netloc_parsed['password']))
+ password = (
+ netloc_parsed['password'] and quote(netloc_parsed['password'])
+ )
host = netloc_parsed['host']
port = netloc_parsed['port'] and netloc_parsed['port']
# the below splits the path portion of the url by slashes, translates
From 2f128a2f1ce65932d772460dc6689c1770f2df7c Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 18:49:08 -0500
Subject: [PATCH 30/81] flake8: comment cleanup
---
textile/__main__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/textile/__main__.py b/textile/__main__.py
index 1845961..210c147 100644
--- a/textile/__main__.py
+++ b/textile/__main__.py
@@ -33,5 +33,5 @@ def main():
outfile.write(output)
-if __name__ == '__main__': #pragma: no cover
+if __name__ == '__main__': # pragma: no cover
main()
From 97eb73044a3b4dd088ca63dcacda2432b50c7cfa Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:01:03 -0500
Subject: [PATCH 31/81] flake8: mostly indentation cleanup
---
textile/objects/block.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/textile/objects/block.py b/textile/objects/block.py
index de993e8..7aca9dd 100644
--- a/textile/objects/block.py
+++ b/textile/objects/block.py
@@ -71,12 +71,11 @@ def process(self):
else:
supp_id = parse_attributes('(#fn{0})'.format(fnid), restricted=self.textile.restricted)
-
if '^' not in self.atts:
sup = generate_tag('sup', fns.group('fnid'), supp_id)
else:
fnrev = generate_tag('a', fns.group('fnid'), {'href':
- '#fnrev{0}'.format(fnid)})
+ '#fnrev{0}'.format(fnid)})
sup = generate_tag('sup', fnrev, supp_id)
self.content = '{0} {1}'.format(sup, self.content)
From 5333f8486a5954db9302ee8f1014259e3b9efce5 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:07:22 -0500
Subject: [PATCH 32/81] flake8: indentation cleanup
---
textile/objects/block.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/textile/objects/block.py b/textile/objects/block.py
index 7aca9dd..8f44ad1 100644
--- a/textile/objects/block.py
+++ b/textile/objects/block.py
@@ -40,7 +40,7 @@ def process(self):
[{space}]+ # whitespace ends def marker
(?P.*)$ # content""".format(
space=regex_snippets['space'], cls=cls_re_s),
- flags=re.X | re.U)
+ flags=re.X | re.U)
notedef = notedef_re.sub(self.textile.fParseNoteDefs, self.content)
# It will be empty if the regex matched and ate it.
@@ -49,13 +49,13 @@ def process(self):
self.eat = True
fns = re.search(r'fn(?P{0}+)'.format(regex_snippets['digit']),
- self.tag, flags=re.U)
+ self.tag, flags=re.U)
if fns:
self.tag = 'p'
fnid = self.textile.fn.get(fns.group('fnid'), None)
if fnid is None:
fnid = '{0}{1}'.format(self.textile.linkPrefix,
- self.textile._increment_link_index())
+ self.textile._increment_link_index())
# If there is an author-specified ID goes on the wrapper & the
# auto-id gets pushed to the
From 7ffa65d1bbfb9e129aafca6b91590f63323b0379 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:07:44 -0500
Subject: [PATCH 33/81] flake8: indentation and whitespace cleanup
---
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 882e040..717d457 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -131,8 +131,8 @@ def process(self):
if rgrp:
groups.append('\n\t{0}'.format(rgrp.process()))
- content = '{0}{1}{2}{3}\n\t'.format(self.caption, self.colgroup,
- ''.join(groups), ''.join(self.content))
+ content = '{0}{1}{2}{3}\n\t'.format(
+ self.caption, self.colgroup, ''.join(groups), ''.join(self.content))
tbl = generate_tag('table', content, self.attributes)
return '\t{0}\n\n'.format(tbl)
From de319df092100cd078333a048193abeb454e0dd0 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:09:31 -0500
Subject: [PATCH 34/81] flake8: indentation and whitespace cleanup
---
textile/objects/table.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/textile/objects/table.py b/textile/objects/table.py
index 717d457..d20f800 100644
--- a/textile/objects/table.py
+++ b/textile/objects/table.py
@@ -4,7 +4,7 @@
from xml.etree import ElementTree
from textile.regex_strings import (align_re_s, cls_re_s, regex_snippets,
- table_span_re_s, valign_re_s)
+ table_span_re_s, valign_re_s)
from textile.utils import generate_tag, parse_attributes
try:
@@ -27,7 +27,7 @@ def __init__(self, textile, tatts, rows, summary):
def process(self):
rgrp = None
groups = []
- if self.input[-1] == '|': # pragma: no branch
+ if self.input[-1] == '|': # pragma: no branch
self.input = '{0}\n'.format(self.input)
split = self.input.split('|\n')
for i, row in enumerate([x for x in split if x]):
@@ -66,8 +66,9 @@ def process(self):
# search the row for a table group - thead, tfoot, or tbody
grpmatchpattern = (r"(:?^\|(?P{v})(?P{s}{a}{c})"
- r"\.\s*$\n)?^(?P.*)").format(**{'v': valign_re_s, 's':
- table_span_re_s, 'a': align_re_s, 'c': cls_re_s})
+ r"\.\s*$\n)?^(?P.*)").format(
+ **{'v': valign_re_s, 's': table_span_re_s,
+ 'a': align_re_s, 'c': cls_re_s})
grpmatch_re = re.compile(grpmatchpattern, re.S | re.M)
grpmatch = grpmatch_re.match(row.lstrip())
@@ -97,8 +98,9 @@ def process(self):
ctag = 'th'
cmtch = re.search(r'^(?P_?{0}{1}{2}\. )'
- '(?P.*)'.format(table_span_re_s, align_re_s,
- cls_re_s), cell, flags=re.S)
+ '(?P.*)'.format(
+ table_span_re_s, align_re_s, cls_re_s),
+ cell, flags=re.S)
if cmtch:
catts = cmtch.group('catts')
cell_atts = parse_attributes(catts, 'td', restricted=self.textile.restricted)
@@ -108,7 +110,7 @@ def process(self):
if not self.textile.lite:
a_pattern = r'(?P{0}*)(?P.*)'.format(
- regex_snippets['space'])
+ regex_snippets['space'])
a = re.search(a_pattern, cell, flags=re.S)
cell = self.textile.redcloth_list(a.group('cell'))
cell = self.textile.textileLists(cell)
From 67df70c201a7b3d21a224720780811ebe37a9cc5 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:09:55 -0500
Subject: [PATCH 35/81] flake8: whitespace cleanup
---
setup.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 80488d2..b405f28 100644
--- a/setup.py
+++ b/setup.py
@@ -10,6 +10,7 @@ def get_version():
return variables.get('VERSION')
raise RuntimeError('No version info found.')
+
setup(
name='textile',
version=get_version(),
@@ -38,7 +39,7 @@ def get_version():
install_requires=[
'html5lib>=1.0.1',
'regex>1.0; implementation_name != "pypy"',
- ],
+ ],
extras_require={
'develop': ['pytest', 'pytest-cov'],
'imagesize': ['Pillow>=3.0.0'],
From 1f26d4cd9b4f6d93d7e1c04b09c81203a213df9a Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:16:22 -0500
Subject: [PATCH 36/81] flake8: whitespace cleanup
---
tests/test_block.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_block.py b/tests/test_block.py
index 613bf41..93d3c17 100644
--- a/tests/test_block.py
+++ b/tests/test_block.py
@@ -69,6 +69,7 @@ def test_blockcode_comment():
result = t.parse(input)
assert result == expect
+
def test_extended_pre_block_with_many_newlines():
"""Extra newlines in an extended pre block should not get cut down to only
two."""
From c20f9a575fc5ea7bab3825e825c47e2d0b75d4c3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:17:30 -0500
Subject: [PATCH 37/81] flake8: whitespace cleanup
---
tests/test_block.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/test_block.py b/tests/test_block.py
index 93d3c17..691d21a 100644
--- a/tests/test_block.py
+++ b/tests/test_block.py
@@ -8,6 +8,7 @@
except ImportError:
from ordereddict import OrderedDict
+
def test_block():
t = textile.Textile()
result = t.block('h1. foobar baby')
@@ -16,14 +17,14 @@ def test_block():
b = Block(t, "bq", "", None, "", "Hello BlockQuote")
expect = ('blockquote', OrderedDict(), 'p', OrderedDict(),
- 'Hello BlockQuote')
+ 'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect
b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote")
expect = ('blockquote', OrderedDict([('cite',
- '{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
- 'Hello BlockQuote')
+ '{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(),
+ 'Hello BlockQuote')
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect
@@ -39,6 +40,7 @@ def test_block():
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content)
assert result == expect
+
def test_block_tags_false():
t = textile.Textile(block_tags=False)
assert t.block_tags is False
@@ -47,6 +49,7 @@ def test_block_tags_false():
expect = 'test'
assert result == expect
+
def test_blockcode_extended():
input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test'
expect = '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 Burke
Date: Sun, 28 Nov 2021 19:17:53 -0500
Subject: [PATCH 38/81] flake8: whitespace cleanup
---
tests/test_image.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_image.py b/tests/test_image.py
index aad39e2..b746292 100644
--- a/tests/test_image.py
+++ b/tests/test_image.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_image():
t = Textile()
result = t.image('!/imgs/myphoto.jpg!:http://jsamsa.com')
@@ -17,5 +18,5 @@ def test_image():
t = Textile(rel='nofollow')
result = t.image('!/imgs/myphoto.jpg!:http://jsamsa.com')
expect = (''.format(t.uid))
+ '/>'.format(t.uid))
assert result == expect
From ffb01d17084abda9ebe18a0e0d379d289b189ae4 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:18:41 -0500
Subject: [PATCH 39/81] flake8: whitespace cleanup
---
tests/test_retrieve.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_retrieve.py b/tests/test_retrieve.py
index 10bd173..a416524 100644
--- a/tests/test_retrieve.py
+++ b/tests/test_retrieve.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_retrieve():
t = Textile()
id = t.shelve("foobar")
From d7f3f2a3c8e9fcd74f2c4a705c92c8f540c83d6c Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:22:20 -0500
Subject: [PATCH 40/81] flake8: whitespace cleanup
---
tests/test_textile.py | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/tests/test_textile.py b/tests/test_textile.py
index cc4ce84..a32fcbd 100644
--- a/tests/test_textile.py
+++ b/tests/test_textile.py
@@ -4,10 +4,12 @@
import re
import textile
+
def test_FootnoteReference():
html = textile.textile('YACC[1]')
assert re.search(r'^\tYACC ', 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 elsewhere. \n\n\t\n\n\t$', 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'^\tSee for details. \n\n\t$', 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> "
@@ -93,10 +97,12 @@ def test_restricted():
assert result == expect
+
def test_unicode_footnote():
html = textile.textile('текст[1]')
assert re.compile(r'^\tтекст $', 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'
expect = textile.Textile(get_sizes=True).parse(test)
assert result == expect
+
def test_endnotes_simple():
test = """Scientists say the moon is slowly shrinking[#my_first_label].\n\nnotelist!.\n\nnote#my_first_label Over the past billion years, about a quarter of the moon's 4.5 billion-year lifespan, it has shrunk about 200 meters (700 feet) in diameter."""
html = textile.textile(test)
@@ -135,6 +144,7 @@ def test_endnotes_simple():
result_re = re.compile(result_pattern)
assert result_re.search(html) is not None
+
def test_endnotes_complex():
test = """Tim Berners-Lee is one of the pioneer voices in favour of Net Neutrality[#netneutral] and has expressed the view that ISPs should supply "connectivity with no strings attached"[#netneutral!] [#tbl_quote]\n\nBerners-Lee admitted that the forward slashes ("//") in a web address were actually unnecessary. He told the newspaper that he could easily have designed URLs not to have the forward slashes. "... it seemed like a good idea at the time,"[#slashes]\n\nnote#netneutral. "Web creator rejects net tracking":http://news.bbc.co.uk/2/hi/technology/7613201.stm. BBC. 15 September 2008\n\nnote#tbl_quote. "Web inventor's warning on spy software":http://www.telegraph.co.uk/news/uknews/1581938/Web-inventor%27s-warning-on-spy-software.html. The Daily Telegraph (London). 25 May 2008\n\nnote#slashes. "Berners-Lee 'sorry' for slashes":http://news.bbc.co.uk/1/hi/technology/8306631.stm. BBC. 14 October 2009\n\nnotelist."""
html = textile.textile(test)
@@ -142,6 +152,7 @@ def test_endnotes_complex():
result_re = re.compile(result_pattern)
assert result_re.search(html) is not None
+
def test_endnotes_unreferenced_note():
test = """Scientists say[#lavader] the moon is quite small. But I, for one, don't believe them. Others claim it to be made of cheese[#aardman]. If this proves true I suspect we are in for troubled times[#apollo13] as people argue over their "share" of the moon's cheese. In the end, its limited size[#lavader] may prove problematic.\n\nnote#lavader(noteclass). "Proof of the small moon hypothesis":http://antwrp.gsfc.nasa.gov/apod/ap080801.html. Copyright(c) Laurent Laveder\n\nnote#aardman(#noteid). "Proof of a cheese moon":http://www.imdb.com/title/tt0104361\n\nnote#apollo13. After all, things do go "wrong":http://en.wikipedia.org/wiki/Apollo_13#The_oxygen_tank_incident.\n\nnotelist{padding:1em; margin:1em; border-bottom:1px solid gray}.\n\nnotelist{padding:1em; margin:1em; border-bottom:1px solid gray}:§^.\n\nnotelist{padding:1em; margin:1em; border-bottom:1px solid gray}:‡"""
html = textile.textile(test)
@@ -149,6 +160,7 @@ def test_endnotes_unreferenced_note():
result_re = re.compile(result_pattern, re.U)
assert result_re.search(html) is not None
+
def test_endnotes_malformed():
test = """Scientists say[#lavader] the moon is quite small. But I, for one, don't believe them. Others claim it to be made of cheese[#aardman]. If this proves true I suspect we are in for troubled times[#apollo13!] as people argue over their "share" of the moon's cheese. In the end, its limited size[#lavader] may prove problematic.\n\nnote#unused An unreferenced note.\n\nnote#lavader^ "Proof of the small moon hypothesis":http://antwrp.gsfc.nasa.gov/apod/ap080801.html. Copyright(c) Laurent Laveder\n\nnote#aardman^ "Proof of a cheese moon":http://www.imdb.com/title/tt0104361\n\nnote#apollo13^ After all, things do go "wrong":http://en.wikipedia.org/wiki/Apollo_13#The_oxygen_tank_incident.\n\nnotelist{padding:1em; margin:1em; border-bottom:1px solid gray}:α!+"""
html = textile.textile(test)
@@ -156,6 +168,7 @@ def test_endnotes_malformed():
result_re = re.compile(result_pattern, re.U)
assert result_re.search(html) is not None
+
def test_endnotes_undefined_note():
test = """Scientists say the moon is slowly shrinking[#my_first_label].\n\nnotelist!."""
html = textile.textile(test)
@@ -163,6 +176,7 @@ def test_endnotes_undefined_note():
result_re = re.compile(result_pattern)
assert result_re.search(html) is not None
+
def test_encode_url():
# I tried adding these as doctests, but the unicode tests weren't
# returning the correct results.
@@ -198,21 +212,25 @@ def test_encode_url():
eurl = t.encode_url(url)
assert eurl == result
+
def test_footnote_crosslink():
html = textile.textile('''See[2] for details, and later, reference it again[2].\n\nfn2^(footy#otherid)[en]. Here are the details.''')
searchstring = r'\tSee for details, and later, reference it again. \n\n\t$'
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'^\tSee for details. \n\n\t$'
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 link. '
assert re.compile(searchstring).search(html) is not None
+
def test_html5():
"""docstring for testHTML5"""
@@ -221,6 +239,7 @@ def test_html5():
expect = textile.textile(test, html_type="html5")
assert result == expect
+
def test_relURL():
t = textile.Textile()
t.restricted = True
From 76fda11365685ee425b82efa96d93cef1b813ed7 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:23:30 -0500
Subject: [PATCH 41/81] flake8: whitespace cleanup
---
tests/test_urls.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/test_urls.py b/tests/test_urls.py
index 39ff163..1cd09f9 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from textile import Textile
+
def test_urls():
t = Textile()
assert t.relURL("http://www.google.com/") == 'http://www.google.com/'
@@ -53,12 +54,14 @@ def test_urls():
expect = '\tA 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 = '\tdomain.tld '
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 Burke
Date: Sun, 28 Nov 2021 19:24:15 -0500
Subject: [PATCH 42/81] flake8: whitespace cleanup
---
tests/test_lists.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_lists.py b/tests/test_lists.py
index 4e85f4c..06d13c3 100644
--- a/tests/test_lists.py
+++ b/tests/test_lists.py
@@ -1,5 +1,6 @@
from textile import Textile
+
def test_lists():
t = Textile()
result = t.textileLists("* one\n* two\n* three")
From 391586aefe33e7acdb354f40547cc34f834f9b7d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:24:51 -0500
Subject: [PATCH 43/81] flake8: whitespace cleanup
---
tests/test_span.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/test_span.py b/tests/test_span.py
index d83530d..aab0574 100644
--- a/tests/test_span.py
+++ b/tests/test_span.py
@@ -1,10 +1,11 @@
from textile import Textile
+
def test_span():
t = Textile()
result = t.span("hello %(bob)span *strong* and **bold**% goodbye")
expect = ('hello span strong and '
- 'bold goodbye')
+ 'bold goodbye')
assert result == expect
result = t.span('%:http://domain.tld test%')
From d1cb4089abbaf07db1a173ba52a00b8ebb61f1e2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Sun, 28 Nov 2021 19:34:54 -0500
Subject: [PATCH 44/81] flake8: whitespace cleanup
---
tests/test_github_issues.py | 44 ++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 8 deletions(-)
diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py
index 2507e5f..c08d067 100644
--- a/tests/test_github_issues.py
+++ b/tests/test_github_issues.py
@@ -3,51 +3,60 @@
import textile
+
def test_github_issue_16():
result = textile.textile('"$":http://google.com "$":https://google.com "$":mailto:blackhole@sun.comet')
expect = '\tgoogle.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 = '\t'
assert result == expect
+
def test_github_issue_20():
text = 'This is a link to a ["Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)].'
result = textile.textile(text)
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. '''
+ '''
bar
-'''
+''')
result = textile.textile(text)
expect = '\txml example\n\n\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 = """\t\n\t\t- Folders with “:” in their names are displayed with a forward slash “/” instead. (Filed as #4581709, which was considered “normal behaviour” – quote: “Please note that Finder presents the ‘Carbon filesystem’ view, regardless of the underlying filesystem.”)
\n\t """
assert result == expect
+
def test_github_issue_28():
test = """So here I am porting my ancient "newspipe":newspipe "front-end":blog/2006/09/30/0950 to "Snakelets":Snakelets and "Python":Python, and I've just trimmed down over 20 lines of "PHP":PHP down to essentially one line of "BeautifulSoup":BeautifulSoup retrieval:
@@ -80,23 +89,26 @@ def parseWapProfile(self, url):
\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 = '\tTëxtíle '
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'
assert result == expect
+
def test_github_issue_36():
text = '"Chögyam Trungpa":https://www.google.com/search?q=Chögyam+Trungpa'
result = textile.textile(text)
expect = '\tChögyam Trungpa '
assert result == expect
+
def test_github_issue_37():
text = '# xxx\n# yyy\n*blah*'
result = textile.textile(text)
@@ -118,24 +130,28 @@ def test_github_issue_37():
\t'''
assert result == expect
+
def test_github_issue_40():
text = '\r\n'
result = textile.textile(text)
expect = '\r\n'
assert result == expect
+
def test_github_issue_42():
text = '!./image.png!'
result = textile.textile(text)
expect = '\t'
assert result == expect
+
def test_github_issue_43():
text = 'pre. smart ‘quotes’ are not smart!'
result = textile.textile(text)
expect = '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 = '\ttest '
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 = '\tlink '
assert result == expect
+
def test_github_issue_50():
"""Incorrect wrap code with Java generics in pre"""
test = ('pre.. public class Tynopet {}\n\nfinal '
@@ -189,6 +209,7 @@ def test_github_issue_50():
'ArrayList<>();')
assert result == expect
+
def test_github_issue_51():
"""Link build with $ sign without "http" prefix broken."""
test = '"$":www.google.com.br'
@@ -196,6 +217,7 @@ def test_github_issue_51():
expect = '\twww.google.com.br '
assert result == expect
+
def test_github_issue_52():
"""Table build without space after aligment raise a AttributeError."""
test = '|=.First Header |=. Second Header |'
@@ -205,6 +227,7 @@ def test_github_issue_52():
'\n\t\t\n\t')
assert result == expect
+
def test_github_issue_55():
"""Incorrect handling of quote entities in extended pre block"""
test = ('pre.. this is the first line\n\nbut "quotes" in an extended pre '
@@ -258,15 +281,17 @@ def test_github_issue_55():
'return configs;\n}\n}')
assert result == expect
+
def test_github_issue_56():
"""Empty description lists throw error"""
result = textile.textile("- :=\n-")
expect = '\n '
assert result == expect
+
def test_github_pull_61():
"""Fixed code block multiline encoding on quotes/span"""
- test = '''bc.. This is some TEXT inside a "Code BLOCK"
+ test = ('''bc.. This is some TEXT inside a "Code BLOCK"
{
if (JSON) {
@@ -275,11 +300,12 @@ def test_github_pull_61():
}
}
-Back to 10-4 CAPS
+Back to 10-4 CAPS '''
+ '''
p.. Some multiline Paragragh
-Here is some output!!! "Some" CAPS'''
+Here is some output!!! "Some" CAPS''')
expect = '''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 45/81] 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 5f6e501..57b2d5f 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 46/81] 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 0f5d019..b07712f 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 47/81] 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 43f85e3..3a3c0a9 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 48/81] 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 56b0d27..ed50ad5 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 49/81] 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 9235e03..a7db99a 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 50/81] 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 0a89b43..e7d9d88 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 51/81] 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 846b927..e9fc027 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 52/81] 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 d3cfcd7..8a22d4f 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 53/81] 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 c973ee7..5ac2ea4 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 54/81] 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 0a3cb0d..1ea34e9 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 55/81] 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 063ed3e..5b2b7e3 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 56/81] 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 5b2b7e3..12dae55 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\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 57/81] 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 7f386a9..a6e88f8 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 58/81] turn flake8 warnings and errors back on
---
.flake8 | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.flake8 b/.flake8
index 07c24d1..9f8ccc3 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 59/81] 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 437820d..f82f4c2 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 60/81] 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 f82f4c2..5ba1e86 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 61/81] 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 5ba1e86..47ce8cf 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 62/81] 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 47ce8cf..0db7ea8 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 7715a78def0bcfe56ea90194908950d9d01da5e7 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 63/81] 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 118c2fb..70953c0 100644
--- a/setup.py
+++ b/setup.py
@@ -29,11 +29,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 3203e30104390543aa5124438a1a2eac6f853c06 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:18:12 -0400
Subject: [PATCH 64/81] 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 0db7ea8..f488521 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 66312bdc92c1c74fc1b785468c3993450370d0fa Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:22:46 -0400
Subject: [PATCH 65/81] 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 f488521..935d688 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 964b71c42543afa92c15abd0463795f7f360f06d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:26:09 -0400
Subject: [PATCH 66/81] 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 57b2d5f..5e6ab79 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 b3c0341656a938e4031e062a3d9a490ab41eae90 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:36:54 -0400
Subject: [PATCH 67/81] 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 935d688..96bfd6d 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 9c7da86753dc2852e18f01ea75778d2a513f2fd3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:41:42 -0400
Subject: [PATCH 68/81] 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 96bfd6d..c4d4aab 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 d58b58b0ba7bc83d0d6abf9aa663420845b8fdbe Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:54:17 -0400
Subject: [PATCH 69/81] 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 c4d4aab..cc2690b 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 e5e2e5c40b1604658c85cf3c1622b490bc42bc42 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 11:59:57 -0400
Subject: [PATCH 70/81] 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 cc2690b..8cfec1f 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 3a99e730198a45bcd2b921e8cbf1d0ded4136676 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 12:07:53 -0400
Subject: [PATCH 71/81] 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 8cfec1f..44a7c91 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 abcaaaa6af49d7cd229bd5e2d9f14c5384d606bc Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 12:58:55 -0400
Subject: [PATCH 72/81] update badge to github actions
---
README.textile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.textile b/README.textile
index 98f4fbd..797516c 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 7112abfcb0dd7fd09f9abb5a3f95b11ea80310f2 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 13:01:08 -0400
Subject: [PATCH 73/81] 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 61dc0f0..466b706 100644
--- a/tests/fixtures/README.txt
+++ b/tests/fixtures/README.txt
@@ -1,4 +1,4 @@
-
+
python-textile
From 5cb14853894aca092d089b508775e7364597fb12 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 13:59:53 -0400
Subject: [PATCH 74/81] update minimum supported python version
---
setup.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index cbbb774..b14b9a6 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 425afff8e67f396ec1f220c9978e2a2e4b2d18e3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:15:18 -0400
Subject: [PATCH 75/81] 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 6fba73e..ec724a2 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 766c76733eee9094c86476adf85088f23c971b23 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:17:00 -0400
Subject: [PATCH 76/81] 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 ec724a2..1d758cc 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 9951604d2d6c665d613935fe89ed5a98d62f6cf3 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:23:05 -0400
Subject: [PATCH 77/81] 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 1d758cc..6fba73e 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 ba2424904042cb2e02ba597d121937cff70eb1e5 Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:23:21 -0400
Subject: [PATCH 78/81] 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 44a7c91..e932372 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 05e3bca4d6b8cf902f7c9ec795d8be7a81748f8e Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:25:23 -0400
Subject: [PATCH 79/81] 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 e932372..f4795b2 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 05bb7bf524797a2cd790fcd20ec43470714dccda Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:30:29 -0400
Subject: [PATCH 80/81] 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 f4795b2..047e6d8 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 f93078826204732d10ec806eec3464104812985d Mon Sep 17 00:00:00 2001
From: Dennis Burke
Date: Mon, 5 Aug 2024 14:32:17 -0400
Subject: [PATCH 81/81] 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 047e6d8..14ced37 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
| | |