| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A gem for converting Markdown documents to book style, two-column PDFs.
This Markdown doc, run through bookify, gets converted into this PDF.
gem install bookify bookify document.md
You can specify the output file with a second argument (bookify document.md output.pdf), otherwise it will default to a PDF in your current directory with the same name as the input file.
Passing -l or --landscape as the first argument will render the document in a three-column landscape layout.
bookify -l document.md
require "bookify"
Bookify::Renderer.new(input_file: "document.md", output_file: "output.pdf").renderSupports basic Markdown (paragraphs, ul, ol, bold, italics, h1, h2, h3, tables) and limited html (img). You can also add divs with a class of "section-break" to immediately move to the next column, or "page-break" to immediately move to the next full page.
When generating documents, bookify converts Markdown to HTML, then parses that HTML into the final PDF document. If you want to add any custom extensions to Markdown (to be applied during the Markdown-to-HTML step), you can do so by registering your own pre- and post-processors. For example, if you want wiki-style internal links ([[Title]] and [[Title|Target]]) to be parsed as internal PDF links:
Bookify::Markdown.add_preprocessor ->(string) do
pattern = /\[\[[^\[]+\]\]/
string.gsub(pattern).each do |element|
content = element.gsub(/[\[\]]/, "")
title, target = content.split("|")
target ||= title
"<link anchor='#{target}'>#{title}</link>"
end
end| Back | FazBrowse Home | New Git URL |