Transform html into markdown. Useful for example if you want to import html into your markdown based application.
See Change Log
- Ruby 1.9.3 or higher
Install the gem
[sudo] gem install reverse_markdown
or add it to your Gemfile
- Supports all the established html tags like
- Module based - if you miss a tag, just add it
- Can deal with nested lists
- Inline and block code is supported
- Supports blockquote
You can convert html content as string or Nokogiri document:
input = '<strong>feelings</strong>' result = . input result.inspect # " **feelings** "
It's also possible to convert html files to markdown using the binary:
$ reverse_markdown file.html > file.md $ cat file.html | reverse_markdown > file.md
The following options are available:
pass_through) - how to handle unknown tags. Valid options are:
pass_through- Include the unknown tag completely into the result
drop- Drop the unknown tag and its content
bypass- Ignore the unknown tag but try to convert its content
raise- Raise an error to let you know
false) - use github flavored markdown (yet only code blocks are supported)
' ') - how to handle tag borders. valid options are:
' '- Add whitespace if there is none at tag borders.
''- Do not not add whitespace.
Just pass your chosen configuration options in after the input. The given options will last for this operation only.
.(input, unknown_tags: :raise, github_flavored: true)
Or configure it block style on a initializer level. These configurations will last for all conversions until they are set to something different.
. do |config| config. = :bypass config.github_flavored = true config.tag_border = '' end
- Write custom converters - Wiki entry about how to write your own converter
- html_massage - A gem by Harlan T. Wood to convert regular sites into markdown using reverse_markdown
- word-to-markdown - Convert word docs into markdown while using reverse_markdown, by Ben Balter
- markdown syntax - The markdown syntax specification
- github flavored markdown - Githubs extension to markdown
- wmd-editor - Markdown flavored text editor
Thanks to all contributors and all other helpers: