From d0d20a6ba7cff5159a2f78b414326262f45b0542 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 7 Aug 2021 20:19:27 +0000 Subject: markdown (7aug21) git-svn-id: svn://tug.org/texlive/trunk@60182 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/context/third/markdown/t-markdown.tex | 17 +- .../texmf-dist/tex/generic/markdown/markdown.tex | 54 +++-- Master/texmf-dist/tex/latex/markdown/markdown.sty | 164 +++++++++------ .../tex/latex/markdown/markdownthemewitiko_dot.sty | 71 +++++++ .../markdown/markdownthemewitiko_graphicx_http.sty | 89 ++++++++ .../latex/markdown/markdownthemewitiko_tilde.sty | 52 +++++ Master/texmf-dist/tex/luatex/markdown/markdown.lua | 223 +++++++++++++++------ 7 files changed, 531 insertions(+), 139 deletions(-) create mode 100644 Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_dot.sty create mode 100644 Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty create mode 100644 Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_tilde.sty (limited to 'Master/texmf-dist/tex') 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 92027c9eb0a..98830398c82 100644 --- a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex +++ b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `context') %% -%% Copyright (C) 2016-2020 Vít Novotný +%% Copyright (C) 2016-2021 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -46,12 +46,15 @@ %% The names of the source files used are shown above. %% \writestatus{loading}{ConTeXt User Module / markdown}% +\startmodule[markdown] \unprotect \let\startmarkdown\relax \let\stopmarkdown\relax +\def\markdownInfo#1{\writestatus{markdown}{#1.}}% +\def\markdownWarning#1{\writestatus{markdown\space warn}{#1.}}% \def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\_\do\%\do\~}% -\input markdown +\input markdown/markdown \def\markdownMakeOther{% \count0=128\relax \loop @@ -59,8 +62,6 @@ \advance\count0 by 1\relax \ifnum\count0<256\repeat \catcode`|=12}% -\def\markdownInfo#1{\writestatus{markdown}{#1.}}% -\def\markdownWarning#1{\writestatus{markdown\space warn}{#1.}}% \begingroup \catcode`\|=0% \catcode`\\=12% @@ -92,12 +93,12 @@ \def\markdownConTeXtCSV{csv} \def\markdownRendererContentBlockPrototype#1#2#3#4{% \def\markdownConTeXtCSV@arg{#1}% -\ifx\markdownConTeXtCSV@arg\markdownConTeXtCSV + \ifx\markdownConTeXtCSV@arg\markdownConTeXtCSV \placetable[][tab:#1]{#4}{% \processseparatedfile[MarkdownConTeXtCSV][#3]}% -\else -\markdownInput{#3}% -\fi}% + \else + \markdownInput{#3}% + \fi}% \def\markdownRendererImagePrototype#1#2#3#4{% \placefigure[][fig:#1]{#4}{\externalfigure[#3]}}% \def\markdownRendererUlBeginPrototype{\startitemize}% diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex index 61327f92397..f3c4d4e8b43 100644 --- a/Master/texmf-dist/tex/generic/markdown/markdown.tex +++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `tex') %% -%% Copyright (C) 2016-2020 Vít Novotný +%% Copyright (C) 2016-2021 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -45,8 +45,8 @@ %% %% The names of the source files used are shown above. %% -\def\markdownLastModified{2020/09/14}% -\def\markdownVersion{2.9.0}% +\def\markdownLastModified{2021/08/06}% +\def\markdownVersion{2.10.0}% \let\markdownBegin\relax \let\markdownEnd\relax \let\markdownInput\relax @@ -80,7 +80,9 @@ \let\markdownOptionSlice\undefined \let\markdownOptionSmartEllipses\undefined \let\markdownOptionStartNumber\undefined +\let\markdownOptionStripIndent\undefined \let\markdownOptionTableCaptions\undefined +\let\markdownOptionTeXComments\undefined \let\markdownOptionTightLists\undefined \def\markdownOptionStripPercentSigns{false}% \def\markdownRendererInterblockSeparator{% @@ -201,6 +203,8 @@ \markdownRendererTextCitePrototype}% \def\markdownRendererTable{% \markdownRendererTablePrototype}% +\def\markdownRendererInlineHtmlComment{% + \markdownRendererInlineHtmlCommentPrototype}% \def\markdownRendererInterblockSeparatorPrototype{}% \def\markdownRendererLineBreakPrototype{}% \def\markdownRendererEllipsisPrototype{}% @@ -260,9 +264,7 @@ \def\markdownRendererCitePrototype#1{}% \def\markdownRendererTextCitePrototype#1{}% \def\markdownRendererTablePrototype#1#2#3{}% -\def\markdownInfo#1{}% -\def\markdownWarning#1{}% -\def\markdownError#1#2{}% +\def\markdownRendererInlineHtmlCommentPrototype#1{}% \let\markdownMakeOther\relax \let\markdownReadAndConvert\relax \begingroup @@ -280,13 +282,19 @@ \fi \def\markdownLuaRegisterIBCallback#1{\relax}% \def\markdownLuaUnregisterIBCallback#1{\relax}% -\def\markdownInfo#1{% - \immediate\write-1{(l.\the\inputlineno) markdown.tex info: #1.}}% -\def\markdownWarning#1{% - \immediate\write16{(l.\the\inputlineno) markdown.tex warning: #1}}% -\def\markdownError#1#2{% - \errhelp{#2.}% - \errmessage{(l.\the\inputlineno) markdown.tex error: #1}}% +\ifx\markdownInfo\undefined + \def\markdownInfo#1{% + \immediate\write-1{(l.\the\inputlineno) markdown.tex info: #1.}}% +\fi +\ifx\markdownWarning\undefined + \def\markdownWarning#1{% + \immediate\write16{(l.\the\inputlineno) markdown.tex warning: #1}}% +\fi +\ifx\markdownError\undefined + \def\markdownError#1#2{% + \errhelp{#2.}% + \errmessage{(l.\the\inputlineno) markdown.tex error: #1}}% +\fi \newcount\markdownFrozenCacheCounter \def\markdownRendererInterblockSeparatorPrototype{\par}% \def\markdownRendererLineBreakPrototype{\hfil\break}% @@ -428,9 +436,15 @@ \ifx\markdownOptionStartNumber\undefined\else startNumber = \markdownOptionStartNumber, \fi +\ifx\markdownOptionStripIndent\undefined\else + stripIndent = \markdownOptionStripIndent, +\fi \ifx\markdownOptionTableCaptions\undefined\else tableCaptions = \markdownOptionTableCaptions, \fi +\ifx\markdownOptionTeXComments\undefined\else + texComments = \markdownOptionTeXComments, +\fi \ifx\markdownOptionTightLists\undefined\else tightLists = \markdownOptionTightLists, \fi @@ -565,8 +579,8 @@ "|markdownOptionHelperScriptFileName"}% |immediate|write|markdownOutputFileStream{% local ran_ok, error = pcall(function() - local kpse = require("kpse") - kpse.set_program_name("luatex") + local ran_ok, kpse = pcall(require, "kpse") + if ran_ok then kpse.set_program_name("luatex") end #1 end) if not ran_ok then @@ -600,6 +614,8 @@ \catcode`|=0% \catcode`\\=12% |gdef|markdownInput#1{% + |begingroup + |catcode`|%=12 |markdownIfOption{FrozenCache}{% |ifnum|markdownFrozenCacheCounter=0|relax |markdownInfo{Reading frozen cache from @@ -609,21 +625,23 @@ |markdownInfo{Including markdown document number "|the|markdownFrozenCacheCounter" from frozen cache}% |csname markdownFrozenCache|the|markdownFrozenCacheCounter|endcsname - |advance|markdownFrozenCacheCounter by 1|relax + |global|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 file = assert(io.open("#1", "r"), + [[could not open file "#1" for reading]]) local input = assert(file:read("*a")) assert(file:close()) print(convert(input:gsub("\r\n?", "\n") .. "\n"))}% |markdownIfOption{FinalizeCache}{% - |advance|markdownFrozenCacheCounter by 1|relax + |global|advance|markdownFrozenCacheCounter by 1|relax }% }% + |endgroup }% |endgroup \endinput diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index 816c56a2a0d..fa84c468857 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `latex') %% -%% Copyright (C) 2016-2020 Vít Novotný +%% Copyright (C) 2016-2021 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -45,18 +45,63 @@ %% %% The names of the source files used are shown above. %% -\NeedsTeXFormat{LaTeX2e}% \RequirePackage{keyval} -\RequirePackage{url} -\RequirePackage{graphicx} -\RequirePackage{ifthen} -\RequirePackage{fancyvrb} -\RequirePackage{csvsimple} -\RequirePackage{gobble} +\RequirePackage{xstring} \newenvironment{markdown}\relax\relax \newenvironment{markdown*}[1]\relax\relax \newcommand\markdownSetup[1]{% \setkeys{markdownOptions}{#1}}% +\newcommand\markdownSetupSnippet[2]{% + \@ifundefined + {markdownLaTeXSetupSnippet\markdownLaTeXThemeName#1}{% + \newtoks\next + \next={#2}% + \expandafter\let\csname markdownLaTeXSetupSnippet% + \markdownLaTeXThemeName#1\endcsname=\next + }{% + \markdownWarning + {Redefined setup snippet \markdownLaTeXThemeName#1}% + \csname markdownLaTeXSetupSnippet% + \markdownLaTeXThemeName#1\endcsname={#2}% + }}% +\newif\ifmarkdownLaTeXPlain + \markdownLaTeXPlainfalse +\define@key{markdownOptions}{plain}[true]{% + \ifmarkdownLaTeXLoaded + \markdownWarning + {The plain option must be specified when loading the package}% + \else + \markdownLaTeXPlaintrue + \fi} +\newif\ifmarkdownLaTeXLoaded + \markdownLaTeXLoadedfalse +\AtEndOfPackage{\markdownLaTeXLoadedtrue}% +\define@key{markdownOptions}{theme}{% + \IfSubStr{#1}{/}{}{% + \markdownError + {Won't load theme with unqualified name #1}% + {Theme names must contain at least one forward slash}}% + \StrSubstitute{#1}{/}{_}[\markdownLaTeXThemePackageName]% + \edef\markdownLaTeXThemePackageName{% + markdowntheme\markdownLaTeXThemePackageName}% + \expandafter\markdownLaTeXThemeLoad\expandafter{% + \markdownLaTeXThemePackageName}{#1/}}% +\newcommand\markdownLaTeXThemeName{}% +\newcommand\markdownLaTeXThemeLoad[2]{% + \ifmarkdownLaTeXLoaded + \def\markdownLaTeXThemeName{#2}% + \RequirePackage{#1}% + \def\markdownLaTeXThemeName{}% + \else + \AtEndOfPackage{% + \def\markdownLaTeXThemeName{#2}% + \RequirePackage{#1}% + \def\markdownLaTeXThemeName{}}% + \fi}% +\@onlypreamble\KV@markdownOptions@theme +\define@key{markdownOptions}{snippet}{% + \expandafter\markdownSetup\expandafter{% + \the\csname markdownLaTeXSetupSnippet#1\endcsname}}% \define@key{markdownOptions}{helperScriptFileName}{% \def\markdownOptionHelperScriptFileName{#1}}% \define@key{markdownOptions}{inputTempFileName}{% @@ -115,8 +160,12 @@ \def\markdownOptionSlice{#1}}% \define@key{markdownOptions}{startNumber}[true]{% \def\markdownOptionStartNumber{#1}}% +\define@key{markdownOptions}{stripIndent}[true]{% + \def\markdownOptionStripIndent{#1}}% \define@key{markdownOptions}{tableCaptions}[true]{% \def\markdownOptionTableCaptions{#1}}% +\define@key{markdownOptions}{texComments}[true]{% + \def\markdownOptionTeXComments{#1}}% \define@key{markdownOptions}{tightLists}[true]{% \def\markdownOptionTightLists{#1}}% \define@key{markdownOptions}{underscores}[true]{% @@ -249,6 +298,8 @@ \renewcommand\markdownRendererTextCite[1]{#1}}% \define@key{markdownRenderers}{table}{% \renewcommand\markdownRendererTable[3]{#1}}% +\define@key{markdownRenderers}{inlineHtmlComment}{% + \renewcommand\markdownRendererInlineHtmlComment[1]{#1}}% \define@key{markdownRendererPrototypes}{interblockSeparator}{% \renewcommand\markdownRendererInterblockSeparatorPrototype{#1}}% \define@key{markdownRendererPrototypes}{lineBreak}{% @@ -367,13 +418,15 @@ \renewcommand\markdownRendererTextCitePrototype[1]{#1}}% \define@key{markdownRendererPrototypes}{table}{% \renewcommand\markdownRendererTablePrototype[3]{#1}}% -\input markdown +\define@key{markdownRendererPrototypes}{inlineHtmlComment}{% + \renewcommand\markdownRendererInlineHtmlCommentPrototype[1]{#1}}% +\newcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}% +\newcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}% +\newcommand\markdownError[2]{\PackageError{markdown}{#1}{#2.}}% +\input markdown/markdown \def\markdownVersionSpace{ }% \ProvidesPackage{markdown}[\markdownLastModified\markdownVersionSpace v% \markdownVersion\markdownVersionSpace markdown renderer]% -\renewcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}% -\renewcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}% -\renewcommand\markdownError[2]{\PackageError{markdown}{#1}{#2.}}% \let\markdownInputPlainTeX\markdownInput \renewcommand\markdownInput[2][]{% \begingroup @@ -403,13 +456,15 @@ \define@key{markdownOptions}{rendererPrototypes}{% \setkeys{markdownRendererPrototypes}{#1}% \def\KV@prefix{KV@markdownOptions@}}% -\ifx\markdownOptionTightLists\undefined - \@ifclassloaded{beamer}{}{ - \RequirePackage{paralist}} -\else - \ifthenelse{\equal{\markdownOptionTightLists}{false}}{}{ - \RequirePackage{paralist}} -\fi +\ifmarkdownLaTeXPlain\else +\RequirePackage{ifthen} +\@ifundefined{markdownOptionTightLists}{% + \@ifclassloaded{beamer}{}{% + \RequirePackage{paralist}}% +}{% + \ifthenelse{\equal{\markdownOptionTightLists}{false}}{}{% + \RequirePackage{paralist}}% +}% \@ifpackageloaded{paralist}{ \markdownSetup{rendererPrototypes={ ulBeginTight = {\begin{compactitem}}, @@ -426,6 +481,9 @@ olEndTight = {\markdownRendererOlEnd}, dlBeginTight = {\markdownRendererDlBegin}, dlEndTight = {\markdownRendererDlEnd}}}} +\RequirePackage{csvsimple} +\RequirePackage{fancyvrb} +\RequirePackage{graphicx} \markdownSetup{rendererPrototypes={ lineBreak = {\\}, leftBrace = {\textbraceleft}, @@ -459,10 +517,10 @@ \label{fig:#1}% \end{figure}}, ulBegin = {\begin{itemize}}, - ulItem = {\item}, + ulItem = {\item{}}, ulEnd = {\end{itemize}}, olBegin = {\begin{enumerate}}, - olItem = {\item}, + olItem = {\item{}}, olItemWithNumber = {\item[#1.]}, olEnd = {\end{enumerate}}, dlBegin = {\begin{description}}, @@ -476,39 +534,30 @@ \ifx\relax#2\relax \VerbatimInput{#1}% \else - \ifx\minted@code\undefined - \ifx\lst@version\undefined + \@ifundefined{minted@code}{% + \@ifundefined{lst@version}{% \markdownRendererInputFencedCode{#1}{}% - \else + }{% \lstinputlisting[language=#2]{#1}% - \fi - \else + }% + }{% \inputminted{#2}{#1}% - \fi + }% \fi}, horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}}, footnote = {\footnote{#1}}}} -\newif\ifmarkdownLATEXStrongEmphasisNested -\markdownLATEXStrongEmphasisNestedfalse -\markdownSetup{rendererPrototypes={ - strongEmphasis = {% - \ifmarkdownLATEXStrongEmphasisNested - \markdownLATEXStrongEmphasisNestedfalse - \textmd{#1}% - \markdownLATEXStrongEmphasisNestedtrue - \else - \markdownLATEXStrongEmphasisNestedtrue - \textbf{#1}% - \markdownLATEXStrongEmphasisNestedfalse - \fi}}} -\ifx\chapter\undefined +\def\markdownLATEXStrongEmphasis#1{% + \IfSubStr\f@series{b}{\textnormal{#1}}{\textbf{#1}}} +\markdownSetup{rendererPrototypes={strongEmphasis={% + \protect\markdownLATEXStrongEmphasis{#1}}}} +\@ifundefined{chapter}{% \markdownSetup{rendererPrototypes = { headingOne = {\section{#1}}, headingTwo = {\subsection{#1}}, headingThree = {\subsubsection{#1}}, headingFour = {\paragraph{#1}\leavevmode}, headingFive = {\subparagraph{#1}\leavevmode}}} -\else +}{% \markdownSetup{rendererPrototypes = { headingOne = {\chapter{#1}}, headingTwo = {\section{#1}}, @@ -516,9 +565,10 @@ headingFour = {\subsubsection{#1}}, headingFive = {\paragraph{#1}\leavevmode}, headingSix = {\subparagraph{#1}\leavevmode}}} -\fi +}% \newcount\markdownLaTeXCitationsCounter +\RequirePackage{gobble} \def\markdownLaTeXBasicCitations#1#2#3#4#5#6{% \advance\markdownLaTeXCitationsCounter by 1\relax \ifx\relax#4\relax @@ -691,47 +741,48 @@ cite = {% \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% - \ifx\autocites\undefined - \ifx\citep\undefined + \@ifundefined{autocites}{% + \@ifundefined{citep}{% \expandafter\expandafter\expandafter \markdownLaTeXBasicCitations \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% - \else + }{% \expandafter\expandafter\expandafter \markdownLaTeXNatbibCitations \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% - \fi - \else + }% + }{% \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXCitations \expandafter{\expandafter}% - \fi}, + }}, textCite = {% \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% - \ifx\autocites\undefined - \ifx\citep\undefined + \@ifundefined{autocites}{% + \@ifundefined{citep}{% \expandafter\expandafter\expandafter \markdownLaTeXBasicTextCitations \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% - \else + }{% \expandafter\expandafter\expandafter \markdownLaTeXNatbibTextCitations \expandafter\expandafter\expandafter{% \expandafter\expandafter\expandafter}% - \fi - \else + }% + }{% \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXTextCitations \expandafter{\expandafter}% - \fi}}} + }}}} +\RequirePackage{url} \def\markdownRendererLinkPrototype{% \begingroup \catcode`\#=12 @@ -794,8 +845,6 @@ \fi \advance\markdownLaTeXRowCounter by 1\relax \ifnum\markdownLaTeXRowCounter>\markdownLaTeXRowTotal\relax - \markdownInfo{\the\markdownLaTeXTable} - \markdownInfo{\the\markdownLaTeXTableEnd} \the\markdownLaTeXTable \the\markdownLaTeXTableEnd \expandafter\@gobble @@ -818,6 +867,7 @@ \addto@hook\markdownLaTeXTable{#1\\}% \expandafter\@gobble \fi\markdownLaTeXRenderTableCell} +\fi \newcommand\markdownMakeOther{% \count0=128\relax \loop diff --git a/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_dot.sty b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_dot.sty new file mode 100644 index 00000000000..3a569f72775 --- /dev/null +++ b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_dot.sty @@ -0,0 +1,71 @@ +%% +%% This is file `markdownthemewitiko_dot.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% markdown.dtx (with options: `latex-themes-witiko-dot') +%% +%% Copyright (C) 2016-2021 Vít Novotný +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Vít Novotný. +%% +%% Send bug reports, requests for additions and questions +%% either to the GitHub issue tracker at +%% +%% https://github.com/Witiko/markdown/issues +%% +%% or to the e-mail address . +%% +%% MODIFICATION ADVICE: +%% +%% If you want to customize this file, it is best to make a copy of +%% the source file(s) from which it was produced. Use a different +%% name for your copy(ies) and modify the copy(ies); this will ensure +%% that your modifications do not get overwritten when you install a +%% new release of the standard system. You should also ensure that +%% your modified source file does not generate any modified file with +%% the same name as a standard file. +%% +%% You will also need to produce your own, suitably named, .ins file to +%% control the generation of files from your source file; this file +%% should contain your own preambles for the files it generates, not +%% those in the standard .ins files. +%% +%% The names of the source files used are shown above. +%% +\ProvidesPackage{markdownthemewitiko_dot}[2021/03/09]% +\markdownSetup{fencedCode}% +\let\markdown@witiko@dot@oldRendererInputFencedCodePrototype + \markdownRendererInputFencedCodePrototype +\RequirePackage{ifthen} +\renewcommand\markdownRendererInputFencedCode[2]{% + \def\next##1 ##2\relax{% + \ifthenelse{\equal{##1}{dot}}{% + \markdownIfOption{FrozenCache}{}{% + \immediate\write18{% + if ! test -e #1.pdf.source || ! diff #1 #1.pdf.source; + then + dot -Tpdf -o #1.pdf #1; + cp #1 #1.pdf.source; + fi}}% + \markdownRendererImage{Graphviz image}{#1.pdf}{#1.pdf}{##2}% + }{% + \markdown@witiko@dot@oldRendererInputFencedCodePrototype{#1}{#2}% + }% + }% + \next#2 \relax}% +\endinput +%% +%% End of file `markdownthemewitiko_dot.sty'. diff --git a/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty new file mode 100644 index 00000000000..56a0bcb960e --- /dev/null +++ b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty @@ -0,0 +1,89 @@ +%% +%% This is file `markdownthemewitiko_graphicx_http.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% markdown.dtx (with options: `latex-themes-witiko-graphicx-http') +%% +%% Copyright (C) 2016-2021 Vít Novotný +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Vít Novotný. +%% +%% Send bug reports, requests for additions and questions +%% either to the GitHub issue tracker at +%% +%% https://github.com/Witiko/markdown/issues +%% +%% or to the e-mail address . +%% +%% MODIFICATION ADVICE: +%% +%% If you want to customize this file, it is best to make a copy of +%% the source file(s) from which it was produced. Use a different +%% name for your copy(ies) and modify the copy(ies); this will ensure +%% that your modifications do not get overwritten when you install a +%% new release of the standard system. You should also ensure that +%% your modified source file does not generate any modified file with +%% the same name as a standard file. +%% +%% You will also need to produce your own, suitably named, .ins file to +%% control the generation of files from your source file; this file +%% should contain your own preambles for the files it generates, not +%% those in the standard .ins files. +%% +%% The names of the source files used are shown above. +%% +\ProvidesPackage{markdownthemewitiko_graphicx_http}[2021/03/22]% +\RequirePackage{catchfile} +\let\markdown@witiko@graphicx@http@oldRendererImagePrototype + \markdownRendererImagePrototype +\newcount\markdown@witiko@graphicx@http@counter +\markdown@witiko@graphicx@http@counter=0 +\newcommand\markdown@witiko@graphicx@http@filename{% + \markdownOptionCacheDir/witiko_graphicx_http% + .\the\markdown@witiko@graphicx@http@counter}% +\newcommand\markdown@witiko@graphicx@http@download[2]{% + wget -O #2 #1 || curl --location -o #2 #1 || rm -f #2} +\begingroup +\catcode`\%=12 +\catcode`\^^A=14 +\global\def\markdownRendererImagePrototype#1#2#3#4{^^A + \begingroup + \edef\filename{\markdown@witiko@graphicx@http@filename}^^A + \markdownIfOption{FrozenCache}{}{^^A + \immediate\write18{^^A + if printf '%s' "#3" | grep -q -E '^https?:'; + then + OUTPUT_PREFIX="\markdownOptionCacheDir"; + OUTPUT_BODY="$(printf '%s' '#3' | md5sum | cut -d' ' -f1)"; + OUTPUT_SUFFIX="$(printf '%s' '#3' | sed 's/.*[.]//')"; + OUTPUT="$OUTPUT_PREFIX/$OUTPUT_BODY.$OUTPUT_SUFFIX"; + if ! [ -e "$OUTPUT" ]; + then + \markdown@witiko@graphicx@http@download{'#3'}{"$OUTPUT"}; + printf '%s' "$OUTPUT" > "\filename"; + fi; + else + printf '%s' '#3' > "\filename"; + fi}}^^A + \CatchFileDef{\filename}{\filename}{}^^A + \markdown@witiko@graphicx@http@oldRendererImagePrototype^^A + {#1}{#2}{\filename}{#4}^^A + \endgroup + \global\advance\markdown@witiko@graphicx@http@counter by 1\relax}^^A +\endgroup +\endinput +%% +%% End of file `markdownthemewitiko_graphicx_http.sty'. diff --git a/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_tilde.sty b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_tilde.sty new file mode 100644 index 00000000000..104b93088d3 --- /dev/null +++ b/Master/texmf-dist/tex/latex/markdown/markdownthemewitiko_tilde.sty @@ -0,0 +1,52 @@ +%% +%% This is file `markdownthemewitiko_tilde.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% markdown.dtx (with options: `latex-themes-witiko-tilde') +%% +%% Copyright (C) 2016-2021 Vít Novotný +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status `maintained'. +%% The Current Maintainer of this work is Vít Novotný. +%% +%% Send bug reports, requests for additions and questions +%% either to the GitHub issue tracker at +%% +%% https://github.com/Witiko/markdown/issues +%% +%% or to the e-mail address . +%% +%% MODIFICATION ADVICE: +%% +%% If you want to customize this file, it is best to make a copy of +%% the source file(s) from which it was produced. Use a different +%% name for your copy(ies) and modify the copy(ies); this will ensure +%% that your modifications do not get overwritten when you install a +%% new release of the standard system. You should also ensure that +%% your modified source file does not generate any modified file with +%% the same name as a standard file. +%% +%% You will also need to produce your own, suitably named, .ins file to +%% control the generation of files from your source file; this file +%% should contain your own preambles for the files it generates, not +%% those in the standard .ins files. +%% +%% The names of the source files used are shown above. +%% +\ProvidesPackage{markdownthemewitiko_tilde}[2021/03/22]% +\renewcommand\markdownRendererTildePrototype{~}% +\endinput +%% +%% End of file `markdownthemewitiko_tilde.sty'. diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index e6127c8bf6d..8583a21f5a0 100644 --- a/Master/texmf-dist/tex/luatex/markdown/markdown.lua +++ b/Master/texmf-dist/tex/luatex/markdown/markdown.lua @@ -20,7 +20,7 @@ -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- --- Copyright (C) 2016-2020 Vít Novotný +-- Copyright (C) 2016-2021 Vít Novotný -- -- This work may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either version 1.3 @@ -58,18 +58,21 @@ -- those in the standard .ins files. -- local metadata = { - version = "2.9.0", + version = "2.10.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", - "2016-2020 Vít Novotný"}, + "2016-2021 Vít Novotný"}, license = "LPPL 1.3" } if not modules then modules = { } end modules['markdown'] = metadata local lpeg = require("lpeg") -local unicode = require("unicode") +local ran_ok, unicode = pcall(require, "unicode") +if not ran_ok then + unicode = {["utf8"]={char=utf8.char}} +end local md5 = require("md5") local M = {metadata = metadata} local defaultOptions = {} @@ -100,7 +103,9 @@ defaultOptions.shiftHeadings = 0 defaultOptions.slice = "^ $" defaultOptions.smartEllipses = false defaultOptions.startNumber = true +defaultOptions.stripIndent = false defaultOptions.tableCaptions = false +defaultOptions.texComments = false defaultOptions.tightLists = true defaultOptions.underscores = true local upper, gsub, format, length = @@ -119,7 +124,8 @@ function util.cache(dir, string, salt, transform, suffix) local name = util.pathname(dir, digest .. suffix) local file = io.open(name, "r") if file == nil then -- If no cache entry exists, then create a new one. - local file = assert(io.open(name, "w")) + local file = assert(io.open(name, "w"), + [[could not open file "]] .. name .. [[" for writing]]) local result = string if transform ~= nil then result = transform(result) @@ -2382,16 +2388,18 @@ function M.writer.new(options) self.citation = escape_citation self.uri = escape_uri end + self.escape = escape function self.code(s) - return {"\\markdownRendererCodeSpan{",escape(s),"}"} + return {"\\markdownRendererCodeSpan{",self.escape(s),"}"} end function self.link(lab,src,tit) return {"\\markdownRendererLink{",lab,"}", - "{",self.string(src),"}", + "{",self.escape(src),"}", "{",self.uri(src),"}", "{",self.string(tit or ""),"}"} end function self.table(rows, caption) + if not self.is_writing then return "" end local buffer = {"\\markdownRendererTable{", caption or "", "}{", #rows - 1, "}{", #rows[1], "}"} local temp = rows[2] -- put alignments on the first row @@ -2405,10 +2413,10 @@ function M.writer.new(options) end table.insert(buffer, column) if i > 1 then - table.insert(buffer, "}%\n") + table.insert(buffer, "}") end end - table.insert(buffer, "}%\n") + table.insert(buffer, "}") end return buffer end @@ -2419,13 +2427,18 @@ function M.writer.new(options) "{",self.string(tit or ""),"}"} end local languages_json = (function() - local kpse = require("kpse") - kpse.set_program_name("luatex") + local ran_ok, kpse = pcall(require, "kpse") + if ran_ok then + kpse.set_program_name("luatex") + else + kpse = {lookup=function(filename, options) return filename end} + end local base, prev, curr - for _, file in ipairs{kpse.lookup(options.contentBlocksLanguageMap, - { all=true })} do - json = io.open(file, "r"):read("*all") - :gsub('("[^\n]-"):','[%1]=') + for _, filename in ipairs{kpse.lookup(options.contentBlocksLanguageMap, + { all=true })} do + local file = io.open(filename, "r") + if not file then goto continue end + json = file:read("*all"):gsub('("[^\n]-"):','[%1]=') curr = (function() local _ENV={ json=json, load=load } -- run in sandbox return load("return "..json)() @@ -2438,6 +2451,7 @@ function M.writer.new(options) end prev = curr end + ::continue:: end return base or {} end)() @@ -2512,8 +2526,9 @@ function M.writer.new(options) "\n\\markdownRendererOlEnd "} end end - function self.inline_html(html) return "" end - function self.display_html(html) return "" end + function self.inline_html_comment(contents) + return {"\\markdownRendererInlineHtmlComment{",contents,"}"} + end local function dlitem(term, defs) local retVal = {"\\markdownRendererDlItem{",term,"}"} for _, def in ipairs(defs) do @@ -2638,6 +2653,28 @@ function M.writer.new(options) end return buffer end + function self.get_state() + return { + is_writing=self.is_writing, + active_headings={table.unpack(self.active_headings)}, + } + end + function self.set_state(s) + previous_state = self.get_state() + for key, value in pairs(state) do + self[key] = value + end + return previous_state + end + function self.defer_call(f) + state = self.get_state() + return function(...) + state = self.set_state(state) + local return_value = f(...) + self.set_state(state) + return return_value + end + end return self end @@ -2672,6 +2709,7 @@ parsers.semicolon = P(";") parsers.exclamation = P("!") parsers.pipe = P("|") parsers.tilde = P("~") +parsers.backslash = P("\\") parsers.tab = P("\t") parsers.newline = P("\n") parsers.tightblocksep = P("\001") @@ -2694,7 +2732,7 @@ parsers.any = P(1) parsers.fail = parsers.any - 1 parsers.escapable = S("\\`*_{}[]()+_.!<>#-~:^@;") -parsers.anyescaped = P("\\") / "" * parsers.escapable +parsers.anyescaped = parsers.backslash / "" * parsers.escapable + parsers.any parsers.spacechar = S("\t ") @@ -2727,6 +2765,30 @@ parsers.spnl = parsers.optionalspace parsers.line = parsers.linechar^0 * parsers.newline parsers.nonemptyline = parsers.line - parsers.blankline +parsers.commented_line = Cs(((parsers.linechar -- initial + - parsers.backslash + - parsers.percent)^1 + + (parsers.backslash -- even backslash + * parsers.backslash)^1 + + (parsers.backslash -- odd backslash + * parsers.backslash)^0 + * (parsers.backslash / "" + * parsers.percent + + parsers.backslash + * (parsers.linechar -- initial + + parsers.newline + - parsers.backslash + - parsers.percent)) + )^0) + * ((parsers.percent -- comment + * parsers.line + * #parsers.blankline) -- blank line + / "\n" + + parsers.percent -- comment + * parsers.line + * parsers.optionalspace -- leading tabs and spaces + + C(parsers.newline)) + parsers.chunk = parsers.line * (parsers.optionallyindentedline - parsers.blankline)^0 @@ -3131,9 +3193,13 @@ parsers.htmlattribute = parsers.spacing^1 * parsers.sp * parsers.equal * parsers.sp * parsers.htmlattributevalue -parsers.htmlcomment = P(""))^0 * P("-->") +parsers.htmlcomment = P(""))^0) + * parsers.optionalspace + * P("-->") -parsers.htmlinstruction = P("" ))^0 * P("?>" ) +parsers.htmlinstruction = P(""))^0 * P("?>") parsers.openelt_any = parsers.less * parsers.keyword * parsers.htmlattribute^0 * parsers.sp * parsers.more @@ -3180,17 +3246,11 @@ end parsers.in_matched_block_tags = parsers.less * Cmt(#parsers.openelt_block, parse_matched_tags) -parsers.displayhtml = parsers.htmlcomment +parsers.displayhtml = parsers.htmlcomment / "" + parsers.emptyelt_block + parsers.openelt_exact("hr") + parsers.in_matched_block_tags + parsers.htmlinstruction - -parsers.inlinehtml = parsers.emptyelt_any - + parsers.htmlcomment - + parsers.htmlinstruction - + parsers.openelt_any - + parsers.closeelt_any parsers.hexentity = parsers.ampersand * parsers.hash * S("Xx") * C(parsers.hexdigit^1) * parsers.semicolon parsers.decentity = parsers.ampersand * parsers.hash @@ -3280,24 +3340,51 @@ function M.reader.new(writer, options) setmetatable(options, { __index = function (_, key) return defaultOptions[key] end }) local function normalize_tag(tag) - return unicode.utf8.lower( + return string.lower( gsub(util.rope_to_string(tag), "[ \n\r\t]+", " ")) end + local function iterlines(s, f) + rope = lpeg.match(Ct((parsers.line / f)^1), s) + return util.rope_to_string(rope) + end local expandtabs if options.preserveTabs then expandtabs = function(s) return s end else expandtabs = function(s) if s:find("\t") then - return s:gsub("[^\n]*", util.expand_tabs_in_line) + return iterlines(s, util.expand_tabs_in_line) else return s end end end local larsers = {} - local function create_parser(name, grammar) + local function create_parser(name, grammar, toplevel) return function(str) + if toplevel and options.stripIndent then + local min_prefix_length, min_prefix = nil, '' + str = iterlines(str, function(line) + if lpeg.match(parsers.nonemptyline, line) == nil then + return line + end + line = util.expand_tabs_in_line(line) + prefix = lpeg.match(C(parsers.optionalspace), line) + local prefix_length = #prefix + local is_shorter = min_prefix_length == nil + is_shorter = is_shorter or prefix_length < min_prefix_length + if is_shorter then + min_prefix_length, min_prefix = prefix_length, prefix + end + return line + end) + str = str:gsub('^' .. min_prefix, '') + end + if toplevel and options.texComments then + str = lpeg.match(Ct(parsers.commented_line^1), str) + str = util.rope_to_string(str) + print(str) + end local res = lpeg.match(grammar(), str) if res == nil then error(format("%s failed on:\n%s", name, str:sub(1,20))) @@ -3311,37 +3398,43 @@ function M.reader.new(writer, options) = create_parser("parse_blocks", function() return larsers.blocks - end) + end, false) local parse_blocks_toplevel = create_parser("parse_blocks_toplevel", function() return larsers.blocks_toplevel - end) + end, true) local parse_inlines = create_parser("parse_inlines", function() return larsers.inlines - end) + end, false) local parse_inlines_no_link = create_parser("parse_inlines_no_link", function() return larsers.inlines_no_link - end) + end, false) local parse_inlines_no_inline_note = create_parser("parse_inlines_no_inline_note", function() return larsers.inlines_no_inline_note - end) + end, false) + + local parse_inlines_no_html + = create_parser("parse_inlines_no_html", + function() + return larsers.inlines_no_html + end, false) local parse_inlines_nbsp = create_parser("parse_inlines_nbsp", function() return larsers.inlines_nbsp - end) + end, false) if options.hashEnumerators then larsers.dig = parsers.digit + parsers.hash else @@ -3397,14 +3490,14 @@ function M.reader.new(writer, options) -- like indirect_link local function lookup_note(ref) - return function() + return writer.defer_call(function() local found = rawnotes[normalize_tag(ref)] if found then return writer.note(parse_blocks_toplevel(found)) else return {"[", parse_inlines("^" .. ref), "]"} end - end + end) end local function register_note(ref,rawnote) @@ -3479,27 +3572,27 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline -- lookup link reference and return a link, if the reference is found, -- or a bracketed label otherwise. local function indirect_link(label,sps,tag) - return function() + return writer.defer_call(function() local r,fallback = lookup_reference(label,sps,tag) if r then return writer.link(parse_inlines_no_link(label), r.url, r.title) else return fallback end - end + end) end -- lookup image reference and return an image, if the reference is found, -- or a bracketed label otherwise. local function indirect_image(label,sps,tag) - return function() + return writer.defer_call(function() local r,fallback = lookup_reference(label,sps,tag) if r then return writer.image(writer.string(label), r.url, r.title) else return {"!", fallback} end - end + end) end larsers.Str = (parsers.normalchar * (parsers.normalchar + parsers.at)^0) / writer.string @@ -3593,7 +3686,7 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline * C(parsers.alphanumeric^1 * P("://") * parsers.urlchar^1) * parsers.more / function(url) - return writer.link(writer.string(url), url) + return writer.link(writer.escape(url), url) end larsers.AutoLinkEmail = parsers.less @@ -3601,7 +3694,7 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline * P("@") * parsers.urlchar^1) * parsers.more / function(email) - return writer.link(writer.string(email), + return writer.link(writer.escape(email), "mailto:"..email) end @@ -3633,20 +3726,22 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline larsers.Image = larsers.DirectImage + larsers.IndirectImage - larsers.TextCitations = Ct(Cc("") + larsers.TextCitations = Ct((parsers.spnl + * Cc("") * parsers.citation_name * ((parsers.spnl * parsers.lbracket * parsers.citation_headless_body - * parsers.rbracket) + Cc(""))) + * parsers.rbracket) + Cc("")))^1) / function(raw_cites) return larsers.citations(true, raw_cites) end larsers.ParenthesizedCitations - = Ct(parsers.lbracket + = Ct((parsers.spnl + * parsers.lbracket * parsers.citation_body - * parsers.rbracket) + * parsers.rbracket)^1) / function(raw_cites) return larsers.citations(false, raw_cites) end @@ -3657,9 +3752,14 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline larsers.UlOrStarLine = parsers.asterisk^4 + parsers.underscore^4 / writer.string - larsers.EscapedChar = S("\\") * C(parsers.escapable) / writer.string + larsers.EscapedChar = parsers.backslash * C(parsers.escapable) / writer.string - larsers.InlineHtml = C(parsers.inlinehtml) / writer.inline_html + larsers.InlineHtml = parsers.emptyelt_any + + (parsers.htmlcomment / parse_inlines_no_html) + / writer.inline_html_comment + + parsers.htmlinstruction + + parsers.openelt_any + + parsers.closeelt_any larsers.HtmlEntity = parsers.hexentity / entities.hex_entity / writer.string + parsers.decentity / entities.dec_entity / writer.string @@ -3669,8 +3769,7 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline * parsers.contentblock_tail / writer.contentblock - larsers.DisplayHtml = C(parsers.displayhtml) - / expandtabs / writer.display_html + larsers.DisplayHtml = parsers.displayhtml larsers.Verbatim = Cs( (parsers.blanklines * ((parsers.indentedline - parsers.blankline))^1)^1 @@ -3995,6 +4094,10 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline syntax.Smart = parsers.fail end + if options.preserveTabs then + options.stripIndent = false + end + if not options.pipeTables then syntax.PipeTable = parsers.fail end @@ -4018,6 +4121,12 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline inlines_no_inline_note_t.InlineNote = parsers.fail larsers.inlines_no_inline_note = Ct(inlines_no_inline_note_t) + local inlines_no_html_t = util.table_copy(inlines_t) + inlines_no_html_t.DisplayHtml = parsers.fail + inlines_no_html_t.InlineHtml = parsers.fail + inlines_no_html_t.HtmlEntity = parsers.fail + larsers.inlines_no_html = Ct(inlines_no_html_t) + local inlines_nbsp_t = util.table_copy(inlines_t) inlines_nbsp_t.Endline = larsers.NonbreakingEndline inlines_nbsp_t.Space = larsers.NonbreakingSpace @@ -4044,10 +4153,12 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline else mode = "w" end - file = assert(io.open(options.frozenCacheFileName, mode)) - assert(file:write([[\expandafter\def\csname markdownFrozenCache]] .. - options.frozenCacheCounter .. [[\endcsname{]] .. output .. [[}]] .. - "\n")) + file = assert(io.open(options.frozenCacheFileName, mode), + [[could not open file "]] .. options.frozenCacheFileName + .. [[" for writing]]) + assert(file:write([[\expandafter\global\expandafter\def\csname ]] + .. [[markdownFrozenCache]] .. options.frozenCacheCounter + .. [[\endcsname{]] .. output .. [[}]] .. "\n")) assert(file:close()) end return output -- cgit v1.2.3