diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/markdown/markdown.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/markdown/markdown.sty | 252 |
1 files changed, 121 insertions, 131 deletions
diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index da080d33d5b..49ec9ee9e6f 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -6,18 +6,15 @@ %% %% markdown.dtx (with options: `latex') %% -%% Copyright (C) 2016-2021 Vít Novotný +%% Copyright (C) 2016-2022 Vít Novotný %% %% This work may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3 +%% conditions of the LaTeX Project Public License, either version 1.3c %% 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ý. %% @@ -48,6 +45,10 @@ \RequirePackage{keyval} \RequirePackage{xstring} \RequirePackage{expl3} +\newcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}% +\newcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}% +\newcommand\markdownError[2]{\PackageError{markdown}{#1}{#2.}}% +\input markdown/markdown \newenvironment{markdown}\relax\relax \newenvironment{markdown*}[1]\relax\relax \newcommand\markdownSetup[1]{% @@ -69,15 +70,26 @@ \@ifundefined {markdownLaTeXSetupSnippet\markdownLaTeXThemeName#1}% {#3}{#2}}% -\newif\ifmarkdownLaTeXPlain - \markdownLaTeXPlainfalse -\define@key{markdownOptions}{plain}[true]{% - \ifmarkdownLaTeXLoaded - \markdownWarning - {The plain option must be specified when loading the package}% - \else - \markdownLaTeXPlaintrue - \fi} +\ExplSyntaxOn +\seq_new:N \g__markdown_latex_options_seq +\prop_new:N \g__markdown_latex_option_types_prop +\prop_new:N \g__markdown_default_latex_options_prop +\tl_const:Nn \c__markdown_option_layer_latex_tl { latex } +\seq_put_right:NV \g__markdown_option_layers_seq \c__markdown_option_layer_latex_tl +\cs_new:Nn + \__markdown_add_latex_option:nnn + { + \__markdown_add_option:Vnnn + \c__markdown_option_layer_latex_tl + { #1 } + { #2 } + { #3 } + } +\__markdown_add_latex_option:nnn + { plain } + { boolean } + { false } +\ExplSyntaxOff \newif\ifmarkdownLaTeXLoaded \markdownLaTeXLoadedfalse \AtEndOfPackage{\markdownLaTeXLoadedtrue} @@ -104,96 +116,62 @@ {The setup snippet is undefined}% }% }% -\define@key{markdownOptions}{helperScriptFileName}{% - \def\markdownOptionHelperScriptFileName{#1}}% -\define@key{markdownOptions}{inputTempFileName}{% - \def\markdownOptionInputTempFileName{#1}}% -\define@key{markdownOptions}{outputTempFileName}{% - \def\markdownOptionOutputTempFileName{#1}}% -\define@key{markdownOptions}{errorTempFileName}{% - \def\markdownOptionErrorTempFileName{#1}}% -\define@key{markdownOptions}{cacheDir}{% - \def\markdownOptionCacheDir{#1}}% -\define@key{markdownOptions}{outputDir}{% - \def\markdownOptionOutputDir{#1}}% -\define@key{markdownOptions}{blankBeforeBlockquote}[true]{% - \def\markdownOptionBlankBeforeBlockquote{#1}}% -\define@key{markdownOptions}{blankBeforeCodeFence}[true]{% - \def\markdownOptionBlankBeforeCodeFence{#1}}% -\define@key{markdownOptions}{blankBeforeHeading}[true]{% - \def\markdownOptionBlankBeforeHeading{#1}}% -\define@key{markdownOptions}{breakableBlockquotes}[true]{% - \def\markdownOptionBreakableBlockquotes{#1}}% -\define@key{markdownOptions}{citations}[true]{% - \def\markdownOptionCitations{#1}}% -\define@key{markdownOptions}{citationNbsps}[true]{% - \def\markdownOptionCitationNbsps{#1}}% -\define@key{markdownOptions}{contentBlocks}[true]{% - \def\markdownOptionContentBlocks{#1}}% -\define@key{markdownOptions}{codeSpans}[true]{% - \def\markdownOptionCodeSpans{#1}}% -\define@key{markdownOptions}{contentBlocksLanguageMap}{% - \def\markdownOptionContentBlocksLanguageMap{#1}}% -\define@key{markdownOptions}{definitionLists}[true]{% - \def\markdownOptionDefinitionLists{#1}}% -\define@key{markdownOptions}{eagerCache}[true]{% - \def\markdownOptionEagerCache{#1}}% -\define@key{markdownOptions}{expectJekyllData}[true]{% - \def\markdownOptionExpectJekyllData{#1}}% -\define@key{markdownOptions}{footnotes}[true]{% - \def\markdownOptionFootnotes{#1}}% -\define@key{markdownOptions}{fencedCode}[true]{% - \def\markdownOptionFencedCode{#1}}% -\define@key{markdownOptions}{jekyllData}[true]{% - \def\markdownOptionJekyllData{#1}}% -\define@key{markdownOptions}{hardLineBreaks}[true]{% - \def\markdownOptionHardLineBreaks{#1}}% -\define@key{markdownOptions}{hashEnumerators}[true]{% - \def\markdownOptionHashEnumerators{#1}}% -\define@key{markdownOptions}{headerAttributes}[true]{% - \def\markdownOptionHeaderAttributes{#1}}% -\define@key{markdownOptions}{html}[true]{% - \def\markdownOptionHtml{#1}}% -\define@key{markdownOptions}{hybrid}[true]{% - \def\markdownOptionHybrid{#1}}% -\define@key{markdownOptions}{inlineFootnotes}[true]{% - \def\markdownOptionInlineFootnotes{#1}}% -\define@key{markdownOptions}{pipeTables}[true]{% - \def\markdownOptionPipeTables{#1}}% -\define@key{markdownOptions}{preserveTabs}[true]{% - \def\markdownOptionPreserveTabs{#1}}% -\define@key{markdownOptions}{relativeReferences}[true]{% - \def\markdownOptionRelativeReferences{#1}}% -\define@key{markdownOptions}{smartEllipses}[true]{% - \def\markdownOptionSmartEllipses{#1}}% -\define@key{markdownOptions}{shiftHeadings}{% - \def\markdownOptionShiftHeadings{#1}}% -\define@key{markdownOptions}{slice}{% - \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}{taskLists}[true]{% - \def\markdownOptionTaskLists{#1}}% -\define@key{markdownOptions}{texComments}[true]{% - \def\markdownOptionTexComments{#1}}% -\define@key{markdownOptions}{tightLists}[true]{% - \def\markdownOptionTightLists{#1}}% -\define@key{markdownOptions}{underscores}[true]{% - \def\markdownOptionUnderscores{#1}}% -\define@key{markdownOptions}{stripPercentSigns}[true]{% - \def\markdownOptionStripPercentSigns{#1}}% -\define@key{markdownOptions}{finalizeCache}[true]{% - \def\markdownOptionFinalizeCache{#1}}% +\ExplSyntaxOn +\cs_new:Nn \__markdown_latex_define_option_commands_and_keyvals: + { + \seq_map_inline:Nn + \g__markdown_latex_options_seq + { + \__markdown_plain_tex_define_option_command:n + { ##1 } + } + \seq_map_inline:Nn + \g__markdown_option_layers_seq + { + \seq_map_inline:cn + { g__markdown_ ##1 _options_seq } + { + \__markdown_latex_define_option_keyval:nn + { ##1 } + { ####1 } + } + } + } +\cs_new:Nn \__markdown_latex_define_option_keyval:nn + { + \prop_get:cnN + { g__markdown_ #1 _option_types_prop } + { #2 } + \l_tmpa_tl + \str_if_eq:VVTF + \l_tmpa_tl + \c__markdown_option_type_boolean_tl + { + \define@key + { markdownOptions } + { #2 } + [ true ] + { + \__markdown_set_option_value:nn + { #2 } + { ##1 } + } + } + { + \define@key + { markdownOptions } + { #2 } + { + \__markdown_set_option_value:nn + { #2 } + { ##1 } + } + } + } +\__markdown_latex_define_option_commands_and_keyvals: +\ExplSyntaxOff \DeclareOption{finalizecache}{\markdownSetup{finalizeCache}} -\define@key{markdownOptions}{frozenCache}[true]{% - \def\markdownOptionFrozenCache{#1}}% \DeclareOption{frozencache}{\markdownSetup{frozenCache}} -\define@key{markdownOptions}{frozenCacheFileName}{% - \def\markdownOptionFrozenCacheFileName{#1}}% \ExplSyntaxOn \cs_new:Nn \__markdown_latex_define_renderers: { @@ -203,16 +181,9 @@ } \cs_new:Nn \__markdown_latex_define_renderer:n { - \tl_set:Nn - \l_tmpb_tl - { \str_upper_case:n { #1 } } - \tl_set:Nx + \__markdown_renderer_tl_to_csname:nN + { #1 } \l_tmpa_tl - { - markdownRenderer - \tl_head:f { \l_tmpb_tl } - \tl_tail:n { #1 } - } \prop_get:NnN \g__markdown_renderer_arities_prop { #1 } @@ -222,6 +193,19 @@ { \l_tmpa_tl } \l_tmpb_tl } +\cs_new:Nn \__markdown_renderer_tl_to_csname:nN + { + \tl_set:Nn + \l_tmpa_tl + { \str_upper_case:n { #1 } } + \tl_set:Nx + #2 + { + markdownRenderer + \tl_head:f { \l_tmpa_tl } + \tl_tail:n { #1 } + } + } \cs_new:Nn \__markdown_latex_define_renderer:nNn { \define@key @@ -248,17 +232,9 @@ } \cs_new:Nn \__markdown_latex_define_renderer_prototype:n { - \tl_set:Nn - \l_tmpb_tl - { \str_upper_case:n { #1 } } - \tl_set:Nx + \__markdown_renderer_prototype_tl_to_csname:nN + { #1 } \l_tmpa_tl - { - markdownRenderer - \tl_head:f { \l_tmpb_tl } - \tl_tail:n { #1 } - Prototype - } \prop_get:NnN \g__markdown_renderer_arities_prop { #1 } @@ -285,10 +261,6 @@ \__markdown_latex_define_renderer_prototype:nNn { ncV } \ExplSyntaxOff -\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]% @@ -357,7 +329,7 @@ \setkeys{markdownRendererPrototypes}{#1}% \def\KV@prefix{KV@markdownOptions@}}% \define@key{markdownOptions}{code}{#1}% -\ifmarkdownLaTeXPlain\else +\markdownIfOption{plain}{\iffalse}{\iftrue} \markdownIfOption{tightLists}{ \@ifclassloaded{beamer}{}{\RequirePackage{paralist}}% }{} @@ -811,16 +783,34 @@ \next } \def\markdownLaTeXRendererAutolink#1#2{% - \tl_set:Nx + \tl_set:Nn \l_tmpa_tl - { \str_range:nnn { #2 } { 1 } { 1 } } - \str_if_eq:NNTF + { #2 } + \tl_trim_spaces:N \l_tmpa_tl + \tl_set:Nx + \l_tmpb_tl + { + \tl_range:Nnn + \l_tmpa_tl + { 1 } + { 1 } + } + \str_if_eq:NNTF + \l_tmpb_tl \c_hash_str { - \exp_args:No + \tl_set:Nx + \l_tmpb_tl + { + \tl_range:Nnn + \l_tmpa_tl + { 2 } + { -1 } + } + \exp_args:NV \ref - { \str_range:nnn { #2 } { 2 } { -1 } } + \l_tmpb_tl }{ \url { #2 } } |