Prawndown
A tiny Ruby gem to render a subset of Markdown in PDF files.
Prawn is a Ruby library to generate PDF files. It supports text formatting trough its own HTML-esque language, which has tags for different formatting options like bold, italic, ~~strikethrough~~ and links. Read more about the supported tags in the Prawn documentation.
Usage
Prawndown extends Prawn with the markdown method. It accepts the same options as Prawn::Document#text.
Use it to render Markdown in the document:
Prawn::Document.generate('markdown.pdf') do
markdown '# Welcome to Prawndown!'
markdown '**Important:** We _hope_ you enjoy your stay!', color: 'AAAAAA'
end
If prefered, the parser can also be invoked directly:
Prawndown::Parser.new('_Welcome_ to **Prawndown**').to_prawn #=> '<i>Welcome</i> to <b>Prawndown</b>'
More thorough examples can be found under the examples folder. Run rake examples to generate the examples PDF.
Supported Markdown syntax
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
###### Header 6
_Italic_
*Italic*
__Bold__
**Bold**
~~Strikethrough~~
[Links](https://github.com/kaspermeyer/prawndown)
Note: Prawdown can't output the tags <sub>, <sup>, <font> and <color> as they lack native support in Markdown.
Installation
Add this line to your application's Gemfile:
gem 'prawndown'
And then execute:
$ bundle
Or install it yourself as:
$ gem install prawndown
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install.
Credits
- Henrik Ny for the idea and name of the project.
- Johnny Broadway for creating Slimdown and coming up with great regular expressions to match Markdown tags with.