2022-07-04 Markdown instead of LaTeX

I’m sitting at the desk, balcony door open, the street is wet and the cars make that peculiar hissing noise when they drive. A thunderstorm is still growling in the distance.

I’ve spent the day trying to rewrite Halberds and Helmets using Markdown, replacing the LaTeX sources I have. I know that LaTeX produces the best looking output. At the same time it demands a lot of attention, uses a lot of my brain for packages and whatnot that I want to free for other stuff.

Halberds and Helmets

A Markdown → HTML + CSS → PDF pipeline has the benefit that I get to use CSS to fiddle with the output instead of relying on LaTeX class authors. I don’t know whether that is a benefit. 🤔 Perhaps it’s simply irrational on my part but lately more and more of my projects have been using this Markdown → HTML + CSS → PDF pipeline, I felt like I should migrate my existing projects while I still care.

Markdown → HTML + CSS → PDF pipeline

Well, one immediate drawback is that the things that cannot be handled by the simple Markdown processor needs to be added using HTML, and that in turn doesn’t nest with Markdown, so I’ve added some post-processing using two Perl scripts. 😓

Another drawback is that I spent the entire day doing it, and all I got to show for it are eight pages. That’s super slow and frustrating.

If you want to compare results:

Halberds & Helmets from LaTeX (PDF)

Halberds & Helmets from Markdown (PDF)

As you can see, another drawback is that right now, there’s no index. I know that indexes are possible in theory because I recently added a post-processing script to my Spellcasters project. And yes, LaTeX index generation is weird, but post-processing using Perl is probably just as weird for somebody new.

Spellcasters

Are are also no internal links because I wanted to add those later.

The more I write, the more I regret my decision. I guess I don’t regret the fact that I’ve tried it because this was on my mind a lot, but I also expected conversion to be faster, the layout to be a lot less fiddly (but it isn’t), the tooling to be easier to understand (but I doubt it).

Perhaps the biggest takeaway is that I should do this in Libre Office and then everybody who cared could take a look. The older I am, the more I’m losing my LaTeX-arrogance and just wish for stuff to be simpler.

The day of Word 5 crashing every now and then and me saving after practically every sentence are gone with the last millennium. Perhaps it’s time to change. Or to learn Scribus? I suspect Scribus is also a bad fit because I keep fiddling with these documents as I run my games. They are not “books” with a publishing date and possibly a second edition in ten years. Every few weeks, I make little changes.

Anyway, I’ve committed the stuff to a local branch and haven’t decided what to do next.

​#RPG ​#Halberds and Helmets ​#Markdown

Comments

(Please contact me if you want to remove your comment.)

Do you think you could do the writing in Markdown, sprinkling in LaTeX where appropriate? I saw on tex.stackexchange someone uses pandoc to process combined Markdown/LaTeX documents.

on tex.stackexchange

A move to Open Document Format could work, I suppose, if moving from plaintext and rendered output to a binary that combined both would be acceptable.

I’ve tried a few publishing tools but they seemed oriented to more “serious” work than I wanted to put them to and I found the complexity not worth it for me. You produce more comprehensive products than I do, though so it might be worth the investment for you.

– Frotz 2022-07-04 16:15 UTC

---

Just as a follow-on, I created a simple Markdown document for my next FDC game, and ran it through pandoc to create a PDF and it generated an index and put my hyperlinks in the PDF properly, etc. It is a pretty simple document - I’ll try it with something more complex to see how it goes.

– Frotz 2022-07-04 16:55 UTC

---

For the moment I’m going to leave the “markdown” branch in my repository so that people can look at the source code, and compare it:

Halberds & Helmets Markdown sources

Halberds & Helmets LaTeX source

– Alex 2022-07-04 20:56 UTC

---

Oh, I didn’t know weasyprint and looks cool! My go-to solution for markdown → (HTML | PDF) is pandoc, I don’t know if you had considered that. You can easily add a sprinkle of latex if you need to when generating the PDF (I almost never do it).

– jjm 2022-07-05 06:29 UTC

---

For my Aachen houserules, I’m using Lowdown to transform my Markdown to HTML, then Chrome headless to turn that into a PDF, then psnup and pdftops to prepare duplex PS files (for easier printing then stapling). It’s held together with Ruby tape, styled with CSS. Works fine for me.

Aachen

Lowdown

– John 2022-07-05 10:54 UTC

John

---

I’ve been telling myself that my next book design will use XML+CSS.

For the ones previously, like

https://idiomdrottning.org/dagny

I’ve used Pandoc’s markdown with inline ConTeXt.

It looks similar to your LaTeX version but instead of stuff like “are \textbf{no clerics} in” I can instead write asterisks.

Pandoc lets you jam a custom template in there so there’s no preamble etc, my book just starts with the header. It looks like markdown but with the occasional \page and \cont.

What made me flip my mental script on markdown is that… (this isn’t literally true but it’s a better way to think of it)—

Instead of thinking of markdown as it’s own language that you need to extend with inline HTML or inline LaTeX where it “breaks down”, I can think of it as an extension to HTML/LaTeX.

Let’s say I’m writing a web page, something I do every day. I’m writing it in markdown, a.k.a. “HTML with shortcuts”—shortcuts like turning paragraphs to or asterisks to li or em or strong. Shortcuts that help me.

Of course, with enough shortcuts, including the template so I don’t have to write title or head or body or stuff, I can just start with the document itself, it then almost starts looking as its own standalone again. Except that when it “breaks down”, I’m not thinking of it as breaking down, I’m just like “oh, there’s no shortcut for this yet”.

– Sandra 2022-07-05 11:27 UTC

Sandra

---

One thing that annoys me is that it doesn’t nest: I write markdown, e.g. this table should be half width so it goes in a div, but a div is HTML and everything inside it is not processed as Mardown. I don’t want to create HTML first and then paste it there. So it has to be an extension to the Markdown processor. If I use the attr_list extension my processor offers, it breaks in all sorts of weird ways unless the use case is simple (the reason being it applies to the „last block element“ but in Mardown, after the last list item, or after the last row – does it apply to the list item, the list, the cell, row, or table? So now I have a handwritten Perl postprocessor… „Perl as duct tape“ or „glue language“ is OK, but also doesn’t help other people understand what’s going on, sadly. I’m still at a loss. Installing TexLive is about 20GiB of stuff but it’s old and conservative so it will hopefully work in 10 years, too. Adding Pandoc as a middle man doesn’t help, I think because I’m not pained by the paragraph breaks and the emph and textbf – what I hate is the fiddly bits this or that Unicode character not being supported, the hoops for table markup, the minipages, and so on.

– Alex 2022-07-05 14:18 UTC

---

I work in markdown a lot right now because I’m addicted to Obsidian (note-taking construct/software). But I get it. I’m sure LaTeX is superior. I looked at it and didn’t feel like learning it, suspecting what you are telling me – the effort might not be worth it. In the end I tend to do my work for consumption in Mac Pages because it’s a WYSIWYG, few-frills word processor. But ... yeah. Maybe not future-proof. Markdown and LaTeX seem more like survivors. No perfect solution I guess, just like there’s no perfect backpack or pen. Doesn’t stop me from looking and experimenting and wasting time and money.

– Ray Otus 2022-07-05 14:28 UTC

---

Haha, same! Same. 😅

– Alex 2022-07-05 14:34 UTC

---

I went and looked at markdown file for the one page I have that has a lot of divs

The web version of Introducing Late Night Fighting

and you’re right, the divs don’t have markdown in them, they’re fully rendered. My guess is that I just selected the region and ran shell-command-on-region with a prefix.

But that goes to what I’m trying to say here: these documents (for my blog) are “HTML with shortcuts”.

It makes the commonest and boringest stuff easy without getting in the way of normal HTML stuff.

And, with Pandoc, you could have the same for your LaTeX setup: all the conveniences of LaTeX but the most repetitive stuff hidden away.

It could look like this:

The rules offer **very little mechanics**: there aren't many
classes to choose from, no feats, no prestige classes and hardly any
special abilities or skills, no magic items for sale. Furthermore,
elves, dwarves and halflings are simply separate classes. There are no
elven thieves or dwarven mages. On the other hand, fewer rules also
leave **a lot of freedoom** for players. The characters are as
diplomatic, friendly or intimidating as the players want them to be.

We're playing in a [sandbox].
There is **no planned ending** for the campaign. The actions of
player characters determines the directions the campaign grows
in.\marginnote{Players determine where the campaign will head. If
  player characters investigate rumors and locations, I will develop
  the game world in that direction. The harder you look, the more
  there is to see.}

So instead of “it’s a bad language because it doesn’t cover everything I wanna do with LaTeX”, I feel that “it’s a good tool because it makes writing my LaTeX a li’l bit easier”.

– Sandra 2022-07-06 05:25 UTC

Sandra

---

This also exists but I’ve never used it:

pandoc-latex-extensions

Oh, wow, that led me to finds both

This kinda ugly div syntax

as well as

an extension that lets it parse pandoc inside divs, inside spans, or both depending on your setting.

Nice!

– Sandra 2022-07-06 05:28 UTC

Sandra

---

I hope find something that works for you. I went through a lot of the same struggles with my TTRPG and novels. Started with Lout, LaTeX, XeLaTeX. Then writing in Creole/Markdown and converting to *TeX. Eventually I stumbled into Markdown YAML converted to HTML and then to EPUB/PDF. WeasyPrint really helped there. Now I have a library (mfgames-writing) that is “good enough” for me so I can focus on writing.

– D. Moonfire 2022-07-19 06:16 UTC

---

It’s good to know that some people do find peace with their writing setup! I’m hoping to get there, soon. 😀

– Alex 2022-07-19 07:03 UTC

---

For what it’s worth, the article that pointed me in the productive direction for typesetting markdown (ease of writing) with LaTeX (high quality output) was How I stopped worrying and started using Markdown like TeX.

How I stopped worrying and started using Markdown like TeX

In short, the solution is gpp. It took a bit of experimentation (and escaping headaches) to find the `gpp` modes that worked well for me. It also allowed me to use different `gpp` macros to publish to different targets. E.g.:

gpp

gpp -x -T --nostdinc -I. --include latex.gpp
gpp -x -T --nostdinc -I. --include wiki.gpp

– Björn Buckwalter 2022-07-24 16:55 UTC

---

I can also add that, if I would start over, I would probably try Panda instead of `gpp`.

Panda

– Björn Buckwalter 2022-07-24 17:09 UTC

---

Oh wow…

its syntax is lighter and more flexible than that of GNU m4

My first website was HTML preprocessed with m4 to add headers and footers. 😆

Skimming the documentation of Panda, I still doubt that it would help me to quickly create nice pages with multiple tables like Ausrüstung.pdf. Perhaps that’s my main point: all of the solutions we mentioned are simple when the layout is simple. The tricky part is how to solve the difficult layout problems – or to change my mindset and no longer create difficult layout problems… 😬

Ausrüstung.pdf

– Alex 2022-07-24 18:53 UTC