mdpre Markdown Preprocessor
A few days ago I released md2pptx, a Markdown to Powerpoint converter on GitHub as an open source project. You can find it here.
Now I’m releasing a companion program – mdpre. This is a preprocessor for Markdown. You can find it here.
I would’ve released them together and why I didn’t is a small story at my own expense: We in IBM have a system for requesting permission to open source software. I put in the cases for both mdpre and md2pptx at the same time. I got the permission email for md2pptx but didn’t spot the one for mdpre. I should have checked the status of the mdpre case but, life being too short, I didn’t get there for another week. Meanwhile I open sourced md2pptx.
All this by way of saying the pairing of mdpre and md2pptx is a strong one: Almost all my presentations are run through mdpre and the resulting Markdown through md2pptx. And one of the features of mdpre is a key reason why I do that.
My Workflow
When I begin a customer study I use a Keyboard Maestro macro that:
- Creates a folder for the study within the customer’s folder in Documents.
- Creates subfolders of this one for each presentation within the study.
- Creates files with the .mdp extension in these folders for each presentation.
- Pulls in some stock graphics and include files into the relevant subfolders.
- Creates a make file in each subfolder.
That saves me a lot of time and it’s very consistent. I’m showing you this as it might be a helpful model to follow if you use md2pptx and mdpre.
The Killer Feature For Me
But what is the key feature I mentioned just now?
It’s the ability to convert CSV data into a Markdown table.
For example, you might code
=csv
"A",1
"B",2
=endcsv
And you get something like this:
A | 1 |
---|---|
B | 2 |
The default for alignment in Markdown is left. But I don’t always want that, so I invented =colalign
:
=colalign l r
=csv
"A",1
"B",2
=endcsv
This aligns the first column left and the second column right -using the Markdown :-
and -:
syntax.
There is one further nuance – which would be ignored by a normal Markdown processor: =colwidth
:
=colalign l r
=colwidth 2 1
=csv
"A",1
"B",2
=endcsv
Here the first column is twice the width of the second – but only when rendered on a slide in md2pptx.
Other Notable Features
I less frequently need a few other things:
- Inclusion of files. The time I use this is when I want to include a CSV file but don’t want to paste it into the main document.
- Conditional processing. I used this in a couple of my conference presentations.
- Variables. Again, useful in conference presentations – to create consistency.
As with most things I do, if I get fed up enough I automate it. So I expect there will be additional features added to mdpre over time.
Talking of which, testing, bug reports and even contributions welcome.
One thought on “mdpre Markdown Preprocessor”