Skip to content
/ md-to-pdf Public

A markdown to pdf generator with styling by yml

License

Notifications You must be signed in to change notification settings

opf/md-to-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ca29cbf · Oct 27, 2022

History

6 Commits
Oct 25, 2022
Oct 26, 2022
Oct 26, 2022
Oct 27, 2022
Oct 25, 2022
Oct 25, 2022
Oct 25, 2022
Oct 25, 2022
Oct 25, 2022
Oct 27, 2022
Oct 25, 2022
Oct 25, 2022
Oct 27, 2022
Oct 25, 2022
Oct 26, 2022
Oct 25, 2022
Oct 25, 2022

Repository files navigation

Markdown-to-PDF

WORK IN PROGRESS, please expect changes to API and styling yml spec

Installation

bundle add md_to_pdf --github opf/md-to-pdf

Requirements

  • Ruby 3.0.3 or newer

Usage

Command line

bundle exec md_to_pdf <styling file> <source file> <dest file>

Example:

bundle exec md_to_pdf ./demo/demo.yml ./demo/demo.md ./demo/generated/demo.pdf

As Library

require 'md_to_pdf'

#...
# file processing
styling_filename = './demo/demo.yml'
source_filename = './demo/demo.md'
dest_filename = './demo/generated/demo.pdf'
MarkdownToPDF.generate_markdown_pdf(styling_filename, source_filename, dest_filename)

# example with raw markdown pre-processing
markdown_string = File.read(source_filename)
markdown_string += 'An additional text at the bottom'
images_path = File.dirname(source_filename)
MarkdownToPDF.generate_markdown_string_pdf(styling_filename, markdown_string, images_path, dest_filename)

Markdown

Please have a look at demo.md for an overview and examples of all supported markdown syntax

Currently not supported:

  • Images inline in text in tables (images will be placed in own line)
  • Images inline in text (images will be placed in own line)
  • Remote images e.g. via http (images will be skipped)

Styling

A yml config file is used to set the pdf styling

Please have a look at docs/STYLING.md for description.

Frontmatter

Meta Information and header/footer content is defined in a head section of the markdown file

Please have a look at docs/FRONTMATTER.md for description.

About

A markdown to pdf generator with styling by yml

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published