Markdown to PDF in 1 Line

With the rise of markdown as the default formatting for so many note-taking apps, and really good apps like Bear, Ulysses, and Notion, working within a markdown-only setup has never been easier. For the most part, I use those apps like inboxes, moving anything that needs keeping or gets larger than a single page into my folder system, which has served me well for, well, decades, now. Once there, I now use Typora for writing — for a long time it was FoldingText, but Typora has finally surpassed it in terms of ease of use and functionality. (I still keep FoldingPaper around, because.) For coding, I use Atom, which handles interacting with GitHub readily, which is where most of those projects live.

The remaining gap in functionality has been going from markdown to the printed page. MD to HTML and then into Word or Pages is okay, but I would prefer to stay in markdown up until the final moment of output, and now it looks like there is a simple path: pandoc + wkhtmltopdf:

pandoc --pdf-engine=wkhtmltopdf -o filename.pdf -c some.css

Make sure your version of Pandoc is up-to-date. I had an older version which did not take kindly to the --pdf-engine option, but once I updated, everything “just worked.” (FTR, I use MacPorts, which made installing, and upgrading, pandoc as well as installing wkhtmltopdf super easy. I then made sure wkhtmltopdf was in my PATH.)

Markdown Woes

I tried switching from the deprecated, but still loved and trusted, Markdown Extra plug-in by Michel Fortin to the Markdown plug-in built into WordPress’ Jetpack, but I got un-transformed text. I tried activating and de-activating all the Jetpack options. I tried de-activating and activating Jetpack itself. No love, no luck. Has anyone else found a solution to the problem of having the Jetpack Markdown module recognize extant posts as being in Markdown format?

More Markdown Munchies

[Brett Terpstra][bt] has a couple of nice bits of code in which folks using Markdown might be interested. The first is a bash script, [`mdfind`][1], that makes it easier to find text inside a collection of text files all in Markdown format. The second is a [Wordpress plug-in][2] that gives you a collection of Markdown tags in the same way that the standard editing UI gives you HTML tags. This could be useful for those less used tags, like images for me, that I have to look up in a cheat sheet. Fortunately for me, if I am posting a note I am usually doing so from [MarEdit][Me] which not only supports Markdown, but also gives me a very flexible menu system that lets me drop tags in as I need them.

Well, that and there’s always [Typinator][Tr], which makes it possible for me not to have to remember that image syntax, except as the macro `mdimage`. It doesn’t get much easier than that.


MultiMarkdown now generates captions

I am a big fan of the [Markdown][md] markup language developed by John Gruber and released as open source. I use a variant of it, [PHP Markdown][phpmd] by Michele Fortin, to write posts for this log. Another variant is [MultiMarkdown][mmd], which I use for my own notes, and which can also be used with other applications to generate camera-ready copy. MultiMarkdown was spun off and is maintained by Fletcher Penney, who is, like the other two folks above, a great guy. (I don’t follow many people on GitHub, but I [follow Fletcher][gh-fp].)

All that is a way of noting that even something as simple as a markup language that is designed to be as minimalist as possible still achieves a remarkable richness in an open source context, and, just as importantly, gets pushed to try out new things.

One of those novelties was covered by Merlin Mann in a recent Tumblr post: MultiMarkdown can now generate captions for images from the `alt` text. I haven’t tried this functionality out myself, because I don’t use the MMD CMS, but it appears to look like this: [Mann’s Illustration of MMD’s Caption Capability](

I should note that captions here are also automatically generated from `alt` text, when I remember to include that text, but that’s thanks to the WordPress plug-in [Image Caption][ic]. Do I wish it could all be handled by one piece of software like MMD? Sure, but MMD CMS generates statis sites and requires that you upload pages individually to your web server. I work from multiple machines and really prefer the convenience of WordPress combined with the power of a site that has a database on its backend. It makes backing up and searching much easier.

**UPDATE**: No, I don’t know why my captions are crossing the entire page. The WP plugging is generating its own `div` and when I get a chance I’m going to see if getting rid of the `div` will fix the problem. The `div` in and of itself is contained within other `divs` and so I’m not sure what is going on. (I’m checking the `CSS` file as I write this.)

**UPDATE D’OH**: The problem appears to be the Tumblr embed scheme. (It doesn’t have options like Flickr.) I tried hacking it a bit, but then I decided just to make the image a link to Mann’s post. Leave it at that.


Markdown in Brief

# Header 1 #
## Header 2 ##
### Header 3 ###             (Hashes on right are optional)
#### Header 4 ####
##### Header 5 #####

This is a paragraph, which is text surrounded by whitespace.
Paragraphs can be on one line (or many), and can drone on
for hours.  

Here is a Markdown link to [Warped](, 
and a literal .  Now some SimpleLinks, like 
one to google (autolinks to are-you-feeling-lucky), a test 
link to a Wikipedia page, and a CPU at foldoc. 

Now some inline markup like _italics_,  **bold**, and `code()`.

![picture alt](/images/photo.jpeg "Title is optional")     

> Blockquotes are like quoted text in email replies
>> And, they can be nested

* Bullet lists are easy too
- Another one
+ Another one

1. A numbered list
2. Which is numbered
3. With periods and a space

And now some code:

    // Code is just text indented a bit
    which(is_easy) to_remember();

Text with  
two trailing spaces  
(on the right)  
can be used  
for things like poems  

Some horizontal rules ...

* * * *

Markdown Cheat Sheet

## Phrase Emphasis

`*italic* **bold**
_italic_ __bold__`

## Links

Inline: `An [example]( “Title”)`. Reference-style labels (titles are optional): An `[example][id]`. Then, anywhere else in the doc, define the link:

`[id]: “Title”`

## Images

Inline (titles are optional): `![alt text](/path/img.jpg “Title”)` Reference-style:
`![alt text][id]`. Elsewhere `[id]: /url/to/img.jpg “Title”`.

## Headers


`Header 1

Header 2

atx-style (closing #’s are optional):

`# Header 1 #

## Header 2 ##

###### Header 6`

## Lists

Ordered, without paragraphs:

`1. Foo
2. Bar`

Unordered, with paragraphs:

`* A list item.`

With multiple paragraphs, you can nest them:

`* Abacus
* answer
* Bubbles
1. bunk
2. bupkis
3. burper
* Cunning`


`> Email-style angle brackets
> are used for blockquotes.

> > And, they can be nested.`

`> #### Headers in blockquotes
> * You can quote a list.
> * Etc.`

Code Spans

`` spans are delimited by backticks.

You can include literal backticks
like `` `this` ``.

Preformatted Code Blocks

Indent every line of a code block by at least 4 spaces or 1 tab.

`This is a normal paragraph.`

This is a preformatted
code block.

Horizontal Rules

Three or more dashes or asterisks:


`* * *`

## Manual Line Breaks

End a line with two or more spaces:

`Roses are red,
Violets are blue. `