Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 897
Tony Lâmpada Avatar asked Aug 13 '12 22:08

Tony Lâmpada


People also ask

What is GitHub Markdown syntax?

Markdown is an easy-to-read, easy-to-write syntax for formatting plain text. We've added some custom functionality to create GitHub Flavored Markdown, used to format prose and code across our site.

How do I add Python code to Markdown?

To add a Python code chunk to an R Markdown document, you can use the chunk header ```{python} , e.g., ```{python} print("Hello Python!") ```

How do I read a Markdown file in Python?

You use the open() function to open the Picnic.md file; passing the value 'r' to the mode parameter to signify that Python should open it for reading. You save the file object in a variable called f , which you can use to reference the file. Then you read the file and save its contents inside the text variable.


1 Answers

GitHub uses Redcarpet which is really a Ruby binding built by github for Sundown.

There's a binding for Sundown in Python called Misaka. If you want to have something closer to the renderer github uses but in python you might start there.

For code highlighting you can use Pygments with Misaka.

like image 172
Eduardo Avatar answered Sep 30 '22 12:09

Eduardo