Irina Rapoport
Irina Rapoport

Reputation: 334

How do I convert README.md to Github-styled HTML?

I have a README.md file (describing a Node app) that I need to convert to a self-contained Github-styled README.html.

Note that this is not the same as finding an HTML converter for Github-flavored markdown. The precise style is important, and so is the self-contained part. (This is how my question is different from this one).

It can be an npm package or an online converter or perhaps some obscure (to me) Github feature allowing to view README.md full-screen, without the Github toolbar and such.

I can live with a Ruby gem or another language/platform if I have to. It needs to be simple, because I modify this README.md often.

Upvotes: 6

Views: 3493

Answers (2)

roman910
roman910

Reputation: 36

I came to this post a few days ago. In the end, I could not find any tool that satisfied my needs so I decided to create my own.

ghmd (GitHub Markdown) is a minimal tool (~4 KB) that converts any Markdown file into HTML using the GitHub CSS. It supports both regular Mardkown and GitHub Flavored Mardkown, and adaptive, light and dark modes. The results look just like they would in GitHub.

To install it, just run:

pip install ghmd

And to convert any file:

ghmd README.md --embed-css

It will generate a README.html in the same directory as the original file. The --embed-css flag will embed the CSS styles in the HTML file so it is self-contained.

I use it a lot to send Markdown files as HTML and it works like a charm.

Upvotes: 0

edhurtig
edhurtig

Reputation: 2361

There is a plugin for sublime text 2 that will do this for you, it is pretty darn accurate

https://github.com/revolunet/sublimetext-markdown-preview

There is also a github markdown API which you might be interested in: https://developer.github.com/v3/markdown/

And the CSS: https://github.com/sindresorhus/github-markdown-css

Upvotes: 3

Related Questions