# HG changeset patch # User Marcin Kuzminski # Date 2016-06-28 22:51:18 # Node ID 2f438a3b1706fee500f70ac01da6651865d2749c # Parent 2ddbbd79d88cbc727d0908d47d768529b63d0b88 markdown: enable full githubFlavoredMarkdown diff --git a/rhodecode/lib/markdown_ext.py b/rhodecode/lib/markdown_ext.py --- a/rhodecode/lib/markdown_ext.py +++ b/rhodecode/lib/markdown_ext.py @@ -22,6 +22,8 @@ import re import markdown +from mdx_gfm import GithubFlavoredMarkdownExtension # noqa + class FlavoredCheckboxExtension(markdown.Extension): @@ -65,8 +67,6 @@ class FlavoredCheckboxPostprocessor(mark return html.replace(before, after) - - # Global Vars URLIZE_RE = '(%s)' % '|'.join([ r'<(?:f|ht)tps?://[^>]*>', @@ -75,6 +75,7 @@ URLIZE_RE = '(%s)' % '|'.join([ r'[^(<\s]+\.(?:com|net|org)\b', ]) + class UrlizePattern(markdown.inlinepatterns.Pattern): """ Return a link Element given an autolink (`http://example/com`). """ def handleMatch(self, m): diff --git a/rhodecode/lib/markup_renderer.py b/rhodecode/lib/markup_renderer.py --- a/rhodecode/lib/markup_renderer.py +++ b/rhodecode/lib/markup_renderer.py @@ -33,7 +33,8 @@ from docutils.core import publish_parts from docutils.parsers.rst import directives import markdown -from rhodecode.lib.markdown_ext import FlavoredCheckboxExtension, UrlizeExtension +from rhodecode.lib.markdown_ext import ( + UrlizeExtension, GithubFlavoredMarkdownExtension) from rhodecode.lib.utils2 import safe_unicode, md5_safe, MENTIONS_REGEX log = logging.getLogger(__name__) @@ -147,9 +148,7 @@ class MarkupRenderer(object): # the safe_mode=True parameter of the markdown method. extensions = ['codehilite', 'extra', 'def_list', 'sane_lists'] if flavored: - extensions.append('nl2br') - extensions.append(FlavoredCheckboxExtension()) - extensions.append(UrlizeExtension()) + extensions.append(GithubFlavoredMarkdownExtension()) if mentions: mention_pat = re.compile(MENTIONS_REGEX)