This would produce a nice PDF from the .md files. I first extracted the latex template this way:
pandoc -D latex > template.tex
This gives me the default latex template used by pandoc. I can then customize it as I want.
Regarding shortcodes, I apply the following sed transformations:
This will replace each shortcode with an equivalent latex environment. For example, {{%warning%}} will be changed into \begin{warning}. The sed code looks awful, but that’s because there is a lot of escaping to do.
Finally, in template.tex I added the code for creating the info boxes:
% Colored boxes
\renewenvironment{shaded}[1]
{\def\FrameCommand{\colorbox{#1}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
% info boxes.
% first param: color of the box
% second param: symbol to use for the icon
\newenvironment{admonition}[2]
{\begin{shaded}{#1!15}%
% minipage for the icon
\begin{minipage}[c][1cm][c]{1.5cm}
\begin{tikzpicture}[remember picture,overlay]
% create a colored cricle, with the symbol inside
\draw[#1, fill=#1!100] (0.4,0) circle (.4cm)
node {\fontsize{8mm}{11mm}\usefont{T1}{put}{b}{b}\color{white}#2};
\end{tikzpicture}
\end{minipage}%
% minipage for the text
\begin{minipage}[t]{.9\textwidth - 1.5cm}}
{\end{minipage}\end{shaded}}
\newenvironment{action}
{\begin{admonition}{green}{>}}%
{\end{admonition}}%
\newenvironment{warning}
{\begin{admonition}{red}{!}}%
{\end{admonition}}%
\newenvironment{note}
{\begin{admonition}{blue}{?}}%
{\end{admonition}}%
However, this method is not so robust (as it relies on sed replacements), and will not work on shortcode parameters, such as: {{%warning title="attention"%}}.
Do you know a better way?
Take this with the disclaimer that I don’t have a lot of experience with either LaTex or Pandoc, so YMMV.
Do you specifically need to use Pandoc, or is it more of a middleman to get from Hugo + markdown to LaTex? You could generate the html from Hugo and use that as input to generate tex.
Another avenue to explore would be Hugo’s custom output formats. The idea is to generate LaTex as a custom output format. But I don’t know how much work that would be, not having done that personally…
That wasn’t really very helpful, eh.
I hope whichever solution you end up with that you give an update, as I’m quite intrigued by this now. Best of luck.