Skip to content

Commit

Permalink
Update Python dependency markdown2 to v2.3.9 (#8088)
Browse files Browse the repository at this point in the history
* Update Python dependency markdown2 to v2.3.9

* mvt update

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Dario <[email protected]>
  • Loading branch information
3 people authored May 12, 2020
1 parent 6c0dc05 commit f785193
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
64 changes: 49 additions & 15 deletions ext/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
# not yet sure if there implications with this. Compare 'pydoc sre'
# and 'perldoc perlre'.

__version_info__ = (2, 3, 8)
__version_info__ = (2, 3, 9)
__version__ = '.'.join(map(str, __version_info__))
__author__ = "Trent Mick"

Expand Down Expand Up @@ -200,7 +200,10 @@ class Markdown(object):
titles = None
html_blocks = None
html_spans = None
html_removed_text = "[HTML_REMOVED]" # for compat with markdown.py
html_removed_text = "{(#HTML#)}" # placeholder removed text that does not trigger bold
html_removed_text_compat = "[HTML_REMOVED]" # for compat with markdown.py

_toc = None

# Used to track when we're inside an ordered or unordered list
# (see _ProcessListItems() for details):
Expand All @@ -217,6 +220,7 @@ def __init__(self, html4tags=False, tab_width=4, safe_mode=None,
else:
self.empty_element_suffix = " />"
self.tab_width = tab_width
self.tab = tab_width * " "

# For compatibility with earlier markdown2.py and with
# markdown.py's safe_mode being a boolean,
Expand Down Expand Up @@ -273,6 +277,7 @@ def reset(self):
self._count_from_header_id = defaultdict(int)
if "metadata" in self.extras:
self.metadata = {}
self._toc = None

# Per <https://developer.mozilla.org/en-US/docs/HTML/Element/a> "rel"
# should only be used in <a> tags with an "href" attribute.
Expand Down Expand Up @@ -384,6 +389,8 @@ def convert(self, text):

if self.safe_mode:
text = self._unhash_html_spans(text)
# return the removed text warning to its markdown.py compatible form
text = text.replace(self.html_removed_text, self.html_removed_text_compat)

if "nofollow" in self.extras:
text = self._a_nofollow.sub(r'<\1 rel="nofollow"\2', text)
Expand Down Expand Up @@ -1070,23 +1077,43 @@ def _do_tables(self, text):

def _wiki_table_sub(self, match):
ttext = match.group(0).strip()
# print 'wiki table: %r' % match.group(0)
# print('wiki table: %r' % match.group(0))
rows = []
for line in ttext.splitlines(0):
line = line.strip()[2:-2].strip()
row = [c.strip() for c in re.split(r'(?<!\\)\|\|', line)]
rows.append(row)
# from pprint import pprint
# pprint(rows)
hlines = ['<table%s>' % self._html_class_str_from_tag('table'), '<tbody>']
for row in rows:
hrow = ['<tr>']
for cell in row:
hrow.append('<td>')
hrow.append(self._run_span_gamut(cell))
hrow.append('</td>')
hrow.append('</tr>')
hlines.append(''.join(hrow))
hlines += ['</tbody>', '</table>']
hlines = []

def add_hline(line, indents=0):
hlines.append((self.tab * indents) + line)

def format_cell(text):
return self._run_span_gamut(re.sub(r"^\s*~", "", cell).strip(" "))

add_hline('<table%s>' % self._html_class_str_from_tag('table'))
# Check if first cell of first row is a header cell. If so, assume the whole row is a header row.
if rows and rows[0] and re.match(r"^\s*~", rows[0][0]):
add_hline('<thead>', 1)
add_hline('<tr>', 2)
for cell in rows[0]:
add_hline("<th>{}</th>".format(format_cell(cell)), 3)
add_hline('</tr>', 2)
add_hline('</thead>', 1)
# Only one header row allowed.
rows = rows[1:]
# If no more rows, don't create a tbody.
if rows:
add_hline('<tbody>', 1)
for row in rows:
add_hline('<tr>', 2)
for cell in row:
add_hline('<td>{}</td>'.format(format_cell(cell)), 3)
add_hline('</tr>', 2)
add_hline('</tbody>', 1)
add_hline('</table>')
return '\n'.join(hlines) + '\n'

def _do_wiki_tables(self, text):
Expand Down Expand Up @@ -1351,6 +1378,11 @@ def _do_links(self, text):
continue
link_text = text[start_idx+1:p]

# Fix for issue 341 - Injecting XSS into link text
if self.safe_mode:
link_text = self._hash_html_spans(link_text)
link_text = self._unhash_html_spans(link_text)

# Possibly a footnote ref?
if "footnotes" in self.extras and link_text.startswith("^"):
normed_id = re.sub(r'\W', '-', link_text[1:])
Expand Down Expand Up @@ -1509,7 +1541,6 @@ def header_id_from_text(self, text, prefix, n):

return header_id

_toc = None
def _toc_add_entry(self, level, id, name):
if level > self._toc_depth:
return
Expand Down Expand Up @@ -2141,11 +2172,14 @@ def _encode_amps_and_angles(self, text):
text = self._naked_gt_re.sub('&gt;', text)
return text

_incomplete_tags_re = re.compile("<(/?\w+[\s/]+?)")
_incomplete_tags_re = re.compile("<(/?\w+?(?!\w).+?[\s/]+?)")

def _encode_incomplete_tags(self, text):
if self.safe_mode not in ("replace", "escape"):
return text

if text.endswith(">"):
return text # this is not an incomplete tag, this is a link in the form <http://x.y.z>

return self._incomplete_tags_re.sub("&lt;\\1", text)

Expand Down
2 changes: 1 addition & 1 deletion ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ext | `imdbpie` | [5.6.4](https://pypi.org/project/imdbpie/5.6.4/) | **`medusa`*
ext | `jsonrpclib-pelix` | [0.4.1](https://pypi.org/project/jsonrpclib-pelix/0.4.1/) | **`medusa`** | Module: `jsonrpclib`
ext | `knowit` | [eea9ac1](https://github.com/ratoaq2/knowit/tree/eea9ac18e38c930230cf81b5dca4a9af9fb10d4e) | **`medusa`** | -
ext | `Mako` | [1.1.2](https://pypi.org/project/Mako/1.1.2/) | **`medusa`** | Module: `mako`
ext | <code><b>markdown2</b>.py</code> | [2.3.8](https://pypi.org/project/markdown2/2.3.8/) | **`medusa`** | -
ext | <code><b>markdown2</b>.py</code> | [2.3.9](https://pypi.org/project/markdown2/2.3.9/) | **`medusa`** | -
ext | `MarkupSafe` | [1.1.1](https://pypi.org/project/MarkupSafe/1.1.1/) | `Mako` | Module: `markupsafe`
ext | `msgpack` | [0.5.6](https://pypi.org/project/msgpack/0.5.6/) | `CacheControl` | -
ext | `oauthlib` | [3.0.0](https://pypi.org/project/oauthlib/3.0.0/) | `requests-oauthlib` | -
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ imdbpie==5.6.4
jsonrpclib-pelix==0.4.1
knowit @ https://codeload.github.com/ratoaq2/knowit/tar.gz/eea9ac18e38c930230cf81b5dca4a9af9fb10d4e#egg=knowit
Mako==1.1.2
markdown2==2.3.8
markdown2==2.3.9
profilehooks==1.11.2
PyGithub==1.45
PyJWT==1.7.1
Expand Down

0 comments on commit f785193

Please sign in to comment.