2017-12-13 Markdown and Pandoc

Many years ago I wanted to compare various tool chains to get from a text file to a PDF.

Many years ago

I looked at quite a few:

1. Oddmuse wiki

2. Open Office (that’d be Libre Office these days)

3. Docbook

4. LaTeX

5. rst2pdf

Also mentioned in the comments: txt2tags, and markdown + pandoc.

Well, I finally used markdown and pandoc—and I have some questions:

1. How can I make *tables* look better in a short RPG rules document?

2. How can I have a *sidebar* or boxed sections for examples? *Edited to add:* I’m currently using `tcolorbox`. That’s cool, even if tables still look bad.

Any other tweaks you can recommend?

This is what I have:

solar-fantasy.md

solar-fantasy.pdf

Later, I have tried quite a few things. Writing a pandoc filter such that I can use the `tufte-book` class and move the examples into the margin. At the top of the file:

---
author: Alex Schroeder
title: Solar Fantasy
lang: de
documentclass: tufte\-book
classoption: a4paper
classoption: twoside
classoption: notitlepage
classoption: openany
---

A filter written in Perl using the appropriate modules. I tried to get Haskell installed but it was a pain to compile my little filter and I gave up. Finding the right incantation for the Perl filter was also a matter of countless guesses because the documentation doesn’t have the example I need and uses `$_->{content}` instead of `$_->{c}`. It was infuriating.

This works, however:

#!/usr/bin/env perl
use Pandoc::Filter;
use Pandoc::Elements;
use Data::Dumper;
pandoc_filter BlockQuote => sub {
  return [
    RawBlock("latex", "\\marginnote{"),
    @{$_->{c}},
    RawBlock("latex", "}"),
 ];
};

So now I start looking at pagebreaks and insert `\newpage` every now and then. This results in a lot of whitespace at the bottom of a few pages. OK, I add a picture or two:

\begin{center}
\includegraphics[height=7cm]{dwarf.jpg}
\end{center}

Ah, but this doesn’t work because of the Fate dice images. For those to look more or less centered on a line, I needed to change the defaults:

\setkeys{Gin}{height=1em,viewport=0 4 16 19,keepaspectratio}

If I remove the default, the dwarf looks good but the dice are too big.

Finally I decided that moving to Markdown had not solved my fundamental problem with LaTeX: endless fiddling and programming to make RPG products look good. *This is not how I want to spend my time.*

And so I didn’t commit any of that. I should use something other than PDF as output.

pandoc --standalone --output solar-fantasy.mobi solar-fantasy.md

And mailing it to my Kindle address. Let’s see!

...

There was a problem with the document you sent.

FUUUUUUH! 😠

I have a cold and this was supposed to keep my busy while I sit around at home and try to forget the sinuses and my throat ache, but this isn’t helping.

​#Markdown ​#Pandoc