Skip to content

Commit

Permalink
Switch to cmarkgfm completely for rendering Markdown (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored Mar 30, 2018
1 parent 506da6a commit 50d399c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 34 deletions.
20 changes: 5 additions & 15 deletions readme_renderer/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 1 addition & 8 deletions readme_renderer/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 0 additions & 5 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import glob
import os

import cmarkgfm
import pytest

from readme_renderer.markdown import render, variants
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
envlist = py27,pypy,py34,py35,py36,pep8,py2pep8,packaging

[testenv]
extras = gfm
deps =
pytest
mock
Expand Down

0 comments on commit 50d399c

Please sign in to comment.