PMT is a robust solution for creating PDF media with Pug.
This project is my attempt to replace LaTeX in my toolchain. I often use LaTeX to create pretty documents, presentations, etc. - any scenario in which structured documents are desired.
This project is still very much under construction. I don't intend to make any breaking changes, but this is your standard "stuff might break" warning.
PMT is available via NPM. You can install it like any other NPM package:
$ npm i -g @jonpalmisc/pmt
The most simple usage secenario is as follows, where <file>
is the the path
to your input:
$ pmt <file>
This will process your input file (Pug) and produce a PDF adjacent to it using the internal (Chromium-based) PDF engine.
If you would like to use an alternate HTML-to-PDF engine such as
Prince or WeasyPrint,
you can instruct PMT to produce HTML output instead with the -x
or --html
flags:
$ pmt -x <file>
For advanced usage, use the -h
or --help
flags for more information.
One thing PMT is sorely lacking is example documents, etc. While they are not written in Pug and do not leverage PMT's syntax, the PrinceXML Samples and WeasyPrint Samples should serve to demonstrate the level of visual fidelity PMT is capable of, as they utilize similar technology.
I aim to create some examples and add them to the repo soon! Unfortunately, most of my existing work done in PMT is not publicly-sharable.
A handful of "plugins" are included by default. You can learn more about them in the following sections.
You can write Markdown in your documents using the :markdown
filter:
:markdown
# An exciting heading
With an even more exciting paragraph
You can write SCSS in your documents or include SCSS files using the :scss
filter:
style
include:scss local.scss
:scss
html {
font-family: sans-serif;
}
You can also leverage the (somewhat limited) "standard library" of styles from either inline SCSS or from included files:
style
:scss
@import "std/base"
The plugins in the sections below are also included with a standard install,
but are not enabled by default. You can enable them via the -p
flag. See the
usage information for more details.
You can write math equations to be automatically typeset by MathJax:
p Look, here's an inline square root: $\sqrt{x}$.
p Below, you can find a display equation:
p $$\int_a^b 6x \,dx = 3x^2 \Big|_a^b$$
Support for creating diagrams with Mermaid is included. You can define your
diagrams in the body of a :mermaid
filter:
:mermaid
graph LR
A[Start] --> B[End]
Hint: You must explicitly set your document's doctype (doctype html
),
otherwise Mermaid may not work as expected.
The smart quotes plugin will automatically replace "dumb quotes" with typographically correct quote characters.
There are two built-in plugins for syntax highlighting: one for Highlight.js
and one for Prism.js, named highlight
and prism
, respectively. If you
enable these plugins, you must use the default highlighting stylesheet
(found in the include folder) or bring your own. Otherwise, it will appear
as if nothing is happening! See the documentation for each highlighter for more
info on customization.
Chrome doesn't support some of the more fancy paged CSS features, but you can
enable them through a polyfill with the pages
plugin, which uses Paged.js
under the hood.
Copyright © 2020 Jon Palmisciano. See LICENSE.txt for more information.