Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead escape code and require Python 3.5 which drops Py 3.7 #2249

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>'
)
Loading