Skip to content

Commit

Permalink
Set escape_misc to False by default to improve backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsrv authored Oct 9, 2024
1 parent 964d89f commit 7ff4d83
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 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 @@ -76,7 +76,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
31 changes: 16 additions & 15 deletions tests/test_escaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ def test_single_escaping_entities():


def text_misc():
assert md('\\*') == r'\\\*'
assert md('<foo>') == r'\<foo\>'
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('+ 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('not a number. x') == r'not a number. 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('<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~~', 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('+ 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('not a number. x', escape_misc=True) == r'not a number. 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'\ <foo> &amp;amp; | ` `', escape_misc=False) == r'\ <foo> &amp; | ` `'
assert md(r'\ <foo> &amp;amp; | ` `') == r'\ <foo> &amp; | ` `' # assert `False` is default

0 comments on commit 7ff4d83

Please sign in to comment.