diff options
Diffstat (limited to 'Master/texmf-dist/tex')
4 files changed, 97 insertions, 43 deletions
diff --git a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex index c7a27aedf3c..92027c9eb0a 100644 --- a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex +++ b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex @@ -67,6 +67,7 @@ |gdef|startmarkdown{% |markdownReadAndConvert{\stopmarkdown}% {|stopmarkdown}}% + |gdef|stopmarkdown{|markdownEnd}% |endgroup \def\markdownRendererLineBreakPrototype{\blank}% \def\markdownRendererLeftBracePrototype{\textbraceleft}% 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 %% diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index 2a1e14dbe7f..816c56a2a0d 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -123,6 +123,14 @@ \def\markdownOptionUnderscores{#1}}% \define@key{markdownOptions}{stripPercentSigns}[true]{% \def\markdownOptionStripPercentSigns{#1}}% +\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}}% \define@key{markdownRenderers}{interblockSeparator}{% \renewcommand\markdownRendererInterblockSeparator{#1}}% \define@key{markdownRenderers}{lineBreak}{% @@ -373,10 +381,12 @@ \markdownInputPlainTeX{#2}% \endgroup}% \renewenvironment{markdown}{% - \markdownReadAndConvert@markdown{}}\relax + \markdownReadAndConvert@markdown{}}{% + \markdownEnd}% \renewenvironment{markdown*}[1]{% \markdownSetup{#1}% - \markdownReadAndConvert@markdown*}\relax + \markdownReadAndConvert@markdown*}{% + \markdownEnd}% \begingroup \catcode`\|=0\catcode`\<=1\catcode`\>=2% \catcode`\\=12|catcode`|{=12|catcode`|}=12% @@ -436,7 +446,6 @@ \ifx\empty#4\empty\else \caption{#4}% \fi - \label{tab:#1}% \end{table}}{% \markdownInput{#3}}}, image = {% diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index 36d2b611a78..e6127c8bf6d 100644 --- a/Master/texmf-dist/tex/luatex/markdown/markdown.lua +++ b/Master/texmf-dist/tex/luatex/markdown/markdown.lua @@ -58,7 +58,7 @@ -- those in the standard .ins files. -- 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", @@ -74,6 +74,7 @@ local md5 = require("md5") local M = {metadata = metadata} local defaultOptions = {} defaultOptions.cacheDir = "." +defaultOptions.frozenCacheFileName = "frozenCache.tex" defaultOptions.blankBeforeBlockquote = false defaultOptions.blankBeforeCodeFence = false defaultOptions.blankBeforeHeading = false @@ -85,7 +86,9 @@ defaultOptions.contentBlocks = false defaultOptions.contentBlocksLanguageMap = "markdown-languages.json" defaultOptions.definitionLists = false defaultOptions.fencedCode = false +defaultOptions.finalizeCache = false defaultOptions.footnotes = false +defaultOptions.frozenCacheCounter = 0 defaultOptions.hashEnumerators = false defaultOptions.headerAttributes = false defaultOptions.html = false @@ -4033,7 +4036,21 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline 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) + 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 |