How to generate PDF from markdown using pure ruby

2019-02-04 04:09发布

问题:

I'm currently using Kramdown to generate HTML from Markdown in Ruby. I know that I can generate a latex file using kramdown and convert it to pdf usaing a command line utility. But I want a pure ruby solution.

Is there a way to convert markdown to pdf using only ruby without using command-line utilities?

回答1:

You can use https://github.com/walle/gimli

I made it just for this purpose. Though, I use textile. But gimli supports all formats supported by GitHub-Markup.



回答2:

Prawn: The Pure Ruby PDF Generation Library
http://www.rubyinside.com/prawn-ruby-pdf-library-987.html



回答3:

I haven't tried it myself, but there's md2pdf



回答4:

The wkhtmltopdf gem is also available: http://rubygems.org/gems/wkhtmltopdf



回答5:

Pandoc is a universal document converter which can convert documents in markdown, reStructuredText, textile, HTML, DocBook, or LaTeX to HTML, EPUB, Microsoft Word, TeX, PDF via LaTeX, Lightweight markup formats.

You can find it here. http://johnmacfarlane.net/pandoc/