From d838c20c4fdae5db1e2fe6e3e42d17926869fc34 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 30 Aug 2022 19:51:52 +0000 Subject: markdown (30aug22) git-svn-id: svn://tug.org/texlive/trunk@64240 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/generic/markdown/markdown.dtx | 118 +++++++++++++-------- 1 file changed, 72 insertions(+), 46 deletions(-) (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx index ec13dced2c9..4db4ecfcc3c 100644 --- a/Master/texmf-dist/source/generic/markdown/markdown.dtx +++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx @@ -859,7 +859,7 @@ abbr { --- title: Markdown Package User Manual author: Vít Novotný -date: \markdownVersion{} (\markdownLastModified{}) +date: \markdownVersion{} \markdownLastModified{} --- @@ -23963,11 +23963,13 @@ end % \end{macrocode} % \begin{markdown} % Swap the category code of the backslash symbol and the pipe symbol, so that -% we may use the backslash symbol freely inside the Lua code. +% we may use the backslash symbol freely inside the Lua code. Furthermore, +% use the ampersand symbol to specify parameters. % \end{markdown} % \begin{macrocode} \catcode`|=0% \catcode`\\=12% + \catcode`|&=6% |gdef|markdownInput#1{% % \end{macrocode} % \begin{markdown} @@ -23980,6 +23982,14 @@ end |catcode`|%=12 % \end{macrocode} % \begin{markdown} +% Furthermore, also change the category code of the hash sign (`#`) to other, +% so that it's safe to tokenize the plain TeX output without mistaking hash +% signs with TeX's parameter numbers. +% \end{markdown} +% \begin{macrocode} + |catcode`|#=12 +% \end{macrocode} +% \begin{markdown} % If we are reading from the frozen cache, input it, expand the corresponding % `\markdownFrozenCache`\meta{number} macro, and increment % \Opt{frozenCacheCounter}. @@ -23996,7 +24006,7 @@ end |csname markdownFrozenCache|the|markdownOptionFrozenCacheCounter|endcsname |global|advance|markdownOptionFrozenCacheCounter by 1|relax }{% - |markdownInfo{Including markdown document "#1"}% + |markdownInfo{Including markdown document "&1"}% % \end{macrocode} % \begin{markdown} % Attempt to open the markdown document to record it in the `.log` and @@ -24004,13 +24014,13 @@ end % changes to the markdown document. % \end{markdown} % \begin{macrocode} - |openin|markdownInputFileStream#1 + |openin|markdownInputFileStream&1 |closein|markdownInputFileStream |markdownPrepareLuaOptions |markdownLuaExecute{% |markdownPrepare - local file = assert(io.open("#1", "r"), - [[could not open file "#1" for reading]]) + local file = assert(io.open("&1", "r"), + [[could not open file "&1" for reading]]) local input = assert(file:read("*a")) assert(file:close()) % \end{macrocode} @@ -24542,17 +24552,17 @@ end { { Default } { . } { OneParen } { ) } - { Period } { - } + { Period } { . } } } \cs_new:Nn \@@_latex_fancy_list_item_label:nnn { - \@@_latex_fancy_list_item_label_delimiter:n - { #2 } \@@_latex_fancy_list_item_label_number:nn { #1 } { #3 } + \@@_latex_fancy_list_item_label_delimiter:n + { #2 } } \cs_new:Nn \@@_latex_paralist_style:nn @@ -24580,7 +24590,16 @@ end \tl_set:Nn \l_@@_latex_fancy_list_item_label_delimiter_style_tl { #2 } - \begin{enumerate}[ \@@_latex_paralist_style:nn { #1 } { #2 } ] + \tl_set:Nn + \l_tmpa_tl + { \begin{enumerate}[ } + \tl_put_right:Nx + \l_tmpa_tl + { \@@_latex_paralist_style:nn { #1 } { #2 } } + \tl_put_right:Nn + \l_tmpa_tl + { ] } + \l_tmpa_tl }, fancyOlEnd = { \end{enumerate} @@ -24596,20 +24615,29 @@ end \tl_set:Nn \l_@@_latex_fancy_list_item_label_delimiter_style_tl { #2 } - \begin{compactenum}[ \@@_latex_paralist_style:nn { #1 } { #2 } ] + \tl_set:Nn + \l_tmpa_tl + { \begin{compactenum}[ } + \tl_put_right:Nx + \l_tmpa_tl + { \@@_latex_paralist_style:nn { #1 } { #2 } } + \tl_put_right:Nn + \l_tmpa_tl + { ] } + \l_tmpa_tl }, fancyOlEndTight = { \end{compactenum} \group_end: }, fancyOlItemWithNumber = { - \markdownRendererOlItemWithNumber - { + \item + [ \@@_latex_fancy_list_item_label:VVn \l_@@_latex_fancy_list_item_label_number_style_tl \l_@@_latex_fancy_list_item_label_delimiter_style_tl { #1 } - } + ] }, dlBeginTight = {\begin{compactdesc}}, dlEndTight = {\end{compactdesc}}}} @@ -24701,8 +24729,10 @@ end }{% \ifthenelse{\equal{#1}{tex}}{% \catcode`\%=14\relax + \catcode`\#=6\relax \input #3\relax \catcode`\%=12\relax + \catcode`\#=12\relax }{% \markdownInput{#3}% }% @@ -24793,7 +24823,9 @@ end % \end{markdown} % \begin{macrocode} }{% + \catcode`\#=6\relax \inputminted{#2}{#1}% + \catcode`\#=12\relax }% \fi}, horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}}, @@ -25156,11 +25188,23 @@ end \RequirePackage{url} \RequirePackage{expl3} \ExplSyntaxOn -\def\markdownRendererLinkPrototype{ - \begingroup - \catcode`\#=12 - \def\next##1##2##3##4{ - \endgroup +\def\markdownRendererLinkPrototype#1#2#3#4{ + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_set:Nn \l_tmpb_tl { #2 } + \bool_set:Nn + \l_tmpa_bool + { + \tl_if_eq_p:NN + \l_tmpa_tl + \l_tmpb_tl + } + \tl_set:Nn \l_tmpa_tl { #4 } + \bool_set:Nn + \l_tmpb_bool + { + \tl_if_empty_p:N + \l_tmpa_tl + } % \end{macrocode} % \begin{markdown} % If the label and the fully-escaped URI are equivalent and the title is @@ -25168,33 +25212,15 @@ end % link is either direct or indirect. % \end{markdown} % \begin{macrocode} - \tl_set:Nn \l_tmpa_tl { ##1 } - \tl_set:Nn \l_tmpb_tl { ##2 } - \bool_set:Nn - \l_tmpa_bool - { - \tl_if_eq_p:NN - \l_tmpa_tl - \l_tmpb_tl - } - \tl_set:Nn \l_tmpa_tl { ##4 } - \bool_set:Nn - \l_tmpb_bool - { - \tl_if_empty_p:N - \l_tmpa_tl - } - \bool_if:nTF - { - \l_tmpa_bool && \l_tmpb_bool - } - { - \markdownLaTeXRendererAutolink { ##2 } { ##3 } - }{ - \markdownLaTeXRendererDirectOrIndirectLink { ##1 } { ##2 } { ##3 } { ##4 } - } - } - \next + \bool_if:nTF + { + \l_tmpa_bool && \l_tmpb_bool + } + { + \markdownLaTeXRendererAutolink { #2 } { #3 } + }{ + \markdownLaTeXRendererDirectOrIndirectLink { #1 } { #2 } { #3 } { #4 } + } } \def\markdownLaTeXRendererAutolink#1#2{% % \end{macrocode} -- cgit v1.2.3