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 @@ -20,7 +20,55 @@ import markdown -from mdx_gfm import GithubFlavoredMarkdownExtension # pragma: no cover +from markdown.extensions import Extension +from markdown.extensions.fenced_code import FencedCodeExtension +from markdown.extensions.smart_strong import SmartEmphasisExtension +from markdown.extensions.tables import TableExtension +from markdown.extensions.nl2br import Nl2BrExtension + +import gfm + + +class GithubFlavoredMarkdownExtension(Extension): + """ + An extension that is as compatible as possible with GitHub-flavored + Markdown (GFM). + + This extension aims to be compatible with the variant of GFM that GitHub + uses for Markdown-formatted gists and files (including READMEs). This + variant seems to have all the extensions described in the `GFM + documentation`_, except: + + - Newlines in paragraphs are not transformed into ``br`` tags. + - Intra-GitHub links to commits, repositories, and issues are not + supported. + + If you need support for features specific to GitHub comments and issues, + please use :class:`mdx_gfm.GithubFlavoredMarkdownExtension`. + + .. _GFM documentation: https://guides.github.com/features/mastering-markdown/ + """ + + def extendMarkdown(self, md, md_globals): + # Built-in extensions + FencedCodeExtension().extendMarkdown(md, md_globals) + SmartEmphasisExtension().extendMarkdown(md, md_globals) + TableExtension().extendMarkdown(md, md_globals) + + # Custom extensions + gfm.AutolinkExtension().extendMarkdown(md, md_globals) + gfm.AutomailExtension().extendMarkdown(md, md_globals) + gfm.HiddenHiliteExtension([ + ('guess_lang', 'False'), + ('css_class', 'highlight') + ]).extendMarkdown(md, md_globals) + gfm.SemiSaneListExtension().extendMarkdown(md, md_globals) + gfm.SpacedLinkExtension().extendMarkdown(md, md_globals) + gfm.StrikethroughExtension().extendMarkdown(md, md_globals) + gfm.TaskListExtension([ + ('list_attrs', {'class': 'checkbox'}) + ]).extendMarkdown(md, md_globals) + Nl2BrExtension().extendMarkdown(md, md_globals) # Global Vars diff --git a/rhodecode/public/css/legacy_code_styles.less b/rhodecode/public/css/legacy_code_styles.less --- a/rhodecode/public/css/legacy_code_styles.less +++ b/rhodecode/public/css/legacy_code_styles.less @@ -212,6 +212,13 @@ div.markdown-block strong { margin: 0; } +div.markdown-block ul.checkbox, +div.markdown-block ol.checkbox { + padding-left: 20px !important; + margin-top: 0px !important; + margin-bottom: 18px !important; +} + div.markdown-block ul, div.markdown-block ol { padding-left: 30px !important; @@ -219,6 +226,13 @@ div.markdown-block ol { margin-bottom: 18px !important; } +div.markdown-block ul.checkbox li, +div.markdown-block ol.checkbox li { + list-style: none !important; + margin: 6px !important; + padding: 0 !important; +} + div.markdown-block ul li, div.markdown-block ol li { list-style: disc !important;