diff --git a/README.rst b/README.rst index 55ea7cf..98473c6 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/markdownify/__init__.py b/markdownify/__init__.py index cd66a39..3476223 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -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 diff --git a/tests/test_escaping.py b/tests/test_escaping.py index eaef77d..91eb4b1 100644 --- a/tests/test_escaping.py +++ b/tests/test_escaping.py @@ -29,19 +29,20 @@ def test_single_escaping_entities(): def text_misc(): - assert md('\\*') == r'\\\*' - assert md('') == r'\' - 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('', 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\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'\ & | ` `', escape_misc=False) == r'\ & | ` `' + assert md(r'\ & | ` `') == r'\ & | ` `' # assert `False` is default