forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown.py
More file actions
27 lines (22 loc) · 765 Bytes
/
markdown.py
File metadata and controls
27 lines (22 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright The IETF Trust 2021, All Rights Reserved
# -*- coding: utf-8 -*-
"""Markdown wrapper
Use this instead of importing markdown directly to guarantee consistent extensions / options through
the datatracker.
"""
import markdown as python_markdown
from django.utils.safestring import mark_safe
from ietf.doc.templatetags.ietf_filters import urlize_ietf_docs
from ietf.utils.text import bleach_cleaner, bleach_linker
def markdown(text):
return mark_safe(
bleach_linker.linkify(
urlize_ietf_docs(
bleach_cleaner.clean(
python_markdown.markdown(
text, extensions=["extra", "nl2br", "sane_lists", "toc"]
)
)
)
)
)