Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to cmarkgfm completely for rendering Markdown #68

Merged
merged 2 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
commands =
Expand Down