markdown: Update regex for strikethrough.

This uses the correct regex for strikethrough. Also, added
a test to make sure that strikethrough works when it contains
link with whitespace.

Fixes #7596.
This commit is contained in:
akashnimare 2017-12-22 17:21:08 +05:30 committed by showell
parent dd406e87e9
commit ef51a39552
2 changed files with 7 additions and 1 deletions

View File

@ -188,6 +188,12 @@
"expected_output": "<p>I <del> like software </del> love hardware</p>",
"text_content": "I like software love hardware"
},
{
"name": "strikthrough_link",
"input": "~~test http://xx.xx link~~",
"expected_output": "<p><del>test <a href=\"http://xx.xx\" target=\"_blank\" title=\"http://xx.xx\">http://xx.xx</a> link</del></p>",
"text_content": "test http://xx.xx link"
},
{
"name": "underscore_disabled",
"input": "_foo_",

View File

@ -1395,7 +1395,7 @@ class Bugdown(markdown.Extension):
# Custom strikethrough syntax: ~~foo~~
md.inlinePatterns.add('del',
markdown.inlinepatterns.SimpleTagPattern(
r'(?<!~)(\~\~)([^~{0}\n]+?)\2(?!~)', 'del'), '>strong')
r'(?<!~)(\~\~)([^~\n]+?)(\~\~)(?!~)', 'del'), '>strong')
# Text inside ** must start and end with a word character
# it need for things like "const char *x = (char *)y"