February 02, 2021 Stardate: 74556.0 Tagged as: Pandoc Pelican
This article documents installing the pelican plugin Pandoc-Reader, which changes the engine that converts Markdown syntax to html from the standard Python-Markdown to Pandoc..
Why? Pandoc is awesome on many levels, but specifically for this blog, it allows me to write pandoc’s flavor of markdown. I added Python-Markdown Extensions that gave some cool features, but it still didn’t satisfy me.
Some of my personal favorite features are:
One feature it doesn’t have are reStructured-like admonitions. This is something that Markdown Extensions had 😞 - but I saw a Pandoc filter that looked like it will implement those.
The installation is easy and the instructions are clear. Make sure you have at least Pandoc 2.11, then pip install the plugin.
python -m pip install pelican-pandoc-reader
One note is that your metadata (Title:, Date:, etc.) has to be in YAML format. That is means fenced by triple dashes. Example:
---
Title: Me
Date: 2021-01-01
---
If you already have a bunch of articles written, here is a simple python script that should convert it for you.
You also need to add these variables to the pelicanconf.py
file.
# Arguments passed into pandoc
= [
PANDOC_ARGS "--mathjax",
]
# Non-Pandoc Extensions that are not enabled by default in pandoc
# https://pandoc.org/MANUAL.html#non-pandoc-extensions
= [
PANDOC_EXTENSIONS "+abbreviations",
"+backtick_code_blocks",
"+emoji"
]
Here are some examples of the cool features built-in Pandoc Markdown.
MARKDOWN:
Here is a footnote reference,[^1] and another.[^longnote]
[^1]: Here is the footnote.
[^longnote]: Here's one with multiple blocks.
HTML RESULT:
Here is a footnote reference,1 and another.2
Pandoc converys textual emojis into Unicode emoticons. https://www.webfx.com/tools/emoji-cheat-sheet/
MARKDOWN:
:smiley:
:cow:
HTML RESULT:
MARKDOWN:
You can go directly to <https://.google.com> to find it.
HTML RESULT:
You can go directly to https://google.com to find it.
MARKDOWN:
Go see the very last header named [MathJax](#mathjax)
HTML RESULT:
Go see the very first header named SmartyPants
Write this in MARKDOWN:
"curly quotes"
... are ellipses
-- are en-dashes
--- are em-dashes
To get this HTML RESULT:
MARKDOWN:
| The limerick packs laughs anatomical
| In space that is quite economical.
| But the good ones I've seen
| So seldom are clean
| And the clean ones so seldom are comical
| 200 Main St.
| Berkeley, CA 94718
HTML RESULT:
MARKDOWN:
COMPACT LISTS
-------------
* one
* two
* three
HTML RESULT:
LOOSE LISTS
-----------
* one
* two
* three
HTML RESULT:
one
two
three
MARKDOWN:
(1) One
(2) Two
a. 2.1
b. 2.2
(3) Three
HTML RESULT:
MARKDOWN:
#. one
#. two
#. three
HTML RESULT:
MARKDOWN:
9) Ninth
10) Tenth
11) Eleventh
i. subone
ii. subtwo
iii. subthree
HTML RESULT:
MARKDOWN:
Term 1
~ Definition 1
Term 2
~ Definition 2a
~ Definition 2b
HTML RESULT:
**NOTE: I styled the definitions with CSS
MARKDOWN:
(@) My first example will be numbered (1).
(@) My second example will be numbered (2).
Explanation of examples.
(@) My third example will be numbered (3).
HTML RESULT:
Explanation of examples.
MARKDOWN:
H~2~O is a liquid. 2^10^ is 1024.
HTML RESULT:
H2O is a liquid. 210 is 1024.
MARKDOWN:
This ~~is deleted text.
HTML RESULT:
This is deleted text.
MARKDOWN:
[Hello Everyone]{.smallcaps}, how are you doing?
HTML RESULT:
Hello Everyone, how are you doing?
MARKDOWN:
This is an inline math $y = mx +b$ which is cool.
HTML RESULT:
This is an inline math \(y = mx +b\) which is cool.
MARKDOWN:
This is a full math equation.
$$ y = mx +b $$
HTML RESULT:
This is a full math equation. \[ y = mx +b \]
This is an automated list of software versions used during the writing of this article.
Software Version
Pelican 4.5.4
Pandoc 2.11
Pandoc-Reader 1.0.0
Python 3.7.9