From dab80993f2b187f61d48db82981f0874b321c7a2 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Fri, 31 Jan 2014 19:28:25 +0100 Subject: [PATCH] Add line through support to Markdown --- generators/markdown2.py | 3 +++ sites/blog.soutade.fr/about.html | 2 +- views.py | 13 ++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/generators/markdown2.py b/generators/markdown2.py index 2f0dee2..6cf850d 100644 --- a/generators/markdown2.py +++ b/generators/markdown2.py @@ -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): # must go first: if "code-friendly" in self.extras: text = self._code_friendly_strong_re.sub(r"\1", text) text = self._code_friendly_em_re.sub(r"\1", text) + text = self._code_friendly_line_re.sub(r"\1", text) else: text = self._strong_re.sub(r"\2", text) text = self._em_re.sub(r"\2", text) + text = self._code_friendly_line_re.sub(r"\1", text) return text # "smarty-pants" extra: Very liberal in interpreting a single prime as an diff --git a/sites/blog.soutade.fr/about.html b/sites/blog.soutade.fr/about.html index b39a3e7..af06a41 100755 --- a/sites/blog.soutade.fr/about.html +++ b/sites/blog.soutade.fr/about.html @@ -99,7 +99,7 @@ diff --git a/views.py b/views.py index e4a3f8f..0348cdc 100644 --- a/views.py +++ b/views.py @@ -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