Add line through support to Markdown

This commit is contained in:
Gregory Soutade 2014-01-31 19:28:25 +01:00
parent 44e4729a23
commit dab80993f2
3 changed files with 14 additions and 4 deletions

View File

@ -1613,14 +1613,17 @@ class Markdown(object):
_em_re = re.compile(r"(\*|_)(?=\S)(.+?)(?<=\S)\1", re.S)
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S)
_code_friendly_em_re = re.compile(r"\*(?=\S)(.+?)(?<=\S)\*", re.S)
_code_friendly_line_re = re.compile(r"\~\~(?=\S)(.+?)(?<=\S)\~\~", re.S)
def _do_italics_and_bold(self, text):
# <strong> must go first:
if "code-friendly" in self.extras:
text = self._code_friendly_strong_re.sub(r"<strong>\1</strong>", text)
text = self._code_friendly_em_re.sub(r"<em>\1</em>", text)
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
else:
text = self._strong_re.sub(r"<strong>\2</strong>", text)
text = self._em_re.sub(r"<em>\2</em>", text)
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
return text
# "smarty-pants" extra: Very liberal in interpreting a single prime as an

View File

@ -99,7 +99,7 @@
</div>
</div>
<div class="footer">
Copyright © 2010-2013 Grégory Soutadé.<br/>
Copyright © 2010-2014 Grégory Soutadé.<br/>
All Rights Reserved.
</div>
</div>

View File

@ -74,6 +74,12 @@ def have_I_right(request, blog_id=None, post_id=None, must_be_superuser=False):
return (b, p)
def to_unicode(s):
if type(s) == unicode:
return s
else:
return unicode(s, 'utf-8')
def createNavigationBar(blog_id, cur_page, nb_pages):
if nb_pages == 0: return ''
@ -774,9 +780,10 @@ def add_comment(request, post_id, parent_id):
response['Cache-Control'] = 'no-store, no-cache, must-revalidate'
response['Expires'] = 'Thu, 01 Jan 1970 00:00:00 GMT'
response.set_cookie('author', request.POST['author'], domain=blog.name, secure=True, httponly=False);
if mel != '':
response.set_cookie('email', mel, domain=blog.name, secure=True, httponly=False);
# This cause problems with non-ascii characters, disabled until Python 3.
# response.set_cookie('author', to_unicode(request.POST['author']), domain=blog.name, secure=True, httponly=False);
# if mel != '':
# response.set_cookie('email', mel, 'utf-8', domain=blog.name, secure=True, httponly=False);
return response