Commit 4f0b5cc3 authored by Julien Palard's avatar Julien Palard
Browse files

Use the maintained markdown module instead of the abandonned markdown2.

parent 67ebedb0
......@@ -41,7 +41,6 @@ INSTALLED_APPS = [
"django.contrib.messages",
"django.contrib.staticfiles",
"bootstrap4",
"django_markdown2",
"django_ace",
"django_filters",
"rest_framework",
......
......@@ -14,7 +14,6 @@ django-bootstrap4==0.0.6
django-debug-toolbar==1.9.1
django-extensions==2.1.0
django-filter==2.0.0
django-markdown2==0.3.1
django-model-utils==3.1.2
django-registration-redux==2.4
djangorestframework==3.8.2
......@@ -24,7 +23,7 @@ hyperlink==18.0.0
idna==2.7
incremental==17.5.0
jsonfield==2.0.2
markdown2==2.3.5
markdown==3.0.1
msgpack==0.5.6
psycopg2==2.7.5
Pygments==2.2.0
......
.codehilite .hll { background-color: #ffffcc }
.codehilite { background: #f8f8f8; }
.codehilite .c { color: #408080; font-style: italic } /* Comment */
.codehilite .err { border: 1px solid #FF0000 } /* Error */
.codehilite .k { color: #008000; font-weight: bold } /* Keyword */
.codehilite .o { color: #666666 } /* Operator */
.codehilite .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.codehilite .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.codehilite .cp { color: #BC7A00 } /* Comment.Preproc */
.codehilite .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.codehilite .c1 { color: #408080; font-style: italic } /* Comment.Single */
.codehilite .cs { color: #408080; font-style: italic } /* Comment.Special */
.codehilite .gd { color: #A00000 } /* Generic.Deleted */
.codehilite .ge { font-style: italic } /* Generic.Emph */
.codehilite .gr { color: #FF0000 } /* Generic.Error */
.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.codehilite .gi { color: #00A000 } /* Generic.Inserted */
.codehilite .go { color: #888888 } /* Generic.Output */
.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.codehilite .gs { font-weight: bold } /* Generic.Strong */
.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.codehilite .gt { color: #0044DD } /* Generic.Traceback */
.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.codehilite .kp { color: #008000 } /* Keyword.Pseudo */
.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.codehilite .kt { color: #B00040 } /* Keyword.Type */
.codehilite .m { color: #666666 } /* Literal.Number */
.codehilite .s { color: #BA2121 } /* Literal.String */
.codehilite .na { color: #7D9029 } /* Name.Attribute */
.codehilite .nb { color: #008000 } /* Name.Builtin */
.codehilite .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.codehilite .no { color: #880000 } /* Name.Constant */
.codehilite .nd { color: #AA22FF } /* Name.Decorator */
.codehilite .ni { color: #999999; font-weight: bold } /* Name.Entity */
.codehilite .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.codehilite .nf { color: #0000FF } /* Name.Function */
.codehilite .nl { color: #A0A000 } /* Name.Label */
.codehilite .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */
.codehilite .nv { color: #19177C } /* Name.Variable */
.codehilite .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.codehilite .w { color: #bbbbbb } /* Text.Whitespace */
.codehilite .mb { color: #666666 } /* Literal.Number.Bin */
.codehilite .mf { color: #666666 } /* Literal.Number.Float */
.codehilite .mh { color: #666666 } /* Literal.Number.Hex */
.codehilite .mi { color: #666666 } /* Literal.Number.Integer */
.codehilite .mo { color: #666666 } /* Literal.Number.Oct */
.codehilite .sa { color: #BA2121 } /* Literal.String.Affix */
.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */
.codehilite .sc { color: #BA2121 } /* Literal.String.Char */
.codehilite .dl { color: #BA2121 } /* Literal.String.Delimiter */
.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */
.codehilite .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */
.codehilite .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.codehilite .sx { color: #008000 } /* Literal.String.Other */
.codehilite .sr { color: #BB6688 } /* Literal.String.Regex */
.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */
.codehilite .ss { color: #19177C } /* Literal.String.Symbol */
.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */
.codehilite .fm { color: #0000FF } /* Name.Function.Magic */
.codehilite .vc { color: #19177C } /* Name.Variable.Class */
.codehilite .vg { color: #19177C } /* Name.Variable.Global */
.codehilite .vi { color: #19177C } /* Name.Variable.Instance */
.codehilite .vm { color: #19177C } /* Name.Variable.Magic */
.codehilite .il { color: #666666 } /* Literal.Number.Integer.Long */
pygments @ c39da1d9
Subproject commit c39da1d9e5f0f67a0117af6207bc50ee875ca3b7
{% extends "hkis/layout.html" %}
{% load hkis_extra %}
{% load i18n static md2 bootstrap4 %}
{% load i18n static bootstrap4 %}
{% block title %}{{ object.title }}{% endblock %}
{% block stylesheet %}
<link href="{% static "css/pygments/default.css" %}" rel="stylesheet" type="text/css" />
{% block stylesheets %}
<link href="{% static "css/codehilite.css" %}" rel="stylesheet" type="text/css" />
{% endblock %}
{% block container %}
{{ answer_form.media }}
......@@ -16,7 +16,7 @@
</div>
{% endif %}
<div style="margin-bottom: 25px;">
{{ object.wording|markdown:"fenced-code-blocks"|trash_fix_code_in_a|i18n_doc_links:LANGUAGE_CODE }}
{{ object.wording|markdown|md_to_bootstrap|i18n_doc_links:LANGUAGE_CODE }}
</div>
<div class="row">
......
from django import template
from django.utils.safestring import mark_safe
import markdown
register = template.Library()
@register.filter(is_safe=True)
def trash_fix_code_in_a(value):
"""This is temporarily trash-fixing
https://github.com/trentm/python-markdown2/issues/259
def md_to_bootstrap(value):
"""This replaces some markdown css classes to bootstrap classes.
"""
return value.replace("&lt;code&gt;", "<code>").replace("&lt;/code&gt;", "</code>")
return value.replace(
'class="admonition warning"', 'class="alert alert-warning"'
).replace("admonition-title", "alert-heading")
@register.filter(is_safe=True)
......@@ -19,3 +23,14 @@ def i18n_doc_links(value, language):
if language == "fr":
return value.replace("https://docs.python.org/", "https://docs.python.org/fr/")
return value
@register.filter(name="markdown", is_safe=True)
def markdown_filter(value):
"""Processes the given value as Markdown.
Syntax::
{{ value|markdown }}
"""
return mark_safe(
markdown.markdown(value, extensions=["fenced_code", "codehilite", "admonition"])
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment