Skip to content

Commit

Permalink
Remove dependency on ifthen, rewrite witiko/dot to expl3
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Nov 19, 2024
1 parent 80a1a29 commit 97e4a1c
Showing 1 changed file with 58 additions and 35 deletions.
93 changes: 58 additions & 35 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1399,19 +1399,6 @@ soft paralist
% \end{macrocode}
% \begin{markdown}
%
% \pkg{ifthen}
%
%: A package that provides a concise syntax for the inspection of macro
% values. It is used in the `witiko/dot` \LaTeX{} theme (see Section
% <#sec:latexthemes>).
%
% \end{markdown}
% \begin{macrocode}
soft latex
soft epstopdf-pkg # required by `latex`
% \end{macrocode}
% \begin{markdown}
%
% \pkg{fancyvrb}
%
%: A package that provides the `\VerbatimInput` macros for the verbatim
Expand Down Expand Up @@ -23236,7 +23223,7 @@ conference article:
%<*themes-witiko-dot>
% \fi
% \begin{macrocode}
\ProvidesPackage{markdownthemewitiko_dot}[2021/03/09]%
\ProvidesPackage{markdownthemewitiko_dot}[2024/11/19]%
% \end{macrocode}
% \iffalse
%</themes-witiko-dot>
Expand Down Expand Up @@ -37404,20 +37391,22 @@ end
% \end{macrocode}
% \begin{markdown}
%
% We load the \pkg{ifthen} and \pkg{grffile} packages, see also
% Section <#sec:latex-prerequisites>:
% We load \pkg{grffile} package, see also Section
% <#sec:latex-prerequisites>:
%
% \end{markdown}
% \begin{macrocode}
\RequirePackage{ifthen,grffile}
\RequirePackage{grffile}
% \end{macrocode}
% \begin{markdown}
%
% We store the previous definition of the fenced code token renderer prototype:
%
% \end{markdown}
% \begin{macrocode}
\let\markdown@witiko@dot@oldRendererInputFencedCodePrototype
\ExplSyntaxOn
\cs_seq_eq:NN
\@@_dot_previous_definition:nnn
\markdownRendererInputFencedCodePrototype
% \end{macrocode}
% \begin{markdown}
Expand All @@ -37429,24 +37418,53 @@ end
%
% \end{markdown}
% \begin{macrocode}
\renewcommand\markdownRendererInputFencedCodePrototype[3]{%
\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}}%
\regex_const:Nn
\c_@@_dot_infostring_regex
{ ^dot~(.*) }
\seq_new:N
\l_@@_dot_matches_seq
\markdownSetup {
rendererPrototypes = {
inputFencedCodePrototype = {
\regex_extract_once:NnNTF
\c_@@_dot_infostring_regex
{ #2 }
\l_@@_dot_matches_seq
{
\@@_if_option:nF
{ frozenCache }
{
\sys_shell_now:n
{
if ! test -e #1.pdf.source
|| ! diff #1 #1.pdf.source;
then
dot -Tpdf -o #1.pdf #1;
cp #1 #1.pdf.source;
fi
}
}
% \end{macrocode}
% \begin{markdown}
%
% We include the typeset image using the image token renderer:
%
% \end{markdown}
% \begin{macrocode}
\markdownRendererImage{Graphviz image}{#1.pdf}{#1.pdf}{##2}%
\exp_args:NNne
\exp_last_unbraced:No
\markdownRendererImage
{
{ Graphviz image }
{ #1.pdf }
{ #1.pdf }
}
{
\seq_item:Nn
\l_@@_dot_matches_seq
{ 2 }
}
}
% \end{macrocode}
% \begin{markdown}
%
Expand All @@ -37455,12 +37473,17 @@ end
%
% \end{markdown}
% \begin{macrocode}
}{%
\markdown@witiko@dot@oldRendererInputFencedCodePrototype
{#1}{#2}{#3}%
}%
}%
\next#2 \relax}%
{
\@@_dot_previous_definition:nnn
{ #1 }
{ #2 }
{ #3 }

}
},
},
}
\ExplSyntaxOff
% \end{macrocode}
% \iffalse
%</themes-witiko-dot>
Expand Down

0 comments on commit 97e4a1c

Please sign in to comment.