diff --git a/rest_framework/templatetags/rest_framework.py b/rest_framework/templatetags/rest_framework.py index a31c3ca94..280b084e1 100644 --- a/rest_framework/templatetags/rest_framework.py +++ b/rest_framework/templatetags/rest_framework.py @@ -9,7 +9,6 @@ from django.utils import six from django.utils.encoding import force_text, iri_to_uri from django.utils.html import escape, format_html, smart_urlquote from django.utils.safestring import SafeData, mark_safe -from markdown.extensions.fenced_code import FencedBlockPreprocessor from rest_framework.compat import ( NoReverseMatch, markdown, reverse, template_render @@ -24,22 +23,6 @@ register = template.Library() class_re = re.compile(r'(?<=class=["\'])(.*)(?=["\'])') -class CustomFencedBlockPreprocessor(FencedBlockPreprocessor): - CODE_WRAP = '
%s
'
- LANG_TAG = ' class="highlight %s"'
-
-
-class FencedCodeExtension(markdown.Extension):
-
- def extendMarkdown(self, md, md_globals):
- """ Add FencedBlockPreprocessor to the Markdown instance. """
- md.registerExtension(self)
-
- md.preprocessors.add('fenced_code_block',
- CustomFencedBlockPreprocessor(md),
- ">normalize_whitespace")
-
-
@register.tag(name='code')
def highlight_code(parser, token):
code = token.split_contents()[-1]
@@ -92,7 +75,9 @@ def form_for_link(link):
@register.simple_tag
def render_markdown(markdown_text):
- return markdown.markdown(markdown_text, extensions=[FencedCodeExtension(), "tables"])
+ if not markdown:
+ return markdown_text
+ return markdown.markdown(markdown_text)
@register.simple_tag