diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/markdown/markdown.sty | 192 |
1 files changed, 161 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index 7ddde4014b1..8645918a346 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -47,6 +47,7 @@ %% \RequirePackage{keyval} \RequirePackage{xstring} +\RequirePackage{expl3} \newenvironment{markdown}\relax\relax \newenvironment{markdown*}[1]\relax\relax \newcommand\markdownSetup[1]{% @@ -75,7 +76,7 @@ \fi} \newif\ifmarkdownLaTeXLoaded \markdownLaTeXLoadedfalse -\AtEndOfPackage{\markdownLaTeXLoadedtrue}% +\AtEndOfPackage{\markdownLaTeXLoadedtrue} \define@key{markdownOptions}{theme}{% \IfSubStr{#1}{/}{}{% \markdownError @@ -86,22 +87,18 @@ 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}}% + \@ifundefined + {markdownLaTeXSetupSnippet#1}{% + \markdownError + {Can't invoke setup snippet #1}% + {The setup snippet is undefined}% + }{% + \expandafter\markdownSetup\expandafter{% + \the\csname markdownLaTeXSetupSnippet#1\endcsname}% + }% + }% \define@key{markdownOptions}{helperScriptFileName}{% \def\markdownOptionHelperScriptFileName{#1}}% \define@key{markdownOptions}{inputTempFileName}{% @@ -158,6 +155,8 @@ \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}{% @@ -188,6 +187,12 @@ \DeclareOption{frozencache}{\markdownSetup{frozenCache}} \define@key{markdownOptions}{frozenCacheFileName}{% \def\markdownOptionFrozenCacheFileName{#1}}% +\define@key{markdownRenderers}{attributeIdentifier}{% + \renewcommand\markdownRendererAttributeIdentifier[1]{#1}}% +\define@key{markdownRenderers}{attributeClassName}{% + \renewcommand\markdownRendererAttributeClassName[1]{#1}}% +\define@key{markdownRenderers}{attributeKeyValue}{% + \renewcommand\markdownRendererAttributeKeyValue[2]{#1}}% \define@key{markdownRenderers}{documentBegin}{% \renewcommand\markdownRendererDocumentBegin{#1}}% \define@key{markdownRenderers}{documentEnd}{% @@ -198,6 +203,10 @@ \renewcommand\markdownRendererLineBreak{#1}}% \define@key{markdownRenderers}{ellipsis}{% \renewcommand\markdownRendererEllipsis{#1}}% +\define@key{markdownRenderers}{headerAttributeContextBegin}{% + \renewcommand\markdownRendererHeaderAttributeContextBegin{#1}}% +\define@key{markdownRenderers}{headerAttributeContextEnd}{% + \renewcommand\markdownRendererHeaderAttributeContextEnd{#1}}% \define@key{markdownRenderers}{nbsp}{% \renewcommand\markdownRendererNbsp{#1}}% \define@key{markdownRenderers}{leftBrace}{% @@ -332,12 +341,26 @@ \renewcommand\markdownRendererTable[3]{#1}}% \define@key{markdownRenderers}{inlineHtmlComment}{% \renewcommand\markdownRendererInlineHtmlComment[1]{#1}}% +\define@key{markdownRenderers}{blockHtmlCommentBegin}{% + \renewcommand\markdownRendererBlockHtmlCommentBegin{#1}}% +\define@key{markdownRenderers}{blockHtmlCommentEnd}{% + \renewcommand\markdownRendererBlockHtmlCommentEnd{#1}}% +\define@key{markdownRenderers}{inlineHtmlTag}{% + \renewcommand\markdownRendererInlineHtmlTag[1]{#1}}% +\define@key{markdownRenderers}{inputBlockHtmlElement}{% + \renewcommand\markdownRendererInputBlockHtmlElement[1]{#1}}% \define@key{markdownRenderers}{tickedBox}{% \renewcommand\markdownRendererTickedBox{#1}}% \define@key{markdownRenderers}{halfTickedBox}{% \renewcommand\markdownRendererHalfTickedBox{#1}}% \define@key{markdownRenderers}{untickedBox}{% \renewcommand\markdownRendererUntickedBox{#1}}% +\define@key{markdownRendererPrototypes}{attributeIdentifier}{% + \renewcommand\markdownRendererAttributeIdentifierPrototype[1]{#1}}% +\define@key{markdownRendererPrototypes}{attributeClassName}{% + \renewcommand\markdownRendererAttributeClassNamePrototype[1]{#1}}% +\define@key{markdownRendererPrototypes}{attributeKeyValue}{% + \renewcommand\markdownRendererAttributeKeyValuePrototype[2]{#1}}% \define@key{markdownRendererPrototypes}{documentBegin}{% \renewcommand\markdownRendererDocumentBeginPrototype{#1}}% \define@key{markdownRendererPrototypes}{documentEnd}{% @@ -348,6 +371,10 @@ \renewcommand\markdownRendererLineBreakPrototype{#1}}% \define@key{markdownRendererPrototypes}{ellipsis}{% \renewcommand\markdownRendererEllipsisPrototype{#1}}% +\define@key{markdownRendererPrototypes}{headerAttributeContextBegin}{% + \renewcommand\markdownRendererHeaderAttributeContextBeginPrototype{#1}}% +\define@key{markdownRendererPrototypes}{headerAttributeContextEnd}{% + \renewcommand\markdownRendererHeaderAttributeContextEndPrototype{#1}}% \define@key{markdownRendererPrototypes}{nbsp}{% \renewcommand\markdownRendererNbspPrototype{#1}}% \define@key{markdownRendererPrototypes}{leftBrace}{% @@ -482,6 +509,14 @@ \renewcommand\markdownRendererTablePrototype[3]{#1}}% \define@key{markdownRendererPrototypes}{inlineHtmlComment}{% \renewcommand\markdownRendererInlineHtmlCommentPrototype[1]{#1}}% +\define@key{markdownRendererPrototypes}{blockHtmlCommentBegin}{% + \renewcommand\markdownRendererBlockHtmlCommentBeginPrototype{#1}}% +\define@key{markdownRendererPrototypes}{blockHtmlCommentEnd}{% + \renewcommand\markdownRendererBlockHtmlCommentEndPrototype{#1}}% +\define@key{markdownRendererPrototypes}{inlineHtmlTag}{% + \renewcommand\markdownRendererInlineHtmlTagPrototype[1]{#1}}% +\define@key{markdownRendererPrototypes}{inputBlockHtmlElement}{% + \renewcommand\markdownRendererInputBlockHtmlElementPrototype[1]{#1}}% \define@key{markdownRendererPrototypes}{tickedBox}{% \renewcommand\markdownRendererTickedBoxPrototype{#1}}% \define@key{markdownRendererPrototypes}{halfTickedBox}{% @@ -515,6 +550,37 @@ |markdownReadAndConvert<\end{markdown#1}>% <|end<markdown#1>>>% |endgroup +\ExplSyntaxOn +\newcommand\markdownLaTeXThemeName{} +\seq_new:N \g__markdown_latex_themes_seq +\seq_put_right:NV + \g__markdown_latex_themes_seq + \markdownLaTeXThemeName +\newcommand\markdownLaTeXThemeLoad[2]{ + \def\@tempa{% + \def\markdownLaTeXThemeName{#2} + \seq_put_right:NV + \g__markdown_latex_themes_seq + \markdownLaTeXThemeName + \RequirePackage{#1} + \seq_pop_right:NN + \g__markdown_latex_themes_seq + \l_tmpa_tl + \seq_get_right:NN + \g__markdown_latex_themes_seq + \l_tmpa_tl + \exp_args:NNV + \def + \markdownLaTeXThemeName + \l_tmpa_tl} + \ifmarkdownLaTeXLoaded + \@tempa + \else + \exp_args:No + \AtEndOfPackage + { \@tempa } + \fi} +\ExplSyntaxOff \DeclareOption*{% \expandafter\markdownSetup\expandafter{\CurrentOption}}% \ProcessOptions\relax @@ -609,7 +675,6 @@ \ifx\empty#4\empty\else \caption{#4}% \fi - \label{fig:#1}% \end{figure}}, ulBegin = {\begin{itemize}}, ulEnd = {\end{itemize}}, @@ -623,6 +688,28 @@ emphasis = {\emph{#1}}, tickedBox = {$\boxtimes$}, halfTickedBox = {$\boxdot$}, + headerAttributeContextBegin = { + \markdownSetup{ + rendererPrototypes = { + attributeIdentifier = {% + \begingroup + \def\next####1{% + \def####1########1{% + \endgroup + ####1{########1}% + \label{##1}% + }% + }% + \next\markdownRendererHeadingOne + \next\markdownRendererHeadingTwo + \next\markdownRendererHeadingThree + \next\markdownRendererHeadingFour + \next\markdownRendererHeadingFive + \next\markdownRendererHeadingSix + }, + }, + }% + }, blockQuoteBegin = {\begin{quotation}}, blockQuoteEnd = {\end{quotation}}, inputVerbatim = {\VerbatimInput{#1}}, @@ -688,6 +775,28 @@ \fi \fi } +\@ifundefined{HCode}{}{ + \markdownSetup{ + rendererPrototypes = { + inlineHtmlTag = {% + \ifvmode + \IgnorePar + \EndP + \fi + \HCode{#1}% + }, + inputBlockHtmlElement = {% + \ifvmode + \IgnorePar + \fi + \EndP + \special{t4ht*<#1}% + \par + \ShowPar + }, + }, + } +} \newcount\markdownLaTeXCitationsCounter \RequirePackage{gobble} @@ -905,14 +1014,34 @@ \expandafter{\expandafter}% }}}} \RequirePackage{url} -\def\markdownRendererLinkPrototype{% +\RequirePackage{expl3} +\ExplSyntaxOn +\def\markdownRendererLinkPrototype{ \begingroup \catcode`\#=12 - \def\next##1##2##3##4{% - ##1\footnote{% - \ifx\empty##4\empty\else##4: \fi\texttt<\url{##3}\texttt>}% - \endgroup}% - \next} + \def\next##1##2##3##4{ + \endgroup + \tl_set:Nx + \l_tmpa_tl + { \str_range:nnn { ##3 } { 1 } { 1 } } + \str_if_eq:NNTF + \l_tmpa_tl + \c_hash_str + { + \exp_args:No + \markdownLaTeXRendererRelativeLink + { \str_range:nnn { ##3 } { 2 } { -1 } } + }{ + \markdownLaTeXRendererAbsoluteLink { ##1 } { ##2 } { ##3 } { ##4 } + } + } + \next +} +\ExplSyntaxOff +\def\markdownLaTeXRendererAbsoluteLink#1#2#3#4{% + #1\footnote{\ifx\empty#4\empty\else#4: \fi\texttt<\url{#3}\texttt>}} +\def\markdownLaTeXRendererRelativeLink#1{% + \ref{#1}} \newcount\markdownLaTeXRowCounter \newcount\markdownLaTeXRowTotal \newcount\markdownLaTeXColumnCounter @@ -920,14 +1049,16 @@ \newtoks\markdownLaTeXTable \newtoks\markdownLaTeXTableAlignment \newtoks\markdownLaTeXTableEnd -\@ifpackageloaded{booktabs}{ - \let\markdownLaTeXTopRule\toprule - \let\markdownLaTeXMidRule\midrule - \let\markdownLaTeXBottomRule\bottomrule -}{ - \let\markdownLaTeXTopRule\hline - \let\markdownLaTeXMidRule\hline - \let\markdownLaTeXBottomRule\hline +\AtBeginDocument{% + \@ifpackageloaded{booktabs}{% + \def\markdownLaTeXTopRule{\toprule}% + \def\markdownLaTeXMidRule{\midrule}% + \def\markdownLaTeXBottomRule{\bottomrule}% + }{% + \def\markdownLaTeXTopRule{\hline}% + \def\markdownLaTeXMidRule{\hline}% + \def\markdownLaTeXBottomRule{\hline}% + }% } \markdownSetup{rendererPrototypes={ table = {% @@ -990,7 +1121,6 @@ \expandafter\@gobble \fi\markdownLaTeXRenderTableCell} \fi -\RequirePackage{expl3} \ExplSyntaxOn \seq_new:N \g__markdown_jekyll_data_datatypes_seq \tl_const:Nn \c__markdown_jekyll_data_sequence_tl { sequence } |