Skip to content

Commit

Permalink
flake8 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Aug 6, 2024
1 parent 6bcdf59 commit abb0581
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@
'\t<h1>Two line with <strong>strong</strong><br />\nheading</h1>'),
# Non-standalone ampersands should not be escaped
(("&#8220;<span lang=\"en\">test</span>&#8221;\n\n"
"&#x201c;<span lang=\"en\">test</span>&#x201d;\n\n"
"&nbsp;<span lang=\"en\">test</span>&nbsp;\n"),
"&#x201c;<span lang=\"en\">test</span>&#x201d;\n\n"
"&nbsp;<span lang=\"en\">test</span>&nbsp;\n"),
("\t<p>&#8220;<span lang=\"en\">test</span>&#8221;</p>\n\n"
"\t<p>&#x201c;<span lang=\"en\">test</span>&#x201d;</p>\n\n"
"\t<p>&nbsp;<span lang=\"en\">test</span>&nbsp;</p>")),
Expand Down
14 changes: 4 additions & 10 deletions textile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ def __init__(self, restricted=False, lite=False, noimage=False,
self.refIndex = 0
self.block_tags = block_tags

cur = r''
if regex_snippets['cur']: # pragma: no branch
cur = r'(?:[{0}]{1}*)?'.format(regex_snippets['cur'],
regex_snippets['space'])

self.glyph_replacers = make_glyph_replacers(
html_type, self.uid, self.glyph_definitions)

Expand Down Expand Up @@ -424,7 +419,7 @@ def fPBr(self, m):
re.compile(r"<br[ ]*/?>{0}*\n(?![{0}|])".format(regex_snippets['space']),
re.I)
.sub("\n", content))
content = re.compile(r"\n(?![\s|])").sub('<br />',content)
content = re.compile(r"\n(?![\s|])").sub('<br />', content)
return '<{0}{1}>{2}{3}'.format(m.group(1), m.group(2), content, m.group(4))

def doBr(self, match):
Expand Down Expand Up @@ -1122,11 +1117,11 @@ def storeTags(self, opentag, closetag=''):
tags = {}
self.refIndex += 1
self.refCache[self.refIndex] = opentag
tags['open'] = self.uid + str(self.refIndex) + ':ospan ';
tags['open'] = self.uid + str(self.refIndex) + ':ospan '

self.refIndex += 1
self.refCache[self.refIndex] = closetag
tags['close'] = ' ' + self.uid + str(self.refIndex) + ':cspan';
tags['close'] = ' ' + self.uid + str(self.refIndex) + ':cspan'
return tags

def retrieveTags(self, text):
Expand All @@ -1139,7 +1134,6 @@ def retrieveTags(self, text):
def fRetrieveTags(self, match):
return self.refCache[int(match.group('token'))]


def image(self, text):
pattern = re.compile(r"""
(?:[\[{{])? # pre
Expand Down Expand Up @@ -1363,7 +1357,7 @@ def fNoteLists(self, match):
content)
else:
li = ('\t\t<li{0}>{1} Undefined Note [#{2}].</li>'
).format(atts, links, info['seq'])
).format(atts, links, info['seq'])
o.append(li)
if '+' == extras and self.unreferencedNotes:
for seq, info in self.unreferencedNotes.items():
Expand Down
2 changes: 1 addition & 1 deletion textile/objects/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from textile.regex_strings import (align_re_s, cls_re_s, regex_snippets,
table_span_re_s, valign_re_s, pnct_re_s)
from textile.utils import generate_tag, parse_attributes
from textile.utils import generate_tag, parse_attributes, pba

try:
import regex as re
Expand Down
4 changes: 2 additions & 2 deletions textile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
# else the regex module doesn't properly match pre-s. It only matches the
# p in pre.
re.compile(r'<(pre|p|blockquote|div|form|table|ul|ol|dl|h[1-6])[^>]*?>.*</\1>',
re.S),
re.S),
re.compile(r'<(hr|br)[^>]*?/>'),
re.compile(r'<!--.*?-->'),
)


def decode_high(text):
"""Decode encoded HTML entities."""
text = '&#{0};'.format(text)
Expand Down Expand Up @@ -88,7 +89,6 @@ def has_raw_text(text):
return r != ''



def is_rel_url(url):
"""Identify relative urls."""
(scheme, netloc) = urlparse(url)[0:2]
Expand Down

0 comments on commit abb0581

Please sign in to comment.