[Tex/LaTex] ny package with Markdown support


Sometimes, I have notes where I would not like to convert all portions to Tex format.
I normally then simply put such contexts under verbatim.
However, this is a rather crude approach.
So I started to wonder if you can use Markdown inside Tex.
I was originally inspired by this Hamilton's code where he uses R inside Tex, after he made his package available.

Dummy example of data which I would not like to convert to Tex:

% http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3458956/
\textbf{All here are antiseptics} % (used in living tissues on mucosa)
% Antiseptic is often disinfection
1 Iodum (Iodine)
2 Povidonum iodinatum
3 Ichthammolum (ammonia)
4 Viride nitens
5 Kalii permanganas (potassium permanganate)
6 Hydrogeniii peroxidum
7 Benzoylis peroxidum
8 Nitrofuralum
9 Acidum boricum
10 Sulfadiazinum argentum (silver sulfadiazine)
11 Benzalkonium
12 Propanolum/Benzalconium
13 Chlorhexidium
14 Cetylpyridinium
15 Dequalinium/Cinchocainum
16 Colini salicylas (salt of salicylic acid - colini adds here saliva production)
17 Hexetidinum (hexetidine)

% only 120 main drugs in exam - from 6 classes theoretically
% much more studied in practcals

A group
1 Halogen
2 Halogen
3 Aromatic compound
4 Dye compounds
5 Oxidizing agent
6 Oxidizing agent
7 Oxidizing agent
8 Nitrofurans
9 Acids 
10 Heavy metal (silver)
% Synthetic antibacterial
% Antibiotics are produced by living organisms (fungi, bacteria, actinomyces, ...)

OS: Debian 8.5
Linux kernel: 4.6 backports
Hardware: Asus Zenbook UX303UA
TeXLive: the latest, not the old one in apt-get

Best Answer

There is a new package for the inclusion of Markdown in plain TeX, LaTeX, and ConTeXt documents. Much like the package suggested by Michal in the accepted answer, this package is also based on the Lunamark parser. This time around, the parser was heavily modified, so that it allows the user to control the expansion of Markdown tokens to TeX tokens:

  renderers = {
    link     = {#1},        % Render a link as the link label.
    emphasis = {\emph{#1}}, % Render emphasis using `\emph`.
  _Hello,_ [Stack Exchange](http://tex.stackexchange.com)!

The above code produces “Hello, Stack Exchange!”. Note that setting up these mappings is not mandatory (though often useful); the defaults should be quite sane. Package authors are encouraged to redefine renderer prototypes (see section 2.2.4 in the package documentation) to override the defaults without overriding the user mappings.

Any engine that supports shell access (pdfTeX, XeTeX) can be used, not just LuaTeX. Note, however, that you need to provide the --shell-escape option or set shell_escape=t in the texmf.cnf file when you don't use LuaTeX. This is similar to other packages (such as Geoffrey M. Poore's minted) that require shell access.

The package also supports syntax extensions such as citations, fenced code blocks, and other (see section 2.1.2 in the package documentation), although I did backport these to Lunamark, so they can now be used with Michal's package as well.

Related Question