I would like to write in Markdown, then use either <font color="red">red text</font>
or <span style="color: red;">red text</span>
to color text, so that when the .md file is checked in say Gitlab, the font color is automatically parsed when browsing the HTML formatted version - but I also want to use the same .md file as a source for a PDF via (xe)latex.
I have seen:
... and my options seem to be:
- Use
<span>
explicitly for HTML, and\textcolor
explicitly for PDF via Latex, which forces me to keep two versions of the same markdown document - Use Lua filter, and write like
violets are [blue]{color="blue"}
- which will definitely not be parsed by whatever Markdown-to-HTML engines used by Gitlab and such
So, I was thinking - it must be possible, that I write <span>
or <font>
in my file (which would/should be recognized by Gitlab and such parsers), and then have a Lua filter for pandoc, that would transform these into \textcolor
, when using the .md file as a source to create PDF.
Unfortunately, I suck at Lua, and definitely do not know the internal document model of Pandoc enough, to be able to easily guess how could I get to these kinds of tags in a Markdown file. So my question is: is there an existing filter or setting in pandoc
already that does this - or lacking that, a Lua filter script that looks up such tags in a markdown document, that I could use a base for this kind of filtering?