Skip to content

Commit b09586d

Browse files
committed
Replace gfm with commonmark
Fixes #8. GFM doesn't ignore inline HTML when rendering, and will produce bugs, such as re-hrefing the href in a link tag. GFM has essentially been abandoned. This PR replaces it with commonmark, which implements Common Markdown (https://commonmark.org/). Pros: - Commonmark is maintained by readthedocs, so is a good bet in terms of code durability. - Edge-cases in CommonMark are well-specified. - The library generates an AST, which we could use for enhancements later. Cons: - No auto-linking of bare URLs. You need to wrap URLs in <brackets> - No br for soft linebreaks. you will need to add two spaces at the end of the line to create a BR.
1 parent f55fc63 commit b09586d

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

lettersmith/markdowntools.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
from markdown import markdown as md
2-
from mdx_gfm import GithubFlavoredMarkdownExtension
1+
from commonmark import commonmark
32
from lettersmith.html import strip_html
43
from lettersmith import docs as Docs
54
from lettersmith.func import compose
65

76

8-
def markdown(s):
9-
"""
10-
Render markdown on content field.
11-
"""
12-
return md(s, extensions=(GithubFlavoredMarkdownExtension(),))
13-
14-
7+
markdown = commonmark
158
strip_markdown = compose(strip_html, markdown)
169
content = Docs.renderer(markdown)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
packages=find_packages(exclude=("tests", "tests.*")),
2222
install_requires=[
2323
"PyYAML>=3.13",
24-
"py-gfm>=0.1.3",
24+
"commonmark>=0.9.1",
2525
"python-frontmatter>=0.3.1",
2626
"Jinja2>=2.7"
2727
# TODO

0 commit comments

Comments
 (0)