summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/markdown/markdown.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/markdown/markdown.sty')
-rw-r--r--Master/texmf-dist/tex/latex/markdown/markdown.sty150
1 files changed, 132 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty
index 08dc59ef1e8..34f443fef1b 100644
--- a/Master/texmf-dist/tex/latex/markdown/markdown.sty
+++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty
@@ -59,18 +59,26 @@
\def\markdownOptionOutputTempFileName{#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}{citations}[true]{%
+ \def\markdownOptionCitations{#1}}%
+\define@key{markdownOptions}{citationNbsps}[true]{%
+ \def\markdownOptionCitationNbsps{#1}}%
\define@key{markdownOptions}{cacheDir}{%
\def\markdownOptionCacheDir{#1}}%
\define@key{markdownOptions}{definitionLists}[true]{%
\def\markdownOptionDefinitionLists{#1}}%
+\define@key{markdownOptions}{footnotes}[true]{%
+ \def\markdownOptionFootnotes{#1}}%
+\define@key{markdownOptions}{fencedCode}[true]{%
+ \def\markdownOptionFencedCode{#1}}%
\define@key{markdownOptions}{hashEnumerators}[true]{%
\def\markdownOptionHashEnumerators{#1}}%
\define@key{markdownOptions}{hybrid}[true]{%
\def\markdownOptionHybrid{#1}}%
-\define@key{markdownOptions}{footnotes}[true]{%
- \def\markdownOptionFootnotes{#1}}%
\define@key{markdownOptions}{preserveTabs}[true]{%
\def\markdownOptionPreserveTabs{#1}}%
\define@key{markdownOptions}{smartEllipses}[true]{%
@@ -79,12 +87,14 @@
\def\markdownOptionStartNumber{#1}}%
\define@key{markdownOptions}{tightLists}[true]{%
\def\markdownOptionTightLists{#1}}%
-\define@key{markdownOptions}{renderers}{%
- \setkeys{markdownRenderers}{#1}}%
+\define@key{markdownRenderers}{interblockSeparator}{%
+ \renewcommand\markdownRendererInterblockSeparator{#1}}%
\define@key{markdownRenderers}{lineBreak}{%
\renewcommand\markdownRendererLineBreak{#1}}%
\define@key{markdownRenderers}{ellipsis}{%
\renewcommand\markdownRendererEllipsis{#1}}%
+\define@key{markdownRenderers}{nbsp}{%
+ \renewcommand\markdownRendererNbsp{#1}}%
\define@key{markdownRenderers}{leftBrace}{%
\renewcommand\markdownRendererLeftBrace{#1}}%
\define@key{markdownRenderers}{rightBrace}{%
@@ -119,6 +129,8 @@
\renewcommand\markdownRendererUlBeginTight{#1}}%
\define@key{markdownRenderers}{ulItem}{%
\renewcommand\markdownRendererUlItem{#1}}%
+\define@key{markdownRenderers}{ulItemEnd}{%
+ \renewcommand\markdownRendererUlItemEnd{#1}}%
\define@key{markdownRenderers}{ulEnd}{%
\renewcommand\markdownRendererUlEnd{#1}}%
\define@key{markdownRenderers}{ulEndTight}{%
@@ -131,6 +143,8 @@
\renewcommand\markdownRendererOlItem{#1}}%
\define@key{markdownRenderers}{olItemWithNumber}{%
\renewcommand\markdownRendererOlItemWithNumber[1]{#1}}%
+\define@key{markdownRenderers}{olItemEnd}{%
+ \renewcommand\markdownRendererOlItemEnd{#1}}%
\define@key{markdownRenderers}{olEnd}{%
\renewcommand\markdownRendererOlEnd{#1}}%
\define@key{markdownRenderers}{olEndTight}{%
@@ -141,6 +155,8 @@
\renewcommand\markdownRendererDlBeginTight{#1}}%
\define@key{markdownRenderers}{dlItem}{%
\renewcommand\markdownRendererDlItem[1]{#1}}%
+\define@key{markdownRenderers}{dlItemEnd}{%
+ \renewcommand\markdownRendererDlItemEnd{#1}}%
\define@key{markdownRenderers}{dlDefinitionBegin}{%
\renewcommand\markdownRendererDlDefinitionBegin{#1}}%
\define@key{markdownRenderers}{dlDefinitionEnd}{%
@@ -159,6 +175,8 @@
\renewcommand\markdownRendererBlockQuoteEnd{#1}}%
\define@key{markdownRenderers}{inputVerbatim}{%
\renewcommand\markdownRendererInputVerbatim[1]{#1}}%
+\define@key{markdownRenderers}{inputFencedCode}{%
+ \renewcommand\markdownRendererInputFencedCode[2]{#1}}%
\define@key{markdownRenderers}{headingOne}{%
\renewcommand\markdownRendererHeadingOne[1]{#1}}%
\define@key{markdownRenderers}{headingTwo}{%
@@ -175,12 +193,18 @@
\renewcommand\markdownRendererHorizontalRule{#1}}%
\define@key{markdownRenderers}{footnote}{%
\renewcommand\markdownRendererFootnote[1]{#1}}%
-\define@key{markdownOptions}{rendererPrototypes}{%
- \setkeys{markdownRendererPrototypes}{#1}}%
+\define@key{markdownRenderers}{cite}{%
+ \renewcommand\markdownRendererCite[1]{#1}}%
+\define@key{markdownRenderers}{textCite}{%
+ \renewcommand\markdownRendererTextCite[1]{#1}}%
+\define@key{markdownRendererPrototypes}{interblockSeparator}{%
+ \renewcommand\markdownRendererInterblockSeparatorPrototype{#1}}%
\define@key{markdownRendererPrototypes}{lineBreak}{%
\renewcommand\markdownRendererLineBreakPrototype{#1}}%
\define@key{markdownRendererPrototypes}{ellipsis}{%
\renewcommand\markdownRendererEllipsisPrototype{#1}}%
+\define@key{markdownRendererPrototypes}{nbsp}{%
+ \renewcommand\markdownRendererNbspPrototype{#1}}%
\define@key{markdownRendererPrototypes}{leftBrace}{%
\renewcommand\markdownRendererLeftBracePrototype{#1}}%
\define@key{markdownRendererPrototypes}{rightBrace}{%
@@ -202,19 +226,21 @@
\define@key{markdownRendererPrototypes}{tilde}{%
\renewcommand\markdownRendererTildePrototype{#1}}%
\define@key{markdownRendererPrototypes}{pipe}{%
- \renewcommand\markdownRendererPipe{#1}}%
+ \renewcommand\markdownRendererPipePrototype{#1}}%
\define@key{markdownRendererPrototypes}{codeSpan}{%
\renewcommand\markdownRendererCodeSpanPrototype[1]{#1}}%
\define@key{markdownRendererPrototypes}{link}{%
- \renewcommand\markdownRendererLink[4]{#1}}%
+ \renewcommand\markdownRendererLinkPrototype[4]{#1}}%
\define@key{markdownRendererPrototypes}{image}{%
- \renewcommand\markdownRendererImage[4]{#1}}%
+ \renewcommand\markdownRendererImagePrototype[4]{#1}}%
\define@key{markdownRendererPrototypes}{ulBegin}{%
\renewcommand\markdownRendererUlBeginPrototype{#1}}%
\define@key{markdownRendererPrototypes}{ulBeginTight}{%
\renewcommand\markdownRendererUlBeginTightPrototype{#1}}%
\define@key{markdownRendererPrototypes}{ulItem}{%
\renewcommand\markdownRendererUlItemPrototype{#1}}%
+\define@key{markdownRendererPrototypes}{ulItemEnd}{%
+ \renewcommand\markdownRendererUlItemEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{ulEnd}{%
\renewcommand\markdownRendererUlEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{ulEndTight}{%
@@ -227,6 +253,8 @@
\renewcommand\markdownRendererOlItemPrototype{#1}}%
\define@key{markdownRendererPrototypes}{olItemWithNumber}{%
\renewcommand\markdownRendererOlItemWithNumberPrototype[1]{#1}}%
+\define@key{markdownRendererPrototypes}{olItemEnd}{%
+ \renewcommand\markdownRendererOlItemEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{olEnd}{%
\renewcommand\markdownRendererOlEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{olEndTight}{%
@@ -237,6 +265,8 @@
\renewcommand\markdownRendererDlBeginTightPrototype{#1}}%
\define@key{markdownRendererPrototypes}{dlItem}{%
\renewcommand\markdownRendererDlItemPrototype[1]{#1}}%
+\define@key{markdownRendererPrototypes}{dlItemEnd}{%
+ \renewcommand\markdownRendererDlItemEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{dlDefinitionBegin}{%
\renewcommand\markdownRendererDlDefinitionBeginPrototype{#1}}%
\define@key{markdownRendererPrototypes}{dlDefinitionEnd}{%
@@ -255,6 +285,8 @@
\renewcommand\markdownRendererBlockQuoteEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{inputVerbatim}{%
\renewcommand\markdownRendererInputVerbatimPrototype[1]{#1}}%
+\define@key{markdownRendererPrototypes}{inputFencedCode}{%
+ \renewcommand\markdownRendererInputFencedCodePrototype[2]{#1}}%
\define@key{markdownRendererPrototypes}{headingOne}{%
\renewcommand\markdownRendererHeadingOnePrototype[1]{#1}}%
\define@key{markdownRendererPrototypes}{headingTwo}{%
@@ -271,6 +303,10 @@
\renewcommand\markdownRendererHorizontalRulePrototype{#1}}%
\define@key{markdownRendererPrototypes}{footnote}{%
\renewcommand\markdownRendererFootnotePrototype[1]{#1}}%
+\define@key{markdownRendererPrototypes}{cite}{%
+ \renewcommand\markdownRendererCitePrototype[1]{#1}}%
+\define@key{markdownRendererPrototypes}{textCite}{%
+ \renewcommand\markdownRendererTextCitePrototype[1]{#1}}%
\input markdown
\def\markdownVersionSpace{ }%
\ProvidesPackage{markdown}[\markdownLastModified\markdownVersionSpace v%
@@ -299,6 +335,12 @@
\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@}}%
\RequirePackage{url}
\RequirePackage{graphicx}
\RequirePackage{ifthen}
@@ -357,31 +399,103 @@
blockQuoteBegin = {\begin{quotation}},
blockQuoteEnd = {\end{quotation}},
inputVerbatim = {\VerbatimInput{#1}},
+ inputFencedCode = {%
+ \ifx\relax#2\relax
+ \VerbatimInput{#1}%
+ \else
+ \ifx\minted@jobname\undefined
+ \ifx\lst@version\undefined
+ \markdownRendererInputFencedCode{#1}{}%
+ \else
+ \lstinputlisting[language=#2]{#1}%
+ \fi
+ \else
+ \inputminted{#2}{#1}%
+ \fi
+ \fi},
horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}},
- footnote = {\footnote{#1}}}}%
+ footnote = {\footnote{#1}}}}
\ifx\chapter\undefined
- \markdownSetup{rendererPrototypes={
+ \markdownSetup{rendererPrototypes = {
headingOne = {\section{#1}},
headingTwo = {\subsection{#1}},
headingThree = {\subsubsection{#1}},
headingFour = {\paragraph{#1}},
- headingFive = {\subparagraph{#1}}}}%
+ headingFive = {\subparagraph{#1}}}}
\else
- \markdownSetup{rendererPrototypes={
+ \markdownSetup{rendererPrototypes = {
headingOne = {\chapter{#1}},
headingTwo = {\section{#1}},
headingThree = {\subsection{#1}},
headingFour = {\subsubsection{#1}},
headingFive = {\paragraph{#1}},
- headingSix = {\subparagraph{#1}}}}%
+ headingSix = {\subparagraph{#1}}}}
\fi
+\newcount\markdownLaTeXCitationsCounter
+
+\def\markdownLaTeXBasicCitations#1#2#3#4{%
+ \advance\markdownLaTeXCitationsCounter by 1\relax
+ \ifx\relax#2\relax\else#2~\fi\cite[#3]{#4}%
+ \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax
+ \expandafter\@gobble
+ \fi\markdownLaTeXBasicCitations}
+\let\markdownLaTeXBasicTextCitations\markdownLaTeXBasicCitations
+
+\def\markdownLaTeXBibLaTeXCitations#1#2#3#4#5{%
+ \advance\markdownLaTeXCitationsCounter by 1\relax
+ \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax
+ \autocites#1[#3][#4]{#5}%
+ \expandafter\@gobbletwo
+ \fi\markdownLaTeXBibLaTeXCitations{#1[#3][#4]{#5}}}
+\def\markdownLaTeXBibLaTeXTextCitations#1#2#3#4#5{%
+ \advance\markdownLaTeXCitationsCounter by 1\relax
+ \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax
+ \textcites#1[#3][#4]{#5}%
+ \expandafter\@gobbletwo
+ \fi\markdownLaTeXBibLaTeXTextCitations{#1[#3][#4]{#5}}}
+
+\markdownSetup{rendererPrototypes = {
+ cite = {%
+ \markdownLaTeXCitationsCounter=1%
+ \def\markdownLaTeXCitationsTotal{#1}%
+ \ifx\autocites\undefined
+ \expandafter
+ \markdownLaTeXBasicCitations
+ \else
+ \expandafter\expandafter\expandafter
+ \markdownLaTeXBibLaTeXCitations
+ \expandafter{\expandafter}%
+ \fi},
+ textCite = {%
+ \markdownLaTeXCitationsCounter=1%
+ \def\markdownLaTeXCitationsTotal{#1}%
+ \ifx\textcites\undefined
+ \expandafter
+ \markdownLaTeXBasicTextCitations
+ \else
+ \expandafter\expandafter\expandafter
+ \markdownLaTeXBibLaTeXTextCitations
+ \expandafter{\expandafter}%
+ \fi}}}
+\let\markdownLuaRegisterIBCallbackPrevious
+ \markdownLuaRegisterIBCallback
+\let\markdownLuaUnregisterIBCallbackPrevious
+ \markdownLuaUnregisterIBCallback
\renewcommand\markdownLuaRegisterIBCallback[1]{%
- luatexbase.add_to_callback("process_input_buffer", #1, %
- "The markdown input processor")}
+ if luatexbase and luatexbase.add_to_callback then
+ luatexbase.add_to_callback("process_input_buffer", #1, %
+ "The markdown input processor")
+ else
+ \markdownLuaRegisterIBCallbackPrevious{#1}
+ end}
\renewcommand\markdownLuaUnregisterIBCallback{%
- luatexbase.remove_from_callback("process_input_buffer",%
- "The markdown input processor")}
+ if luatexbase and luatexbase.add_to_callback then
+ luatexbase.remove_from_callback("process_input_buffer",%
+ "The markdown input processor")
+ else
+ \markdownLuaUnregisterIBCallbackPrevious;
+ end}
\newcommand\markdownMakeOther{%
\count0=128\relax
\loop