A suite of markdown tools
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
CHANGELOG.yml
LICENSE.txt
README.md
build.yml
md2pdf.go

README.md

MD2PDF

Code Quality License

md2pdf is a tool to convert Markdown documents to PDF, without using LaTeX.

Installation

Download the archive on the releases page. Unzip it and put the binary for your platform somewhere in your PATH (in directory /usr/local/bin for instance).

As this tool calls htmldoc, xsltproc and faketime, you must install them with md2pdf. To install these dependencies on a Debian like Linux distribution, you can type following commands :

sudo apt-get install xsltproc
sudo apt-get install htmldoc
sudo apt-get install faketime

Usage

To get help about this tool, type :

$ md2pdf -h
md2pdf [-h] [-x] [-s] [-t] [-i dir] [-o file] file.md
Transform a given Markdown file into PDF.
-h        To print this help page.
-x        Print intermediate XHTML output.
-s        Print stylesheet used for transformation.
-t        Print html output.
-i dir    To indicate image directory.
-o file   The name of the file to output.
file.md   The markdown file to convert.
Note:
This program calls pandoc, xsltproc and htmldoc that must have been installed.

This tool transforms Markdown input to XHTML using blackfriday library. This is the file printed with the -x option. This file is transformed, calling xsltproc and the stylesheet printed with the ̀-s option, into an intermediate decorated XHTML file printed with the -t option. This file is transformed into resulting PDF calling xsltproc.

The option -i dir tells in which directory are located images (relative to current directory).

This will print resulting PDF document in a file with the same path than the origin markdown document with the .pdf extension. To write PDF in another file use the -o file option.

Markdown syntax

See file test/example.md for an example of supported syntax elements. This is syntax described on markdown wiki page, plus images with following syntax:

![Image Title](image_file.jpg)

Furthermore, this tool parses YAML header at the beginning of the markdown document, as used by pandoc tool, such as :

---
title:    Document title
author:   Michel Casabianca
date:     2014-06-09
email:    michel.casabianca@gmail.com
id:       1
lang:     en
toc:      true
---

These headers are used by the tools to print information at the beginning of the document and in page footer:

  • title: this is the title of the document.
  • auhtor: this is the author of the document.
  • date: this ISO formatted date is print in documents as production date.
  • email: this is the email of the author of the document.
  • id: this is the unique ID of the document. This is for my site processor internal usage.
  • lang: this is the language of the document, in ISO format (defaults to en).
  • toc: tells if we want a table of content in resulting document (defaults to false).

Note that these headers are not mandatory.

Bugs

Successive lists

If an ordered list follows an unordered one, it result in a single unordered list:

- First unordered.
- Second unordered.
- Third unordered.

1. First ordered.
2. Second ordered.
3. Third ordered.

If there is a paragraph between, it works:

- First unordered.
- Second unordered.
- Third unordered.

Test.

1. First ordered.
2. Second ordered.
3. Third ordered.

Todo

  • Generate TOC in resulting PDF file.