summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/markdown
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-07-29 21:00:05 +0000
committerKarl Berry <karl@freefriends.org>2022-07-29 21:00:05 +0000
commitc2d2eba4dbcbb6d9555b487010e3486c5b37dddc (patch)
treec9b44160bd004bfcdfb2ed7e81cf6d318aee6622 /Master/texmf-dist/tex/latex/markdown
parenta6300ce69a231968267f6f256bf80298c385d938 (diff)
markdown (28jul22)
git-svn-id: svn://tug.org/texlive/trunk@64000 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/markdown')
-rw-r--r--Master/texmf-dist/tex/latex/markdown/markdown.sty188
1 files changed, 118 insertions, 70 deletions
diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty
index 49ec9ee9e6f..bd67f3ff59d 100644
--- a/Master/texmf-dist/tex/latex/markdown/markdown.sty
+++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty
@@ -42,8 +42,6 @@
%%
%% The names of the source files used are shown above.
%%
-\RequirePackage{keyval}
-\RequirePackage{xstring}
\RequirePackage{expl3}
\newcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}%
\newcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}%
@@ -51,8 +49,16 @@
\input markdown/markdown
\newenvironment{markdown}\relax\relax
\newenvironment{markdown*}[1]\relax\relax
-\newcommand\markdownSetup[1]{%
- \setkeys{markdownOptions}{#1}}%
+\ExplSyntaxOn
+\cs_new:Nn
+ \__markdown_setup:n
+ {
+ \keys_set:nn
+ { markdown/latex-options }
+ { #1 }
+ }
+\let\markdownSetup=\__markdown_setup:n
+\ExplSyntaxOff
\newcommand\markdownSetupSnippet[2]{%
\markdownIfSnippetExists{#1}%
{%
@@ -93,29 +99,57 @@
\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/}}%
-\@onlypreamble\KV@markdownOptions@theme
-\define@key{markdownOptions}{snippet}{%
- \markdownIfSnippetExists{#1}%
- {%
- \expandafter\markdownSetup\expandafter{%
- \the\csname markdownLaTeXSetupSnippet%
- \markdownLaTeXThemeName#1\endcsname}%
- }{%
- \markdownError
- {Can't invoke setup snippet #1}%
- {The setup snippet is undefined}%
- }%
- }%
+\ExplSyntaxOn
+\tl_new:N \markdownLaTeXThemePackageName
+\cs_new:Nn
+ \__markdown_set_latex_theme:n
+ {
+ \str_if_in:NnF
+ { #1 }
+ { / }
+ {
+ \markdownError
+ { Won't load theme with unqualified name #1 }
+ { Theme names must contain at least one forward slash }
+ }
+ \tl_set:Nn \markdownLaTeXThemePackageName { #1 }
+ \str_replace_all:Nnn
+ \markdownLaTeXThemePackageName
+ { / }
+ { _ }
+ \edef\markdownLaTeXThemePackageName{
+ markdowntheme\markdownLaTeXThemePackageName}
+ \expandafter\markdownLaTeXThemeLoad\expandafter{
+ \markdownLaTeXThemePackageName}{#1/}
+ }
+\keys_define:nn
+ { markdown/latex-options }
+ {
+ theme .code:n = { \__markdown_set_latex_theme:n { #1 } },
+ }
+\ExplSyntaxOff
+\ExplSyntaxOn
+\@onlypreamble
+ \__markdown_set_latex_theme:n
+\ExplSyntaxOff
+\ExplSyntaxOn
+\keys_define:nn
+ { markdown/latex-options }
+ {
+ snippet .code:n = {
+ \markdownIfSnippetExists{#1}
+ {
+ \expandafter\markdownSetup\expandafter{
+ \the\csname markdownLaTeXSetupSnippet
+ \markdownLaTeXThemeName#1\endcsname}
+ }{
+ \markdownError
+ {Can't~invoke~setup~snippet~#1}
+ {The~setup~snippet~is~undefined}
+ }
+ }
+ }
+\ExplSyntaxOff
\ExplSyntaxOn
\cs_new:Nn \__markdown_latex_define_option_commands_and_keyvals:
{
@@ -143,28 +177,23 @@
{ g__markdown_ #1 _option_types_prop }
{ #2 }
\l_tmpa_tl
- \str_if_eq:VVTF
- \l_tmpa_tl
- \c__markdown_option_type_boolean_tl
+ \keys_define:nn
+ { markdown/latex-options }
{
- \define@key
- { markdownOptions }
- { #2 }
- [ true ]
- {
- \__markdown_set_option_value:nn
- { #2 }
- { ##1 }
- }
+ #2 .code:n = {
+ \__markdown_set_option_value:nn
+ { #2 }
+ { ##1 }
+ },
}
+ \str_if_eq:VVT
+ \l_tmpa_tl
+ \c__markdown_option_type_boolean_tl
{
- \define@key
- { markdownOptions }
- { #2 }
+ \keys_define:nn
+ { markdown/latex-options }
{
- \__markdown_set_option_value:nn
- { #2 }
- { ##1 }
+ #2 .default:n = { true },
}
}
}
@@ -197,7 +226,7 @@
{
\tl_set:Nn
\l_tmpa_tl
- { \str_upper_case:n { #1 } }
+ { \str_uppercase:n { #1 } }
\tl_set:Nx
#2
{
@@ -208,15 +237,16 @@
}
\cs_new:Nn \__markdown_latex_define_renderer:nNn
{
- \define@key
- { markdownRenderers }
- { #1 }
+ \keys_define:nn
+ { markdown/latex-options/renderers }
{
- \cs_generate_from_arg_count:NNnn
- #2
- \cs_set:Npn
- { #3 }
- { ##1 }
+ #1 .code:n = {
+ \cs_generate_from_arg_count:NNnn
+ #2
+ \cs_set:Npn
+ { #3 }
+ { ##1 }
+ },
}
}
\cs_generate_variant:Nn
@@ -246,15 +276,16 @@
}
\cs_new:Nn \__markdown_latex_define_renderer_prototype:nNn
{
- \define@key
- { markdownRendererPrototypes }
- { #1 }
+ \keys_define:nn
+ { markdown/latex-options/renderer-prototypes }
{
- \cs_generate_from_arg_count:NNnn
- #2
- \cs_set:Npn
- { #3 }
- { ##1 }
+ #1 .code:n = {
+ \cs_generate_from_arg_count:NNnn
+ #2
+ \cs_set:Npn
+ { #3 }
+ { ##1 }
+ },
}
}
\cs_generate_variant:Nn
@@ -322,13 +353,23 @@
\DeclareOption*{%
\expandafter\markdownSetup\expandafter{\CurrentOption}}%
\ProcessOptions\relax
-\define@key{markdownOptions}{renderers}{%
- \setkeys{markdownRenderers}{#1}%
- \def\KV@prefix{KV@markdownOptions@}}%
-\define@key{markdownOptions}{rendererPrototypes}{%
- \setkeys{markdownRendererPrototypes}{#1}%
- \def\KV@prefix{KV@markdownOptions@}}%
-\define@key{markdownOptions}{code}{#1}%
+\ExplSyntaxOn
+\keys_define:nn
+ { markdown/latex-options }
+ {
+ renderers .code:n = {
+ \keys_set:nn
+ { markdown/latex-options/renderers }
+ { #1 }
+ },
+ rendererPrototypes .code:n = {
+ \keys_set:nn
+ { markdown/latex-options/renderer-prototypes }
+ { #1 }
+ },
+ code .code:n = { #1 },
+ }
+\ExplSyntaxOff
\markdownIfOption{plain}{\iffalse}{\iftrue}
\markdownIfOption{tightLists}{
\@ifclassloaded{beamer}{}{\RequirePackage{paralist}}%
@@ -462,8 +503,15 @@
\fi},
horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}},
footnote = {\footnote{#1}}}}
+\ExplSyntaxOn
\def\markdownLATEXStrongEmphasis#1{%
- \IfSubStr\f@series{b}{\textnormal{#1}}{\textbf{#1}}}
+ \str_if_in:NnTF
+ \f@series
+ { b }
+ { \textnormal{#1} }
+ { \textbf{#1} }
+}
+\ExplSyntaxOff
\markdownSetup{rendererPrototypes={strongEmphasis={%
\protect\markdownLATEXStrongEmphasis{#1}}}}
\@ifundefined{chapter}{%