Skip to content

Commit

Permalink
Merge branch 'alfonsrv-fix-pr-118' into jsm28-list-indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVonB committed Nov 24, 2024
2 parents 9202027 + 7ff4d83 commit 1978083
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ escape_underscores
Defaults to ``True``.

escape_misc
If set to ``False``, do not escape miscellaneous punctuation characters
If set to ``True``, escape miscellaneous punctuation characters
that sometimes have Markdown significance in text.
Defaults to ``True``.
Defaults to ``False``.

keep_inline_images_in
Images are converted to their alt-text when the images are located inside
Expand Down
2 changes: 1 addition & 1 deletion markdownify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class DefaultOptions:
default_title = False
escape_asterisks = True
escape_underscores = True
escape_misc = True
escape_misc = False
heading_style = UNDERLINED
keep_inline_images_in = []
newline_style = SPACES
Expand Down
80 changes: 40 additions & 40 deletions tests/test_escaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_underscore():


def test_xml_entities():
assert md('&') == r'\&'
assert md('&', escape_misc=True) == r'\&'


def test_named_entities():
Expand All @@ -27,49 +27,49 @@ def test_hexadecimal_entities():


def test_single_escaping_entities():
assert md('&') == r'\&'
assert md('&', escape_misc=True) == r'\&'


def test_misc():
# ignore the bs4 warning that "1.2" or "*" looks like a filename
warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning)

assert md('\\*') == r'\\\*'
assert md('&lt;foo>') == r'\<foo\>'
assert md('# foo') == r'\# foo'
assert md('#5') == r'#5'
assert md('5#') == '5#'
assert md('####### foo') == r'####### foo'
assert md('> foo') == r'\> foo'
assert md('~~foo~~') == r'\~\~foo\~\~'
assert md('foo\n===\n') == 'foo\n\\=\\=\\=\n'
assert md('---\n') == '\\---\n'
assert md('- test') == r'\- test'
assert md('x - y') == r'x \- y'
assert md('test-case') == 'test-case'
assert md('x-') == 'x-'
assert md('-y') == '-y'
assert md('+ x\n+ y\n') == '\\+ x\n\\+ y\n'
assert md('`x`') == r'\`x\`'
assert md('[text](link)') == r'\[text](link)'
assert md('1. x') == r'1\. x'
# assert md('1<span>.</span> x') == r'1\. x'
assert md('<span>1.</span> x') == r'1\. x'
assert md(' 1. x') == r' 1\. x'
assert md('123456789. x') == r'123456789\. x'
assert md('1234567890. x') == r'1234567890. x'
assert md('A1. x') == r'A1. x'
assert md('1.2') == r'1.2'
assert md('not a number. x') == r'not a number. x'
assert md('1) x') == r'1\) x'
# assert md('1<span>)</span> x') == r'1\) x'
assert md('<span>1)</span> x') == r'1\) x'
assert md(' 1) x') == r' 1\) x'
assert md('123456789) x') == r'123456789\) x'
assert md('1234567890) x') == r'1234567890) x'
assert md('(1) x') == r'(1) x'
assert md('A1) x') == r'A1) x'
assert md('1)x') == r'1)x'
assert md('not a number) x') == r'not a number) x'
assert md('|not table|') == r'\|not table\|'
assert md('\\*', escape_misc=True) == r'\\\*'
assert md('&lt;foo>', escape_misc=True) == r'\<foo\>'
assert md('# foo', escape_misc=True) == r'\# foo'
assert md('#5', escape_misc=True) == r'#5'
assert md('5#', escape_misc=True) == '5#'
assert md('####### foo', escape_misc=True) == r'####### foo'
assert md('> foo', escape_misc=True) == r'\> foo'
assert md('~~foo~~', escape_misc=True) == r'\~\~foo\~\~'
assert md('foo\n===\n', escape_misc=True) == 'foo\n\\=\\=\\=\n'
assert md('---\n', escape_misc=True) == '\\---\n'
assert md('- test', escape_misc=True) == r'\- test'
assert md('x - y', escape_misc=True) == r'x \- y'
assert md('test-case', escape_misc=True) == 'test-case'
assert md('x-', escape_misc=True) == 'x-'
assert md('-y', escape_misc=True) == '-y'
assert md('+ x\n+ y\n', escape_misc=True) == '\\+ x\n\\+ y\n'
assert md('`x`', escape_misc=True) == r'\`x\`'
assert md('[text](link)', escape_misc=True) == r'\[text](link)'
assert md('1. x', escape_misc=True) == r'1\. x'
# assert md('1<span>.</span> x', escape_misc=True) == r'1\. x'
assert md('<span>1.</span> x', escape_misc=True) == r'1\. x'
assert md(' 1. x', escape_misc=True) == r' 1\. x'
assert md('123456789. x', escape_misc=True) == r'123456789\. x'
assert md('1234567890. x', escape_misc=True) == r'1234567890. x'
assert md('A1. x', escape_misc=True) == r'A1. x'
assert md('1.2', escape_misc=True) == r'1.2'
assert md('not a number. x', escape_misc=True) == r'not a number. x'
assert md('1) x', escape_misc=True) == r'1\) x'
# assert md('1<span>)</span> x', escape_misc=True) == r'1\) x'
assert md('<span>1)</span> x', escape_misc=True) == r'1\) x'
assert md(' 1) x', escape_misc=True) == r' 1\) x'
assert md('123456789) x', escape_misc=True) == r'123456789\) x'
assert md('1234567890) x', escape_misc=True) == r'1234567890) x'
assert md('(1) x', escape_misc=True) == r'(1) x'
assert md('A1) x', escape_misc=True) == r'A1) x'
assert md('1)x', escape_misc=True) == r'1)x'
assert md('not a number) x', escape_misc=True) == r'not a number) x'
assert md('|not table|', escape_misc=True) == r'\|not table\|'
assert md(r'\ &lt;foo> &amp;amp; | ` `', escape_misc=False) == r'\ <foo> &amp; | ` `'

0 comments on commit 1978083

Please sign in to comment.