summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-14 20:38:52 +0000
committerKarl Berry <karl@freefriends.org>2020-09-14 20:38:52 +0000
commita3ba1abf10468e4cc434f285fabe14ab5fe86158 (patch)
tree155acdc9224098902aebfbc79b77a1b3be2f0294 /Master/texmf-dist/source/generic
parentc8d2ea73c06009f96ad1c3a66b69d20d57209dc7 (diff)
markdown (14sep20)
git-svn-id: svn://tug.org/texlive/trunk@56342 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic')
-rw-r--r--Master/texmf-dist/source/generic/markdown/markdown.dtx831
1 files changed, 731 insertions, 100 deletions
diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx
index 0cf9f4f9ace..a3ebaecd88d 100644
--- a/Master/texmf-dist/source/generic/markdown/markdown.dtx
+++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx
@@ -2,7 +2,7 @@
%<*driver>
\documentclass{ltxdockit}
\usepackage[american]{babel}
-\usepackage{amsmath,btxdockit,doc,fancyvrb,hologo,microtype,minted,xcolor}
+\usepackage{amsmath,btxdockit,doc,fancyvrb,hologo,microtype,minted}
\usepackage{fontspec}
\defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{}
@@ -20,7 +20,7 @@
\setkomafont{captionlabel}{\bfseries\sffamily\spotcolor}
\hypersetup{citecolor=spot}
\let\oldCodelineNo\theCodelineNo
-\def\theCodelineNo{\textcolor{gray}{\oldCodelineNo}}
+\def\theCodelineNo{\textcolor[gray]{0.5}{\oldCodelineNo}}
% Define some markup.
\let\pkg\relax % A package name
@@ -92,8 +92,7 @@
\CodelineIndex
% Set up the bibliography.
-\usepackage{filecontents}
-\begin{filecontents}{markdown.bib}
+\begin{filecontents}[overwrite,nosearch,noheader]{markdown.bib}
@online{sotkov17,
author = {Sotkov, Anton},
title = {File transclusion syntax for Markdown},
@@ -121,6 +120,14 @@
date = {2017-04-15},
url = {http://mirrors.ctan.org/macros/latex/base/doc.pdf},
urldate = {2018-02-19}}
+@book{poore17,
+ author = {Poore, Geoffrey M.},
+ title = {The \texttt{minted} Package},
+ subtitle = {Highlighted source code in \LaTeX},
+ date = {2017-07-19},
+ version = {v2.5},
+ url = {http://mirrors.ctan.org/macros/latex/contrib/minted/minted.pdf},
+ urldate = {2020-09-01}}
@online{novotny15,
author = {Novotný, Vít},
year = {2015},
@@ -539,7 +546,7 @@ 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. ;-)
- [markdown]: https://daringfireball.net/projects/markdown/basics/
+ [markdown]: https://daringfireball.net/projects/markdown/basics
(Daring Fireball: Markdown Basics)
[pkg]: https://ctan.org/pkg/markdown
(CTAN: Package markdown)
@@ -570,7 +577,7 @@ documentation][techdoc].
% \fi
% \begin{macrocode}
local metadata = {
- version = "2.8.2",
+ version = "2.9.0",
comment = "A module for the conversion from markdown to plain TeX",
author = "John MacFarlane, Hans Hagen, Vít Novotný",
copyright = {"2009-2016 John MacFarlane, Hans Hagen",
@@ -989,7 +996,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
[Kpathsea]: https://tug.org/kpathsea/ (Kpathsea - TeX Users Group)
@@ -1318,7 +1325,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -1468,7 +1475,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the text
@@ -1551,6 +1558,224 @@ defaultOptions.cacheDir = "."
% \iffalse
%</lua,lua-cli>
%<*manual-options>
+
+#### Option `frozenCacheFileName`
+
+`frozenCacheFileName` (default value: `"frozenCache.tex"`)
+
+% \fi
+% \begin{markdown}
+%
+% \Valitem[frozenCache.tex]{frozenCacheFileName}{path}
+%
+: A path to an output file (frozen cache) that will be created when
+ the \Opt{finalizeCache} option is enabled and will contain a mapping
+ between an enumeration of markdown documents and their auxiliary cache
+ files.
+
+ The frozen cache makes it possible to later typeset a plain \TeX{}
+ document that contains markdown documents without invoking Lua using
+ the \m{markdownOptionFrozenCache} plain \TeX{} option. As a result, the
+ plain \TeX{} document becomes more portable, but further changes in the
+ order and the content of markdown documents will not be reflected.
+
+% \end{markdown}
+% \iffalse
+
+##### Lua Module Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\input markdown
+\directlua{
+ local markdown = require("markdown")
+ local convert = markdown.new({finalizeCache = true, frozenCacheFileName = "cache.tex"})
+ local input = "Hello *world*!"
+ tex.sprint(convert(input)) }
+\bye
+```````
+Then, invoke LuaTeX from the terminal:
+``` sh
+luatex document.tex
+```````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizeCache` and `frozenCacheFileName`
+options.
+
+##### Lua CLI Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\input markdown
+\input hello
+\bye
+```````
+Using a text editor, create a text document named `hello.md` with the
+following content:
+``` md
+Hello *world*!
+``````
+Next, invoke LuaTeX from the terminal:
+``` sh
+texlua ⟨CLI pathname⟩ finalizeCache=true frozenCacheFileName=cache.tex -- hello.md hello.tex
+luatex document.tex
+```````
+where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
+such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
+`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
+script file using [Kpathsea][].
+
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizeCache` and `frozenCacheFileName`
+options.
+
+##### Plain \TeX{} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\input markdown
+\def\markdownOptionFinalizeCache{true}
+\def\markdownOptionFrozenCacheFileName{cache.tex}
+\markdownBegin
+Hello *world*!
+\markdownEnd
+\bye
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+luatex document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizeCache` and `frozenCacheFileName`
+options.
+
+Next, create a new text document `frozen-document.tex` with the following
+content:
+``` tex
+\input markdown
+\def\markdownOptionFrozenCache{true}
+\def\markdownOptionFrozenCacheFileName{cache.tex}
+\markdownBegin
+Hi *world*!
+\markdownEnd
+\bye
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+pdftex -no-shell-escape frozen-document.tex
+``````
+A PDF document named `frozen-document.pdf` should be produced and contain the
+text “Hello *world*!” Since we used the contents of the frozen cache using
+the `\markdownOptionFrozenCache` option, we were able to typeset the
+document without accessing the shell or invoking Lua, but the change in the
+content of the markdown document from “Hello *world*!” to “Hi *world*!” was
+not reflected.
+
+##### \LaTeX{} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\documentclass[finalizecache]{article}
+\usepackage[frozenCacheFileName=cache.tex]{markdown}
+\begin{document}
+\begin{markdown}
+Hello *world*!
+\end{markdown}
+\end{document}
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+lualatex document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizecache` and `frozenCacheFileName`
+options.
+
+Next, create a new text document `frozen-document.tex` with the following
+content:
+``` tex
+\documentclass[frozencache]{article}
+\usepackage[frozenCacheFileName=cache.tex]{markdown}
+\begin{document}
+\begin{markdown}
+Hi *world*!
+\end{markdown}
+\end{document}
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+pdflatex -no-shell-escape frozen-document.tex
+``````
+A PDF document named `frozen-document.pdf` should be produced and contain the
+text “Hello *world*!” Since we used the contents of the frozen cache using
+the `frozencache` option, we were able to typeset the document without
+accessing the shell or invoking Lua, but the change in the content of the
+markdown document from “Hello *world*!” to “Hi *world*!” was not reflected.
+
+##### \Hologo{ConTeXt} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\usemodule[t][markdown]
+\def\markdownOptionFinalizeCache{true}
+\def\markdownOptionFrozenCacheFileName{cache.tex}
+\starttext
+\startmarkdown
+Hello *world*!
+\stopmarkdown
+\stoptext
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+context document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizeCache` and `frozenCacheFileName`
+options.
+
+Next, create a new text document `frozen-document.tex` with the following
+content:
+``` tex
+\usemodule[t][markdown]
+\def\markdownOptionFrozenCache{true}
+\def\markdownOptionFrozenCacheFileName{cache.tex}
+\starttext
+\startmarkdown
+Hi *world*!
+\stopmarkdown
+\stoptext
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+texexec --passon=--no-shell-escape frozen-document.tex
+``````
+A PDF document named `frozen-document.pdf` should be produced and contain the
+text “Hello *world*!” Since we used the contents of the frozen cache using
+the `\markdownOptionFrozenCache` option, we were able to typeset the document
+without accessing the shell or invoking Lua, but the change in the content of
+the markdown document from “Hello *world*!” to “Hi *world*!” was not reflected.
+
+%</manual-options>
+%<*lua,lua-cli>
+% \fi
+% \begin{macrocode}
+defaultOptions.frozenCacheFileName = "frozenCache.tex"
+% \end{macrocode}
+% \par
+% \iffalse
+%</lua,lua-cli>
+%<*manual-options>
% \fi
% \begin{markdown}
%
@@ -1642,7 +1867,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -1859,7 +2084,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -2093,7 +2318,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -2311,7 +2536,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -2708,7 +2933,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -3425,6 +3650,160 @@ defaultOptions.fencedCode = false
%</lua,lua-cli>
%<*manual-options>
+#### Option `finalizeCache`
+
+`finalizeCache` (default value: `false`)
+
+% \fi
+% \begin{markdown}
+%
+% \Optitem[false]{finalizeCache}{\opt{true}, \opt{false}}
+%
+: Whether an output file specified with the \Opt{frozenCacheFileName} option
+ (frozen cache) that contains a mapping between an enumeration of markdown
+ documents and their auxiliary cache files will be created.
+
+ The frozen cache makes it possible to later typeset a plain \TeX{}
+ document that contains markdown documents without invoking Lua using
+ the \m{markdownOptionFrozenCache} plain \TeX{} option. As a result, the
+ plain \TeX{} document becomes more portable, but further changes in the
+ order and the content of markdown documents will not be reflected.
+
+% \end{markdown}
+% \iffalse
+
+##### Plain \TeX{} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\input markdown
+\def\markdownOptionFinalizeCache{true}
+\markdownBegin
+Hello *world*!
+\markdownEnd
+\bye
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+luatex document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced as we requested using the
+`finalizeCache` option.
+
+Next, change the content of `document.tex` as follows:
+``` tex
+\input markdown
+\def\markdownOptionFrozenCache{true}
+\markdownBegin
+Hi *world*!
+\markdownEnd
+\bye
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+pdftex -no-shell-escape document.tex
+``````
+A new PDF document named `document.pdf` should be produced and contain the
+same text “Hello *world*!” Since we used the contents of the frozen cache using
+the `\markdownOptionFrozenCache` option, we were able to typeset the document
+without accessing the shell or invoking Lua, but the change in the content of
+the markdown document from “Hello *world*!” to “Hi *world*!” was not reflected.
+
+##### \LaTeX{} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\documentclass[finalizecache]{article}
+\usepackage{markdown}
+\begin{document}
+\begin{markdown}
+Hello *world*!
+\end{markdown}
+\end{document}
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+lualatex document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced as we requested using the
+`finalizecache` option.
+
+Next, change the content of `document.tex` as follows:
+``` tex
+\documentclass[frozencache]{article}
+\usepackage{markdown}
+\begin{document}
+\begin{markdown}
+Hi *world*!
+\end{markdown}
+\end{document}
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+pdflatex -no-shell-escape document.tex
+``````
+A new PDF document named `document.pdf` should be produced and contain the
+same text “Hello *world*!” Since we used the contents of the frozen cache using
+the `\markdownOptionFrozenCache` option, we were able to typeset the document
+without accessing the shell or invoking Lua, but the change in the content of
+the markdown document from “Hello *world*!” to “Hi *world*!” was not reflected.
+
+##### \Hologo{ConTeXt} Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\usemodule[t][markdown]
+\def\markdownOptionFinalizeCache{true}
+\starttext
+\startmarkdown
+Hello *world*!
+\stopmarkdown
+\stoptext
+```````
+Next, invoke LuaTeX from the terminal:
+``` sh
+context document.tex
+``````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache will also be produced in the `cache.tex`
+output file as we requested using the `finalizeCache` option.
+
+Next, change the content of `document.tex` as follows:
+``` tex
+\usemodule[t][markdown]
+\def\markdownOptionFrozenCache{true}
+\starttext
+\startmarkdown
+Hi *world*!
+\stopmarkdown
+\stoptext
+```````
+Last, invoke pdfTeX without shell access from the terminal:
+``` sh
+texexec --passon=--no-shell-escape document.tex
+``````
+A new PDF document named `document.pdf` should be produced and contain the
+same text “Hello *world*!” Since we used the contents of the frozen cache using
+the `\markdownOptionFrozenCache` option, we were able to typeset the document
+without accessing the shell or invoking Lua, but the change in the content of
+the markdown document from “Hello *world*!” to “Hi *world*!” was not reflected.
+
+%</manual-options>
+%<*lua,lua-cli>
+% \fi
+% \begin{macrocode}
+defaultOptions.finalizeCache = false
+% \end{macrocode}
+% \par
+% \iffalse
+%</lua,lua-cli>
+%<*manual-options>
+
#### Option `footnotes`
`footnotes` (default value: `false`)
@@ -3584,6 +3963,61 @@ defaultOptions.footnotes = false
%</lua,lua-cli>
%<*manual-options>
+#### Option `frozenCacheCounter`
+
+`frozenCacheCounter` (default value: `0`)
+
+% \fi
+% \begin{markdown}
+%
+% \Valitem[0]{frozenCacheCounter}{number}
+%
+: The number of the current markdown document that will be stored in
+ an output file (frozen cache) when the \Opt{finalizeCache} is enabled.
+ When the document number is 0, then a new frozen cache will be created.
+ Otherwise, the frozen cache will be appended.
+
+ Each frozen cache entry will define a \TeX{} macro
+ `\markdownFrozenCache`\meta{number} that will typeset markdown document
+ number \meta{number}.
+
+% \end{markdown}
+% \iffalse
+
+##### Lua Module Example {.unnumbered}
+
+Using a text editor, create a text document named `document.tex` with the
+following content:
+``` tex
+\input markdown
+\directlua{
+ local markdown = require("markdown")
+ local firstConvert = markdown.new({finalizeCache = true, frozenCacheCounter = 0})
+ local firstInput = "Hello"
+ local secondConvert = markdown.new({finalizeCache = true, frozenCacheCounter = 1})
+ local secondInput = "*world*!"
+ tex.sprint(firstConvert(firstInput) .. [[ ]] .. secondConvert(secondInput)) }
+\bye
+```````
+Then, invoke LuaTeX from the terminal:
+``` sh
+luatex document.tex
+```````
+A PDF document named `document.pdf` should be produced and contain the text
+“Hello *world*!” A frozen cache with two entries will also be produced as we
+requested using the `frozenCacheCounter` option.
+
+%</manual-options>
+%<*lua,lua-cli>
+% \fi
+% \begin{macrocode}
+defaultOptions.frozenCacheCounter = 0
+% \end{macrocode}
+% \par
+% \iffalse
+%</lua,lua-cli>
+%<*manual-options>
+
#### Option `hashEnumerators`
`hashEnumerators` (default value: `false`)
@@ -3849,7 +4283,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -4089,7 +4523,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -4845,7 +5279,7 @@ luatex document.tex
where \meta{CLI pathname} corresponds to the location of the Lua CLI script file,
such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or
`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows
-systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI
+systems. Use the command `kpsewhich -a markdown-cli.lua` to locate the Lua CLI
script file using [Kpathsea][].
A PDF document named `document.pdf` should be produced and contain the
@@ -5509,6 +5943,8 @@ for i = 1, #arg do
default_type = type(defaultOptions[key])
if default_type == "boolean" then
options[key] = (value == "true")
+ elseif default_type == "number" then
+ options[key] = tonumber(value)
else
if default_type ~= "string" then
if default_type == "nil" then
@@ -5660,8 +6096,8 @@ pdftex --shell-escape document.tex
%
% \end{markdown}
% \begin{macrocode}
-\def\markdownLastModified{2020/03/20}%
-\def\markdownVersion{2.8.2}%
+\def\markdownLastModified{2020/09/14}%
+\def\markdownVersion{2.9.0}%
% \end{macrocode}
% \par
% \begin{markdown}
@@ -5778,8 +6214,63 @@ the `markdown` Lua module. They are supported by all higher-level interfaces of
the Markdown package, i.e. the plain \TeX{}, \LaTeX{} and \Hologo{ConTeXt}
interfaces.
+%</manual-options>
+%<*tex>
% \fi
+% \par
% \begin{markdown}
+%
+%#### Finalizing and Freezing the Cache
+% The \mdef{markdownOptionFinalizeCache} option corresponds to the Lua
+% interface \Opt{finalizeCache} option, which creates an output file
+% \m{markdownOptionFrozenCacheFileName} (frozen cache) that contains a mapping
+% between an enumeration of the markdown documents in the plain \TeX{} document
+% and their auxiliary files cached in the \Opt{cacheDir} directory.
+%
+% \end{markdown}
+% \begin{macrocode}
+\let\markdownOptionFinalizeCache\undefined
+% \end{macrocode}
+% \par
+% \iffalse
+%</tex>
+%<*manual-options>
+
+#### Finalizing and Freezing the Cache
+
+% \fi
+% \begin{markdown}
+%
+The \mdef{markdownOptionFrozenCache} option uses the mapping previously
+% created by the \m{markdownOptionFinalizeCache} option,
+% \iffalse
+created by the Lua interface \Opt{finalizeCache} option,
+% \fi
+and uses it to typeset the plain \TeX{} document without invoking Lua. As a
+result, the plain \TeX{} document becomes more portable, but further changes
+in the order and the content of markdown documents will not be reflected. It
+defaults to `false`.
+
+% The standard usage of the above two options is as follows:
+% \iffalse
+The standard usage of the \Opt{finalizeCache} and \m{markdownOptionFrozenCache}
+options is as follows:
+% \fi
+
+1. Remove the \Opt{cacheDir} cache directory with stale auxiliary cache
+ files.
+% 2. Enable the \m{markdownOptionFinalizeCache} option.
+% \iffalse
+2. Enable the \Opt{finalizeCache} option.
+% \fi
+3. Typeset the plain \TeX{} document to populate and finalize the cache.
+4. Enable the \m{markdownOptionFrozenCache} option.
+5. Publish the source code of the plain \TeX{} document and the
+ \Opt{cacheDir} directory.
+
+% \iffalse
+For more information, see the examples for the \Opt{finalizeCache} option.
+% \fi
#### File and Directory Names
@@ -5848,9 +6339,9 @@ interfaces.
% \begin{markdown}
%
% The \mdef{markdownOptionOutputDir} macro sets the path to the directory that
-% will contain the cache files produced by the Lua implementation and also the
-% auxiliary files produced by the plain \TeX{} implementation. The option
-% defaults to `.`.
+% will contain the auxiliary cache files produced by the Lua implementation and
+% also the auxiliary files produced by the plain \TeX{} implementation. The
+% option defaults to `.`.
%
% The path must be set to the same value as the `-output-directory` option of
% your \TeX{} engine for the package to function correctly. We need this macro
@@ -5876,6 +6367,20 @@ interfaces.
% \begin{macrocode}
\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}%
% \end{macrocode}
+% \par
+% \begin{markdown}
+%
+% The \mdef{markdownOptionFrozenCacheFileName} macro corresponds to the Lua
+% interface \Opt{frozenCacheFileName} option that sets the path to an output
+% file (frozen cache) that will contain a mapping between an enumeration of the
+% markdown documents in the plain \TeX{} document and their auxiliary cache
+% files. The option defaults to `frozenCache.tex`. The same limitations apply
+% here as in the case of the \m{markdownOptionHelperScriptFileName} macro.
+%
+% \end{markdown}
+% \begin{macrocode}
+\def\markdownOptionFrozenCacheFileName{\markdownOptionCacheDir/frozenCache.tex}
+% \end{macrocode}
%
% \iffalse
%</tex>
@@ -5889,8 +6394,9 @@ Markdown to \TeX{}:
- `\markdownOptionInputTempFileName`,
- `\markdownOptionOutputTempFileName`,
- `\markdownOptionErrorTempFileName`,
-- `\markdownOptionOutputDir`, and
-- `\markdownOptionCacheDir`.
+- `\markdownOptionOutputDir`,
+- `\markdownOptionCacheDir`, and
+- `\markdownOptionFrozenCacheFileName`.
Using a text editor, create a folder named `output-directory` and a text
document named `document.tex` with the following content:
@@ -5903,6 +6409,8 @@ document named `document.tex` with the following content:
\def\markdownOptionErrorTempFileName{error-output.txt}
\def\markdownOptionOutputDir{output-directory}
\def\markdownOptionCacheDir{output-directory/cache-directory}
+\markdownOptionFinalizeCachetrue
+\def\markdownOptionFrozenCacheFileName{output-directory/cache-directory/frozen-cache.tex}
\markdownBegin
Hello *world*!
\markdownEnd
@@ -5989,7 +6497,8 @@ The \mdef{markdownOptionStripPercentSigns} macro controls whether a percent
sign (`%`) at the beginning of a line will be discarded when reading Markdown
input from a \TeX{} document. This enables the use of markdown when writing
\TeX{} package documentation using the [Doc \LaTeX{} package][doc] by Frank
-Mittelbach.
+Mittelbach. The recognized values of the macro are `true` (discard) and `false`
+(retain). It defaults to `false`.
[doc]: https://ctan.org/pkg/doc (doc – Format LaTeX documentation)
@@ -6029,34 +6538,13 @@ A PDF document named `document.pdf` should be produced and contain the text
% Markdown input (see Section~\ref{sec:buffering}) or not. Notably, this
% enables the use of markdown when writing \TeX{} package documentation using
% the \pkg{Doc} \LaTeX{}~package~[@mittelbach17] or similar. The recognized
-% values of the macro are `true` (discard) and `false` (retain).
+% values of the macro are `true` (discard) and `false` (retain). It defaults
+% to `false`.
%
% \end{markdown}
% \begin{macrocode}
\def\markdownOptionStripPercentSigns{false}%
% \end{macrocode}
-% \par
-% \begin{markdown}
-%
-% The \mdef{markdownIfOption}`{`\meta{name}`}` macro is provided for testing,
-% whether the value of `\markdownOption`\meta{name} is `true` or `false`.
-%
-% \end{markdown}
-% \begin{macrocode}
-\def\markdownIfOption#1{%
- \def\next##1##2##3##4##5{%
- \expandafter\def\expandafter\next\expandafter{%
- \csname iffalse\endcsname}%
- \if##1t\if##2r\if##3u\if##4e
- \expandafter\def\expandafter\next\expandafter{%
- \csname iftrue\endcsname}%
- \fi\fi\fi\fi
- \next}%
- \expandafter\expandafter\expandafter\next
- \csname markdownOption#1\endcsname\relax\relax\relax\relax\relax}
-% \end{macrocode}
-% \par
-%
% \iffalse
%</tex>
%<*manual-tokens>
@@ -6355,7 +6843,7 @@ following text:
#### Ellipsis Renderer
The \mdef{markdownRendererEllipsis} macro replaces any occurance of ASCII
ellipses in the input text. This macro will only be produced, when the
- \Opt{smartEllipses} option is `true`. The macro receives no arguments.
+ \Opt{smartEllipses} option is enabled. The macro receives no arguments.
% \end{markdown}
%
@@ -7683,7 +8171,7 @@ an ordered list. The macro receives no arguments.
The \mdef{markdownRendererOlItemWithNumber} macro represents an item in an
ordered list. This macro will only be produced, when the \Opt{startNumber}
-option is `true`. The macro receives no arguments.
+option is enabled. The macro receives no arguments.
% \end{markdown}
%
@@ -8010,7 +8498,7 @@ following text:
#### Definition List Renderers
The following macros are only produced, when the \Opt{definitionLists} option
-is `true`.
+is enabled.
The \mdef{markdownRendererDlBegin} macro represents the beginning of a
definition list that contains an item with several paragraphs of text (the
@@ -8859,7 +9347,7 @@ filename of a file contaning the code block contents.
The \mdef{markdownRendererInputFencedCode} macro represents a fenced code
block. This macro will only be produced, when the \Opt{fencedCode} option is
-`true`. The macro receives two arguments that correspond to the filename of
+enabled. The macro receives two arguments that correspond to the filename of
a file contaning the code block contents and to the code fence infostring.
% \end{markdown}
@@ -9330,7 +9818,7 @@ following text:
#### Footnote Renderer
The \mdef{markdownRendererFootnote} macro represents a footnote. This macro
-will only be produced, when the \Opt{footnotes} option is `true`. The
+will only be produced, when the \Opt{footnotes} option is enabled. The
macro receives a single argument that corresponds to the footnote text.
% \end{markdown}
@@ -9444,9 +9932,9 @@ following text:
#### Parenthesized Citations Renderer
The \mdef{markdownRendererCite} macro represents a string of one or more
parenthetical citations. This macro will only be produced, when the
-\Opt{citations} option is `true`. The macro receives the parameter
-`{`\meta{number of citations}`}` followed by \meta{suppress
-author}`{`\meta{prenote}`}{`\meta{postnote}`}{`\meta{name}`}` repeated
+\Opt{citations} option is enabled. The macro receives the parameter
+`{`\meta{number of citations}`}` followed by \meta{suppress author}
+`{`\meta{prenote}`}{`\meta{postnote}`}{`\meta{name}`}` repeated
\meta{number of citations} times. The \meta{suppress author} parameter is
either the token `-`, when the author's name is to be suppressed, or `+`
otherwise.
@@ -9532,7 +10020,7 @@ following text:
#### Text Citations Renderer
The \mdef{markdownRendererTextCite} macro represents a string of one or more
text citations. This macro will only be produced, when the
-\Opt{citations} option is `true`. The macro receives parameters in the same
+\Opt{citations} option is enabled. The macro receives parameters in the same
format as the \m{markdownRendererCite} macro.
% \end{markdown}
@@ -9614,7 +10102,7 @@ following text:
#### Table Renderer
The \mdef{markdownRendererTable} macro represents a table. This macro will only
-be produced, when the \Opt{pipeTables} option is `true`. The macro receives the
+be produced, when the \Opt{pipeTables} option is enabled. The macro receives the
parameters `{`\meta{caption}`}{`\meta{number of rows}`}{`\meta{number of columns}`}`
followed by `{`\meta{alignments}`}` and then by `{`\meta{row}`}` repeated
\meta{number of rows} times, where \meta{row} is `{`\meta{column}`}` repeated
@@ -10285,6 +10773,43 @@ pdflatex --shell-escape document.tex
% \par
% \begin{markdown}
%
+% The \m{markdownOptionFinalizeCache} and \m{markdownOptionFrozenCache} plain
+% \TeX{} options are exposed through \LaTeX{} options with keys `finalizeCache`
+% and `frozenCache`.
+%
+% To ensure compatibility with the `minted` package [@poore17, Section
+% 5.1], which supports the `finalizecache` and `frozencache` package options
+% with similar semantics, the Markdown package also recognizes these as aliases
+% and recognizes them as document class options. By passing `finalizecache` and
+% `frozencache` as document class options, you may conveniently control the
+% behavior of both packages at once:
+%
+% ``` tex
+% \documentclass[frozencache]{article}
+% \usepackage{markdown,minted}
+% \begin{document}
+% % ...
+% \end{document}
+% ```````
+%
+% We hope that other packages will support the `finalizecache` and
+% `frozencache` package options in the future, so that they can become a
+% standard interface for preparing \LaTeX{} document sources for distribution.
+%
+% \end{markdown}
+% \begin{macrocode}
+\define@key{markdownOptions}{finalizeCache}[true]{%
+ \def\markdownOptionFinalizeCache{#1}}%
+\DeclareOption{finalizecache}{\markdownSetup{finalizeCache}}
+\define@key{markdownOptions}{frozenCache}[true]{%
+ \def\markdownOptionFrozenCache{#1}}%
+\DeclareOption{frozencache}{\markdownSetup{frozenCache}}
+\define@key{markdownOptions}{frozenCacheFileName}{%
+ \def\markdownOptionFrozenCacheFileName{#1}}%
+% \end{macrocode}
+% \par
+% \begin{markdown}
+%
% The following example \LaTeX{} code showcases a possible configuration of
% plain \TeX{} interface options \m{markdownOptionHybrid},
% \m{markdownOptionSmartEllipses}, and \m{markdownOptionCacheDir}.
@@ -13379,7 +13904,7 @@ function M.writer.new(options)
% Define \luamdef{writer->string} as a function that will transform an input
% plain text span `s` to the output format and \luamdef{writer->uri} as a
% function that will transform an input \acro{uri} `u` to the output format.
-% If the \Opt{hybrid} option is `true`, use identity functions. Otherwise,
+% If the \Opt{hybrid} option is enabled, use identity functions. Otherwise,
% use the \luam{escape} and \luam{escape_minimal} functions.
%
% \end{markdown}
@@ -13828,7 +14353,7 @@ function M.writer.new(options)
%
% Define \luamdef{writer->citations} as a function that will transform an
% input array of citations `cites` to the output format. If `text_cites`
-% is `true`, the citations should be rendered in-text, when applicable.
+% is enabled, the citations should be rendered in-text, when applicable.
% The `cites` array contains tables with the following keys and values:
% \begin{itemize}
% \item`suppress_author` -- If the value of the key is true, then the
@@ -14687,7 +15212,7 @@ function M.reader.new(writer, options)
% \begin{markdown}
%
% Define \luamdef{expandtabs} either as an identity function, when the
-% \Opt{preserveTabs} Lua inrerface option is `true`, or to a function that
+% \Opt{preserveTabs} Lua inrerface option is enabled, or to a function that
% expands tabs into spaces otherwise.
%
% \end{markdown}
@@ -15578,14 +16103,35 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline
local salt = table.concat(opt_string, ",") .. "," .. metadata.version
% \end{macrocode}
% \begin{markdown}
-% Produce the cache file, transform its filename via the \luam{writer->pack}
-% method, and return the result.
+% Produce the cache file and transform its filename to plain \TeX{} output
+% via the \luam{writer->pack} method.
% \end{markdown}
% \begin{macrocode}
local name = util.cache(options.cacheDir, input, salt, function(input)
return util.rope_to_string(parse_blocks_toplevel(input)) .. writer.eof
end, ".md" .. writer.suffix)
- return writer.pack(name)
+ local output = writer.pack(name)
+% \end{macrocode}
+% \begin{markdown}
+% If the \Opt{frozenCache} option is enabled, populate the frozen cache in
+% the file \Opt{frozenCacheFileName} with an entry for markdown document
+% number \Opt{frozenCacheCounter}.
+% \end{markdown}
+% \begin{macrocode}
+ if options.finalizeCache then
+ local file, mode
+ if options.frozenCacheCounter > 0 then
+ mode = "a"
+ else
+ mode = "w"
+ end
+ file = assert(io.open(options.frozenCacheFileName, mode))
+ assert(file:write([[\expandafter\def\csname markdownFrozenCache]] ..
+ options.frozenCacheCounter .. [[\endcsname{]] .. output .. [[}]] ..
+ "\n"))
+ assert(file:close())
+ end
+ return output
end
return self
end
@@ -15626,9 +16172,9 @@ return M
local input
if input_filename then
- local input_file = io.open(input_filename, "r")
+ local input_file = assert(io.open(input_filename, "r"))
input = assert(input_file:read("*a"))
- input_file:close()
+ assert(input_file:close())
else
input = assert(io.read("*a"))
end
@@ -15668,7 +16214,7 @@ local convert = md.new(options)
local output = convert(input:gsub("\r\n?", "\n") .. "\n")
if output_filename then
- local output_file = io.open(output_filename, "w")
+ local output_file = assert(io.open(output_filename, "w"))
assert(output_file:write(output))
assert(output_file:close())
else
@@ -15706,6 +16252,23 @@ end
% \par
% \begin{markdown}
%
+%### Finalizing and Freezing the Cache
+%
+% When the \m{markdownOptionFinalizeCache} option is enabled, then the
+% \mdef{markdownFrozenCacheCounter} counter is used to enumerate the markdown
+% documents using the Lua interface \Opt{frozenCacheCounter} option.
+%
+% When the \m{markdownOptionFrozenCache} option is enabled, then the
+% \m{markdownFrozenCacheCounter} counter is used to render markdown documents
+% from the frozen cache without invoking Lua.
+%
+% \end{markdown}
+% \begin{macrocode}
+\newcount\markdownFrozenCacheCounter
+% \end{macrocode}
+% \par
+% \begin{markdown}
+%
%### Token Renderer Prototypes
% The following definitions should be considered placeholder.
%
@@ -15719,7 +16282,7 @@ end
\def\markdownRendererRightBracePrototype{\char`\}}%
\def\markdownRendererDollarSignPrototype{\char`$}%
\def\markdownRendererPercentSignPrototype{\char`\%}%
-\def\markdownRendererAmpersandPrototype{\char`&}%
+\def\markdownRendererAmpersandPrototype{\&}%
\def\markdownRendererUnderscorePrototype{\char`_}%
\def\markdownRendererHashPrototype{\char`\#}%
\def\markdownRendererCircumflexPrototype{\char`^}%
@@ -15818,6 +16381,11 @@ end
\ifx\markdownOptionDefinitionLists\undefined\else
definitionLists = \markdownOptionDefinitionLists,
\fi
+\ifx\markdownOptionFinalizeCache\undefined\else
+ finalizeCache = \markdownOptionFinalizeCache,
+\fi
+ frozenCacheFileName = "\markdownOptionFrozenCacheFileName",
+ frozenCacheCounter = \the\markdownFrozenCacheCounter,
\ifx\markdownOptionFootnotes\undefined\else
footnotes = \markdownOptionFootnotes,
\fi
@@ -15883,11 +16451,11 @@ end
% First, ensure that the \m{markdownOptionCacheDir} directory exists.
% \end{markdown}
% \begin{macrocode}
-local lfs = require("lfs")
-local cacheDir = "\markdownOptionCacheDir"
-if not lfs.isdir(cacheDir) then
- assert(lfs.mkdir(cacheDir))
-end
+ local lfs = require("lfs")
+ local cacheDir = "\markdownOptionCacheDir"
+ if not lfs.isdir(cacheDir) then
+ assert(lfs.mkdir(cacheDir))
+ end
% \end{macrocode}
% \begin{markdown}
% Next, load the `markdown` module and create a converter function using
@@ -15895,8 +16463,8 @@ end
% \m{markdownLuaOptions} macro.
% \end{markdown}
% \begin{macrocode}
-local md = require("markdown")
-local convert = md.new(\markdownLuaOptions)
+ local md = require("markdown")
+ local convert = md.new(\markdownLuaOptions)
}%
% \end{macrocode}
% \par
@@ -15904,6 +16472,24 @@ local convert = md.new(\markdownLuaOptions)
%
%### Buffering Markdown Input
% \label{sec:buffering}
+%
+% The
+% \mdef{markdownIfOption}`{`\meta{name}`}{`\meta{iftrue}`}{`\meta{iffalse}`}`
+% macro is provided for testing, whether the value of
+% `\markdownOption`\meta{name} is `true`. If the value is `true`, then
+% \meta{iftrue} is expanded, otherwise \meta{iffalse} is expanded.
+%
+% \end{markdown}
+% \begin{macrocode}
+\def\markdownIfOption#1#2#3{%
+ \begingroup
+ \def\next{true}%
+ \expandafter\ifx\csname markdownOption#1\endcsname\next
+ \endgroup#2\else\endgroup#3\fi}%
+% \end{macrocode}
+% \par
+% \begin{markdown}
+%
% The macros \mdef{markdownInputFileStream} and \mdef{markdownOutputFileStream}
% contain the number of the input and output file streams that will be used for
% the IO operations of the package.
@@ -15941,7 +16527,7 @@ local convert = md.new(\markdownLuaOptions)
% backslash as an ordinary character inside the macro definition. Likewise,
% swap the character codes of the percent sign (`%`) and the ampersand (`@`),
% so that we can remove percent signs from the beginning of lines when
-% \m{markdownOptionStripPercentSigns} is `true`.
+% \m{markdownOptionStripPercentSigns} is enabled.
% \end{markdown}
% \begin{macrocode}
\catcode`\^^M=13%
@@ -15954,14 +16540,17 @@ local convert = md.new(\markdownLuaOptions)
|begingroup@
% \end{macrocode}
% \begin{markdown}
-% Open the \m{markdownOptionInputTempFileName} file for writing.
+% If we are not reading markdown documents from the frozen cache,
+% open the \m{markdownOptionInputTempFileName} file for writing.
% \end{markdown}
% \begin{macrocode}
- |immediate|openout|markdownOutputFileStream@
- |markdownOptionInputTempFileName|relax@
- |markdownInfo{Buffering markdown input into the temporary @
- input file "|markdownOptionInputTempFileName" and scanning @
- for the closing token sequence "#1"}@
+ |markdownIfOption{FrozenCache}{}{@
+ |immediate|openout|markdownOutputFileStream@
+ |markdownOptionInputTempFileName|relax@
+ |markdownInfo{Buffering markdown input into the temporary @
+ input file "|markdownOptionInputTempFileName" and scanning @
+ for the closing token sequence "#1"}@
+ }@
% \end{macrocode}
% \begin{markdown}
% Locally change the category of the special plain \TeX{} characters to
@@ -15977,14 +16566,14 @@ local convert = md.new(\markdownLuaOptions)
% \begin{markdown}
% The \mdef{markdownReadAndConvertStripPercentSigns} macro will process the
% individual lines of output, stipping away leading percent signs (`%`) when
-% \m{markdownOptionStripPercentSigns} is `true`.
+% \m{markdownOptionStripPercentSigns} is enabled.
% Notice the use of the comments (`@`) to ensure that the entire macro is at
% a single line and therefore no (active) newline symbols
% (`^^M`) are produced.
% \end{markdown}
% \begin{macrocode}
|def|markdownReadAndConvertStripPercentSign##1{@
- |markdownIfOption{StripPercentSigns}@
+ |markdownIfOption{StripPercentSigns}{@
|if##1%@
|expandafter|expandafter|expandafter@
|markdownReadAndConvertProcessLine@
@@ -15993,11 +16582,12 @@ local convert = md.new(\markdownLuaOptions)
|markdownReadAndConvertProcessLine@
|expandafter|expandafter|expandafter##1@
|fi@
- |else@
+ }{@
|expandafter@
|markdownReadAndConvertProcessLine@
|expandafter##1@
- |fi}@
+ }@
+ }@
% \end{macrocode}
% \begin{markdown}
% The \mdef{markdownReadAndConvertProcessLine} macro will process the individual
@@ -16010,12 +16600,17 @@ local convert = md.new(\markdownLuaOptions)
|def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{@
% \end{macrocode}
% \begin{markdown}
-% When the ending token sequence does not appear in the line, store the line in
-% the \m{markdownOptionInputTempFileName} file.
+% If we are not reading markdown documents from the frozen cache and the ending
+% token sequence does not appear in the line, store the line in the
+% \m{markdownOptionInputTempFileName} file.
+% If we are reading markdown documents from the frozen cache and the
+% ending token sequence does not appear in the line, gobble the line.
% \end{markdown}
% \begin{macrocode}
|ifx|relax##3|relax@
- |immediate|write|markdownOutputFileStream{##1}@
+ |markdownIfOption{FrozenCache}{}{@
+ |immediate|write|markdownOutputFileStream{##1}@
+ }@
|else@
% \end{macrocode}
% \begin{markdown}
@@ -16029,7 +16624,9 @@ local convert = md.new(\markdownLuaOptions)
% \begin{macrocode}
|def^^M{@
|markdownInfo{The ending token sequence was found}@
- |immediate|closeout|markdownOutputFileStream@
+ |markdownIfOption{FrozenCache}{}{@
+ |immediate|closeout|markdownOutputFileStream@
+ }@
|endgroup@
|markdownInput{@
|markdownOptionOutputDir@
@@ -16274,6 +16871,7 @@ local convert = md.new(\markdownLuaOptions)
% \begin{markdown}
%
%### Typesetting Markdown
+%
% The \m{markdownInput} macro uses an implementation of the
% \m{markdownLuaExecute} macro to convert the contents of the file whose
% filename it has received as its single argument from markdown to plain
@@ -16291,7 +16889,25 @@ local convert = md.new(\markdownLuaOptions)
\catcode`|=0%
\catcode`\\=12%
|gdef|markdownInput#1{%
- |markdownInfo{Including markdown document "#1"}%
+% \end{macrocode}
+% \begin{markdown}
+% If we are reading from the frozen cache, input it, expand the corresponding
+% `\markdownFrozenCache`\meta{number} macro, and increment
+% \m{markdownFrozenCacheCounter}.
+% \end{markdown}
+% \begin{macrocode}
+ |markdownIfOption{FrozenCache}{%
+ |ifnum|markdownFrozenCacheCounter=0|relax
+ |markdownInfo{Reading frozen cache from
+ "|markdownOptionFrozenCacheFileName"}%
+ |input|markdownOptionFrozenCacheFileName|relax
+ |fi
+ |markdownInfo{Including markdown document number
+ "|the|markdownFrozenCacheCounter" from frozen cache}%
+ |csname markdownFrozenCache|the|markdownFrozenCacheCounter|endcsname
+ |advance|markdownFrozenCacheCounter by 1|relax
+ }{%
+ |markdownInfo{Including markdown document "#1"}%
% \end{macrocode}
% \begin{markdown}
% Attempt to open the markdown document to record it in the `.log` and
@@ -16299,11 +16915,13 @@ local convert = md.new(\markdownLuaOptions)
% changes to the markdown document.
% \end{markdown}
% \begin{macrocode}
- |openin|markdownInputFileStream#1
- |closein|markdownInputFileStream
- |markdownLuaExecute{%
- |markdownPrepare
- local input = assert(io.open("#1", "r"):read("*a"))
+ |openin|markdownInputFileStream#1
+ |closein|markdownInputFileStream
+ |markdownLuaExecute{%
+ |markdownPrepare
+ local file = assert(io.open("#1", "r"))
+ local input = assert(file:read("*a"))
+ assert(file:close())
% \end{macrocode}
% \begin{markdown}
% Since the Lua converter expects \acro{unix} line endings, normalize the
@@ -16311,7 +16929,18 @@ local convert = md.new(\markdownLuaOptions)
% has none.
% \end{markdown}
% \begin{macrocode}
- print(convert(input:gsub("\r\n?", "\n") .. "\n"))}}%
+ print(convert(input:gsub("\r\n?", "\n") .. "\n"))}%
+% \end{macrocode}
+% \begin{markdown}
+% If we are finalizing the frozen cache, increment
+% \m{markdownFrozenCacheCounter}.
+% \end{markdown}
+% \begin{macrocode}
+ |markdownIfOption{FinalizeCache}{%
+ |advance|markdownFrozenCacheCounter by 1|relax
+ }%
+ }%
+ }%
|endgroup
% \end{macrocode}
% \iffalse
@@ -16377,10 +17006,12 @@ local convert = md.new(\markdownLuaOptions)
% \end{markdown}
% \begin{macrocode}
\renewenvironment{markdown}{%
- \markdownReadAndConvert@markdown{}}\relax
+ \markdownReadAndConvert@markdown{}}{%
+ \markdownEnd}%
\renewenvironment{markdown*}[1]{%
\markdownSetup{#1}%
- \markdownReadAndConvert@markdown*}\relax
+ \markdownReadAndConvert@markdown*}{%
+ \markdownEnd}%
\begingroup
% \end{macrocode}
% \begin{markdown}
@@ -16493,7 +17124,6 @@ local convert = md.new(\markdownLuaOptions)
\ifx\empty#4\empty\else
\caption{#4}%
\fi
- \label{tab:#1}%
\end{table}}{%
\markdownInput{#3}}},
image = {%
@@ -17040,6 +17670,7 @@ local convert = md.new(\markdownLuaOptions)
|gdef|startmarkdown{%
|markdownReadAndConvert{\stopmarkdown}%
{|stopmarkdown}}%
+ |gdef|stopmarkdown{|markdownEnd}%
|endgroup
% \end{macrocode}
% \par