diff --git a/readme_renderer/markdown.py b/readme_renderer/markdown.py index cfdec80..0a82476 100644 --- a/readme_renderer/markdown.py +++ b/readme_renderer/markdown.py @@ -13,25 +13,15 @@ # limitations under the License. from __future__ import absolute_import, division, print_function -from CommonMark import commonmark +import cmarkgfm from .clean import clean -try: - import cmarkgfm -except ImportError: - cmarkgfm = None - - -variants = {} - -if cmarkgfm is not None: - variants["gfm"] = cmarkgfm.github_flavored_markdown_to_html - # Preferentially use cmarkgfm for CommonMark. - variants["CommonMark"] = cmarkgfm.markdown_to_html -else: - variants["CommonMark"] = commonmark +variants = { + "gfm": cmarkgfm.github_flavored_markdown_to_html, + "CommonMark": cmarkgfm.markdown_to_html, +} def render(raw, variant="CommonMark", **kwargs): diff --git a/readme_renderer/txt.py b/readme_renderer/txt.py index 4edb60e..0c0c533 100644 --- a/readme_renderer/txt.py +++ b/readme_renderer/txt.py @@ -13,14 +13,7 @@ # limitations under the License. from __future__ import absolute_import, division, print_function -try: - from html import escape as html_escape -except ImportError: - from cgi import escape as _html_escape - - def html_escape(s, quote=True): - return _html_escape(s, quote=quote) - +from html import escape as html_escape from .clean import clean diff --git a/setup.py b/setup.py index 08ff708..5f2b64a 100644 --- a/setup.py +++ b/setup.py @@ -60,17 +60,14 @@ ], install_requires=[ - "commonmark>=0.7.4", "bleach>=2.1.0", + "cmarkgfm>=0.2.0", "docutils>=0.13.1", + "future", "Pygments", "six", ], - extras_require={ - "gfm": "cmarkgfm>=0.1.0" - }, - entry_points={ "distutils.commands": [ "check = readme_renderer.integration.distutils:Check", diff --git a/tests/test_markdown.py b/tests/test_markdown.py index cc92236..c0087b1 100755 --- a/tests/test_markdown.py +++ b/tests/test_markdown.py @@ -2,7 +2,6 @@ import glob import os -import cmarkgfm import pytest from readme_renderer.markdown import render, variants @@ -39,7 +38,3 @@ def test_md_fixtures(md_filename, html_filename, variant): def test_missing_variant(): assert render('Hello', variant="InvalidVariant") is None - - -def test_cmarkgfm_is_preferred(): - assert variants['CommonMark'] is cmarkgfm.markdown_to_html diff --git a/tox.ini b/tox.ini index 5ee1df4..8719bb3 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,6 @@ envlist = py27,pypy,py34,py35,py36,pep8,py2pep8,packaging [testenv] -extras = gfm deps = pytest mock