mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-01 05:54:01 +03:00
When markdown is very old, markdown.blocktrans doesn't exists
This commit is contained in:
parent
8fa8776461
commit
cd8372960d
|
@ -371,16 +371,6 @@ else:
|
||||||
try:
|
try:
|
||||||
import markdown
|
import markdown
|
||||||
|
|
||||||
def apply_markdown(text):
|
|
||||||
"""
|
|
||||||
Simple wrapper around :func:`markdown.markdown` to set the base level
|
|
||||||
of '#' style headers to <h2>.
|
|
||||||
"""
|
|
||||||
|
|
||||||
extensions = ['headerid(level=2)']
|
|
||||||
safe_mode = False,
|
|
||||||
|
|
||||||
if markdown.version_info < (2, 1):
|
|
||||||
class CustomSetextHeaderProcessor(markdown.blockprocessors.BlockProcessor):
|
class CustomSetextHeaderProcessor(markdown.blockprocessors.BlockProcessor):
|
||||||
"""
|
"""
|
||||||
Class for markdown < 2.1
|
Class for markdown < 2.1
|
||||||
|
@ -409,7 +399,16 @@ try:
|
||||||
# Block contains additional lines. Add to master blocks for later.
|
# Block contains additional lines. Add to master blocks for later.
|
||||||
blocks.insert(0, '\n'.join(lines[2:]))
|
blocks.insert(0, '\n'.join(lines[2:]))
|
||||||
|
|
||||||
|
def apply_markdown(text):
|
||||||
|
"""
|
||||||
|
Simple wrapper around :func:`markdown.markdown` to set the base level
|
||||||
|
of '#' style headers to <h2>.
|
||||||
|
"""
|
||||||
|
|
||||||
|
extensions = ['headerid(level=2)']
|
||||||
|
safe_mode = False,
|
||||||
|
|
||||||
|
if markdown.version_info < (2, 1):
|
||||||
output_format = markdown.DEFAULT_OUTPUT_FORMAT
|
output_format = markdown.DEFAULT_OUTPUT_FORMAT
|
||||||
|
|
||||||
md = markdown.Markdown(extensions=markdown.load_extensions(extensions),
|
md = markdown.Markdown(extensions=markdown.load_extensions(extensions),
|
||||||
|
@ -420,7 +419,7 @@ try:
|
||||||
md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode)
|
md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode)
|
||||||
return md.convert(text)
|
return md.convert(text)
|
||||||
|
|
||||||
except ImportError:
|
except (ImportError, AttributeError):
|
||||||
apply_markdown = None
|
apply_markdown = None
|
||||||
|
|
||||||
# Yaml is optional
|
# Yaml is optional
|
||||||
|
|
Loading…
Reference in New Issue
Block a user