From 29dfbabaf54d75801b404e253a2d7574fa415564 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 4 Sep 2012 09:32:02 +0100 Subject: [PATCH] Remove support for markdown<2.1 --- djangorestframework/compat.py | 40 ++--------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/djangorestframework/compat.py b/djangorestframework/compat.py index 83d26f1ff..7ced70c57 100644 --- a/djangorestframework/compat.py +++ b/djangorestframework/compat.py @@ -371,34 +371,6 @@ else: try: import markdown - class CustomSetextHeaderProcessor(markdown.blockprocessors.BlockProcessor): - """ - Class for markdown < 2.1 - - Override `markdown`'s :class:`SetextHeaderProcessor`, so that ==== headers are

and ---- heade - - We use

for the resource name. - """ - import re - # Detect Setext-style header. Must be first 2 lines of block. - RE = re.compile(r'^.*?\n[=-]{3,}', re.MULTILINE) - - def test(self, parent, block): - return bool(self.RE.match(block)) - - def run(self, parent, blocks): - lines = blocks.pop(0).split('\n') - # Determine level. ``=`` is 1 and ``-`` is 2. - if lines[1].startswith('='): - level = 2 - else: - level = 3 - h = markdown.etree.SubElement(parent, 'h%d' % level) - h.text = lines[0].strip() - if len(lines) > 2: - # Block contains additional lines. Add to master blocks for later. - blocks.insert(0, '\n'.join(lines[2:])) - def apply_markdown(text): """ Simple wrapper around :func:`markdown.markdown` to set the base level @@ -407,21 +379,13 @@ try: extensions = ['headerid(level=2)'] safe_mode = False, - - if markdown.version_info < (2, 1): - output_format = markdown.DEFAULT_OUTPUT_FORMAT - - md = markdown.Markdown(extensions=markdown.load_extensions(extensions), - safe_mode=safe_mode, - output_format=output_format) - md.parser.blockprocessors['setextheader'] = CustomSetextHeaderProcessor(md.parser) - else: - md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode) + md = markdown.Markdown(extensions=extensions, safe_mode=safe_mode) return md.convert(text) except ImportError: apply_markdown = None + # Yaml is optional try: import yaml