Directory macros/generic/markdown
The Markdown Package for TeX
The Markdown package converts CommonMark markup to TeX commands. The functionality is provided both as a Lua module, and as plain TeX, LaTeX, and ConTeXt macro packages that can be used to directly typeset TeX documents containing markdown markup. Unlike other converters, the Markdown package does not require any external programs, and makes it easy to redefine how each and every markdown element is rendered. Creative abuse of the markdown syntax is encouraged. 😉
Your first Markdown document
Using a text editor, create an empty directory named workdir/
. In it, create a text document named workdir/document.tex
with the following content:
\documentclass{book} \usepackage{markdown} \markdownSetup{pipeTables,tableCaptions} \begin{document} \begin{markdown} Introduction ============ ## Section ### Subsection Hello *Markdown*! | Right | Left | Default | Center | |------:|:-----|---------|:------:| | 12 | 12 | 12 | 12 | | 123 | 123 | 123 | 123 | | 1 | 1 | 1 | 1 | : Table \end{markdown} \end{document}
Next, run the LaTeXMK tool from our official Docker image on document.tex
:
docker run --rm -v "$PWD"/workdir:/workdir -w /workdir witiko/markdown \ latexmk -pdf -shell-escape -silent document.tex
Alternatively, you can install TeX Live (can take up to several hours) and use its LaTeXMK tool:
latexmk -cd -pdf -shell-escape -silent workdir/document.tex
A PDF document named workdir/document.pdf
should be produced and contain the following output:
Congratulations, you have just typeset your first Markdown document! 🥳
Use Markdown for continuous integration
Can't live without the latest features of the Markdown package in your continuous integration pipelines? It's ok, you can use our official Docker image as a drop-in replacement for the texlive/texlive:latest
Docker image! The following example shows a GitHub Actions pipeline, which will automatically typeset and prerelease a PDF document:
name: Typeset and prerelease the book on: push: jobs: typeset: runs-on: ubuntu-latest container: image: witiko/markdown:latest steps: - uses: actions/checkout@v4 - run: latexmk -lualatex document.tex - uses: marvinpinto/action-automatic-releases@latest permissions: contents: write with: title: The latest typeset book automatic_release_tag: latest prerelease: true repo_token: ${{ secrets.GITHUB_TOKEN }} files: document.pdf
In fact, this is how we automatically produce the latest documentation for the Markdown package.
Further information
For further information, consult one of the following:
- The user manual for either the released version or the latest development version, which can be produced by interpreting the
markdown.ins
file using a Unicode-aware TeX engine, such as LuaTeX (luatex markdown.ins
). The manual will reside in the filemarkdown.md
and the CSS stylesheetmarkdown.css
. - The technical documentation for either the released version or the latest development version, which can be typeset by running the LaTeXMK tool on the
markdown.dtx
file (latexmk
markdown.dtx) after [installing the Markdown package][install].
LaTeXMK should be included in your TeX distribution. The typeset documentation will reside in the filemarkdown.pdf
. - Tutorials and example documents by Lian Tze Lim at Overleaf:
- Journal articles published by TUGboat:
- Using Markdown inside TeX documents,
- Markdown 2.7.0: Towards lightweight markup in TeX,
- Making Markdown into a Microwave Meal,
- Markdown 2.10.0: LaTeX Themes & Snippets, Two Flavors of Comments, and LuaMetaTeX,
- Markdown 2.15.0: What's New?,
- Markdown 2.17.1: What's New, What's Next?,
- Attributes in Markdown,
- Markdown 3 at TUG 2023: Reflections from the Q&A session,
- Fast Regression Testing of TeX Packages: The Unreasonable Effectiveness of Batching, and
- Markdown Themes in Practice.
- Journal articles published by CSTUG Bulletin (in Czech and Slovak):
- Rendering Markdown inside TeX Documents,
- Markdown 2.8.1: Boldly Unto the Throne of Lightweight Markup in TeX,
- Markdown 2.10.0: LaTeX Themes & Snippets,
- Direct Typesetting of Various Document Formats in TeX Using the Pandoc Utility,
- High-Level Languages for TeX, and
- Markdown 3: What's New, What's Next?.
- Talks:
- Five Years of Markdown in LaTeX: What, Why, How, and Whereto (in Czech),
- Markdown 2.10.0: LaTeX Themes & Snippets, Two Flavors of Comments, and LuaMetaTeX (mirror, slides),
- A Self-Publisher's Take on Markdown and TeX (slides),
- A Gentle Introduction to Markdown for Writers (slides, example),
- Markdown 3: What's New, What's Next? (mirror, slides),
- An Implementation of the CommonMark Standard and new Syntax Extensions to the Markdown Package for TeX (slides), and
- Markdown Themes in Practice (preprint, slides)
- Theses:
Acknowledgements
Logo | Acknowledgement |
---|---|
I gratefully acknowledge the funding from the Faculty of Informatics at the Masaryk University in Brno, Czech Republic, for the development of the Markdown package in projects MUNI/33/12/2015, MUNI/33/1784/2020, MUNI/33/0776/2021, MUNI/33/1654/2022, and MUNI/33/1658/2022. | |
Extensive user documentation for the Markdown package was kindly written by Lian Tze Lim and published by Overleaf. | |
Support for content slicing (Lua options shiftHeadings and slice ) and pipe tables (Lua options pipeTables and tableCaptions ) was graciously sponsored by David Vins and Omedym. |
|
Fixes for issues 359,368,401,424,440,468,474, and487were graciously sponsored by the International Software Testing Qualifications Board (ISTQB). |
Contributing to the Development of Markdown
Apart from the example markdown documents, tests, and continuous integration, which are placed in the examples/
, tests/
, and .github/
directories, the complete source code and documentation of the package are placed in the markdown.dtx
document following the literate programming paradigm. Some useful commands, such as building the release archives and typesetting the documentation, are placed in the Makefile
file for ease of maintenance.
When the file markdown.ins
is interpreted using a Unicode-aware TeX engine, such LuaTeX (luatex markdown.ins
), several files are produced from the markdown.dtx
document. The make base
command is provided by Makefile
for convenience. In markdown.dtx
, the boundaries between the produced files are marked up using an XML-like syntax provided by the l3docstrip plain TeX package.
Running the LaTeXMK tool on the markdown.dtx
file (latexmk markdown.dtx
) after the Markdown package has been installed typesets the documentation. The make markdown.pdf
command is provided by Makefile
for convenience. In markdown.dtx
, the documentation is placed inside TeX comments and marked up using the ltxdockit LaTeX document class. Support for typesetting the documentation is provided by the doc LaTeX package.
To facilitate continuous integration and sharing of the Markdown package, there exists an official Docker image, which can be reproduced by running the docker build
command on Dockerfile
(docker build
-t witiko/markdown .). The
make docker-image command is provided by
Makefile
for convenience.
Contributed Software
Links to contributed third-party software for the Markdown package are available in the contributions/
directory. The intention is to show interesting tools for the Markdown package and to give them wider exposure without taking responsibility for their development or maintenance.
Citing Markdown
When citing Markdown in academic papers and theses, please use the following BibTeX entry:
@article{novotny2017markdown, author = {V\'{i}t Novotn\'{y}}, year = {2017}, title = {Using {M}arkdown Inside {\TeX} Documents}, journal = {TUGboat}, volume = {38}, number = {2}, pages = {214--217}, issn = {0896-3207}, url = {https://tug.org/TUGboat/tb38-2/tb119novotny.pdf}, urldate = {2020-07-31}, }
Alternatively, you can use the Novotny:2017:UMI
key from the tugboat.bib
BibTeX file that is included in your TeX distribution like this:
\cite{Novotny:2017:UMI} \bibliography{tugboat}
Download the contents of this package in one zip archive (1.6M).
markdown – Converting and rendering markdown documents inside TeX
The package provides facilities for the conversion of markdown markup to plain TeX. These are provided both in form of a Lua module and in form of plain TeX, LaTeX, and ConTeXt macro packages that enable the direct inclusion of markdown documents inside TeX documents.
Package | markdown |
Bug tracker | https://github.com/Witiko/markdown/issues |
Announcements | https://github.com/Witiko/markdown/releases |
Repository | https://github.com/Witiko/markdown |
Developers | https://github.com/Witiko/markdown/pulls |
Version | 3.9.0-0-g4f1abe21 2024-11-21 |
Licenses | The LaTeX Project Public License 1.3c |
Copyright | 2009–2016 John MacFarlane, Hans Hagen 2016–2024 Vít Starý Novotný, Andrej Genčur |
Maintainer | Vít Starý Novotný |
TDS archive | markdown.tds.zip |
Contained in | TeX Live as markdown MiKTeX as markdown |
Topics | Markup |