Skip to content

Commit

Permalink
Remove dead escape code and require Python 3.5 which drops Py 3.7 (#2249
Browse files Browse the repository at this point in the history
)
  • Loading branch information
facelessuser authored Nov 24, 2023
1 parent e882b8e commit a48b616
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
18 changes: 0 additions & 18 deletions pymdownx/escapeall.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"""
from markdown import Extension
from markdown.inlinepatterns import InlineProcessor, SubstituteTagInlineProcessor
from markdown.postprocessors import Postprocessor
from markdown import util as md_util
import re
from . import util

# We need to ignore these as they are used in Markdown processing
Expand All @@ -35,7 +33,6 @@
ESCAPE_RE = r'\\(.)'
ESCAPE_NO_NL_RE = r'\\([^\n])'
HARDBREAK_RE = r'\\\n'
UNESCAPE_PATTERN = re.compile(r'%s(\d+)%s' % (md_util.STX, md_util.ETX))


class EscapeAllPattern(InlineProcessor):
Expand Down Expand Up @@ -68,20 +65,6 @@ def handleMatch(self, m, data):
return escape, m.start(0), m.end(0)


class EscapeAllPostprocessor(Postprocessor):
"""Post processor to strip out unwanted content."""

def unescape(self, m):
"""Unescape the escaped chars."""

return util.get_char(int(m.group(1)))

def run(self, text):
"""Search document for escaped chars."""

return UNESCAPE_PATTERN.sub(self.unescape, text)


class EscapeAllExtension(Extension):
"""Extension that allows you to escape everything."""

Expand Down Expand Up @@ -111,7 +94,6 @@ def extendMarkdown(self, md):
180
)

md.postprocessors.register(EscapeAllPostprocessor(md), "unescape", 10)
if config['hardbreak']:
md.inlinePatterns.register(SubstituteTagInlineProcessor(HARDBREAK_RE, 'br'), "hardbreak", 5.1)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dynamic = [
]

dependencies = [
"Markdown>=3.2",
"Markdown>=3.5",
"pyyaml"
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_extensions/test_blocks/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def test_html_and_html(self):
)

def test_html_and_script(self):
"""Test inline format that script."""
"""Test inline format with script."""

self.check_markdown(
R'''
Expand Down
8 changes: 8 additions & 0 deletions tests/test_extensions/test_escapeall.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ def test_html_special_char_amp(self):
r'This \& that',
'<p>This &amp; that</p>'
)

def test_normal_escape(self):
"""Test normal escapes."""

self.check_markdown(
r'This & \that',
'<p>This &amp; that</p>'
)

0 comments on commit a48b616

Please sign in to comment.