summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/markdown/markdown.tex
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/tex/generic/markdown/markdown.tex
parentc8d2ea73c06009f96ad1c3a66b69d20d57209dc7 (diff)
markdown (14sep20)
git-svn-id: svn://tug.org/texlive/trunk@56342 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/markdown/markdown.tex')
-rw-r--r--Master/texmf-dist/tex/generic/markdown/markdown.tex103
1 files changed, 65 insertions, 38 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex
index 9e2083313cf..61327f92397 100644
--- a/Master/texmf-dist/tex/generic/markdown/markdown.tex
+++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex
@@ -45,17 +45,19 @@
%%
%% The names of the source files used are shown above.
%%
-\def\markdownLastModified{2020/03/20}%
-\def\markdownVersion{2.8.2}%
+\def\markdownLastModified{2020/09/14}%
+\def\markdownVersion{2.9.0}%
\let\markdownBegin\relax
\let\markdownEnd\relax
\let\markdownInput\relax
+\let\markdownOptionFinalizeCache\undefined
\def\markdownOptionHelperScriptFileName{\jobname.markdown.lua}%
\def\markdownOptionInputTempFileName{\jobname.markdown.in}%
\def\markdownOptionOutputTempFileName{\jobname.markdown.out}%
\def\markdownOptionErrorTempFileName{\jobname.markdown.err}%
\def\markdownOptionOutputDir{.}%
\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}%
+\def\markdownOptionFrozenCacheFileName{\markdownOptionCacheDir/frozenCache.tex}
\let\markdownOptionBlankBeforeBlockquote\undefined
\let\markdownOptionBlankBeforeCodeFence\undefined
\let\markdownOptionBlankBeforeHeading\undefined
@@ -81,17 +83,6 @@
\let\markdownOptionTableCaptions\undefined
\let\markdownOptionTightLists\undefined
\def\markdownOptionStripPercentSigns{false}%
-\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}
\def\markdownRendererInterblockSeparator{%
\markdownRendererInterblockSeparatorPrototype}%
\def\markdownRendererLineBreak{%
@@ -296,6 +287,7 @@
\def\markdownError#1#2{%
\errhelp{#2.}%
\errmessage{(l.\the\inputlineno) markdown.tex error: #1}}%
+\newcount\markdownFrozenCacheCounter
\def\markdownRendererInterblockSeparatorPrototype{\par}%
\def\markdownRendererLineBreakPrototype{\hfil\break}%
\let\markdownRendererEllipsisPrototype\dots
@@ -304,7 +296,7 @@
\def\markdownRendererRightBracePrototype{\char`\}}%
\def\markdownRendererDollarSignPrototype{\char`$}%
\def\markdownRendererPercentSignPrototype{\char`\%}%
-\def\markdownRendererAmpersandPrototype{\char`&}%
+\def\markdownRendererAmpersandPrototype{\&}%
\def\markdownRendererUnderscorePrototype{\char`_}%
\def\markdownRendererHashPrototype{\char`\#}%
\def\markdownRendererCircumflexPrototype{\char`^}%
@@ -392,6 +384,11 @@
\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
@@ -442,14 +439,19 @@
\fi}
}%
\def\markdownPrepare{%
-local lfs = require("lfs")
-local cacheDir = "\markdownOptionCacheDir"
-if not lfs.isdir(cacheDir) then
- assert(lfs.mkdir(cacheDir))
-end
-local md = require("markdown")
-local convert = md.new(\markdownLuaOptions)
+ local lfs = require("lfs")
+ local cacheDir = "\markdownOptionCacheDir"
+ if not lfs.isdir(cacheDir) then
+ assert(lfs.mkdir(cacheDir))
+ end
+ local md = require("markdown")
+ local convert = md.new(\markdownLuaOptions)
}%
+\def\markdownIfOption#1#2#3{%
+ \begingroup
+ \def\next{true}%
+ \expandafter\ifx\csname markdownOption#1\endcsname\next
+ \endgroup#2\else\endgroup#3\fi}%
\csname newread\endcsname\markdownInputFileStream
\csname newwrite\endcsname\markdownOutputFileStream
\begingroup
@@ -465,16 +467,18 @@ local convert = md.new(\markdownLuaOptions)
|catcode`|%=12@
|gdef|markdownReadAndConvert#1#2{@
|begingroup@
- |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"}@
+ }@
|def|do##1{|catcode`##1=12}|dospecials@
|catcode`| =12@
|markdownMakeOther@
|def|markdownReadAndConvertStripPercentSign##1{@
- |markdownIfOption{StripPercentSigns}@
+ |markdownIfOption{StripPercentSigns}{@
|if##1%@
|expandafter|expandafter|expandafter@
|markdownReadAndConvertProcessLine@
@@ -483,18 +487,23 @@ local convert = md.new(\markdownLuaOptions)
|markdownReadAndConvertProcessLine@
|expandafter|expandafter|expandafter##1@
|fi@
- |else@
+ }{@
|expandafter@
|markdownReadAndConvertProcessLine@
|expandafter##1@
- |fi}@
+ }@
+ }@
|def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{@
|ifx|relax##3|relax@
- |immediate|write|markdownOutputFileStream{##1}@
+ |markdownIfOption{FrozenCache}{}{@
+ |immediate|write|markdownOutputFileStream{##1}@
+ }@
|else@
|def^^M{@
|markdownInfo{The ending token sequence was found}@
- |immediate|closeout|markdownOutputFileStream@
+ |markdownIfOption{FrozenCache}{}{@
+ |immediate|closeout|markdownOutputFileStream@
+ }@
|endgroup@
|markdownInput{@
|markdownOptionOutputDir@
@@ -591,13 +600,31 @@ local convert = md.new(\markdownLuaOptions)
\catcode`|=0%
\catcode`\\=12%
|gdef|markdownInput#1{%
- |markdownInfo{Including markdown document "#1"}%
- |openin|markdownInputFileStream#1
- |closein|markdownInputFileStream
- |markdownLuaExecute{%
- |markdownPrepare
- local input = assert(io.open("#1", "r"):read("*a"))
- print(convert(input:gsub("\r\n?", "\n") .. "\n"))}}%
+ |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"}%
+ |openin|markdownInputFileStream#1
+ |closein|markdownInputFileStream
+ |markdownLuaExecute{%
+ |markdownPrepare
+ local file = assert(io.open("#1", "r"))
+ local input = assert(file:read("*a"))
+ assert(file:close())
+ print(convert(input:gsub("\r\n?", "\n") .. "\n"))}%
+ |markdownIfOption{FinalizeCache}{%
+ |advance|markdownFrozenCacheCounter by 1|relax
+ }%
+ }%
+ }%
|endgroup
\endinput
%%