'Github-Flavored-Markdown in Python

Does anyone knows of a working Python GFM implementation?

Currently I'm using a javascript renderer. It works, but an actual Python renderer would be the right tool for the job. (FS is a Django app)

I tried combining this with this. But the results are not so good.

relevant code --> https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/djangoproject/core/models.py (see IssueComment.toHTML)

Syntax highlighting is a plus.



Solution 1:[1]

Python-Markdown plus py-gfm seems to work well. It has the benefit of being somewhat standardized within the Python ecosystem - several extensions for Python-Markdown are available, then additional packages like django_markdown can be built on top of Python-Markdown and benefit from its extensions.

Solution 2:[2]

In case helpful for others, I just wanted the Github fenced code syntax, e.g.

```python
def hello():
   print('this should be rendered properly')
```

Python Markdown actually ships with an extension to do this already called Fenced Code Blocks that works well.

You just call it like so:

page_content = markdown.markdown(source, extensions=[FencedCodeExtension()])

Solution 3:[3]

Python has its own Markup language that is fairly similar to Markdown: http://docutils.sourceforge.net/rst.html

Solution 4:[4]

Grip is also pretty cool and gets the job done.

Solution 5:[5]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cory
Solution 2 Cory
Solution 3 Davoud Taghawi-Nejad
Solution 4 Anto
Solution 5 rukeba