summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/markdown
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-08-15 20:33:02 +0000
committerKarl Berry <karl@freefriends.org>2016-08-15 20:33:02 +0000
commit1850016c7aa713d8e5b7e6ac583199a938407287 (patch)
tree5d19cb8b694fbffc7b7606bfe1c1f98b764d5d08 /Master/texmf-dist/tex/generic/markdown
parentc412591dd67ff53334e28fc8f17cc9593a5d5f59 (diff)
markdown (16aug16)
git-svn-id: svn://tug.org/texlive/trunk@41855 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/markdown')
-rw-r--r--Master/texmf-dist/tex/generic/markdown/markdown.tex311
1 files changed, 195 insertions, 116 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex
index 1a90792aacf..247290d0b3b 100644
--- a/Master/texmf-dist/tex/generic/markdown/markdown.tex
+++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex
@@ -45,7 +45,8 @@
%%
%% The names of the source files used are shown above.
%%
-\def\markdownVersion{2016/06/03}%
+\def\markdownLastModified{2016/08/14}%
+\def\markdownVersion{1.0.2}%
\let\markdownBegin\relax
\let\markdownEnd\relax
\let\markdownInput\relax
@@ -56,7 +57,7 @@
\let\markdownOptionBlankBeforeBlockquote\undefined
\let\markdownOptionBlankBeforeHeading\undefined
\let\markdownOptionDefinitionLists\undefined
-\let\markdownOptionHashEnumerator\undefined
+\let\markdownOptionHashEnumerators\undefined
\let\markdownOptionHybrid\undefined
\let\markdownOptionFootnotes\undefined
\let\markdownOptionPreserveTabs\undefined
@@ -67,6 +68,28 @@
\markdownRendererLineBreakPrototype}%
\def\markdownRendererEllipsis{%
\markdownRendererEllipsisPrototype}%
+\def\markdownRendererLeftBrace{%
+ \markdownRendererLeftBracePrototype}%
+\def\markdownRendererRightBrace{%
+ \markdownRendererRightBracePrototype}%
+\def\markdownRendererDollarSign{%
+ \markdownRendererDollarSignPrototype}%
+\def\markdownRendererPercentSign{%
+ \markdownRendererPercentSignPrototype}%
+\def\markdownRendererAmpersand{%
+ \markdownRendererAmpersandPrototype}%
+\def\markdownRendererUnderscore{%
+ \markdownRendererUnderscorePrototype}%
+\def\markdownRendererHash{%
+ \markdownRendererHashPrototype}%
+\def\markdownRendererCircumflex{%
+ \markdownRendererCircumflexPrototype}%
+\def\markdownRendererBackslash{%
+ \markdownRendererBackslashPrototype}%
+\def\markdownRendererTilde{%
+ \markdownRendererTildePrototype}%
+\def\markdownRendererPipe{%
+ \markdownRendererPipePrototype}%
\def\markdownRendererCodeSpan{%
\markdownRendererCodeSpanPrototype}%
\def\markdownRendererLink{%
@@ -101,6 +124,10 @@
\markdownRendererDlBeginTightPrototype}%
\def\markdownRendererDlItem{%
\markdownRendererDlItemPrototype}%
+\def\markdownRendererDlDefinitionBegin{%
+ \markdownRendererDlDefinitionBeginPrototype}%
+\def\markdownRendererDlDefinitionEnd{%
+ \markdownRendererDlDefinitionEndPrototype}%
\def\markdownRendererDlEnd{%
\markdownRendererDlEndPrototype}%
\def\markdownRendererDlEndTight{%
@@ -133,9 +160,20 @@
\markdownRendererFootnotePrototype}%
\def\markdownRendererLineBreakPrototype{}%
\def\markdownRendererEllipsisPrototype{}%
+\def\markdownRendererLeftBracePrototype{}%
+\def\markdownRendererRightBracePrototype{}%
+\def\markdownRendererDollarSignPrototype{}%
+\def\markdownRendererPercentSignPrototype{}%
+\def\markdownRendererAmpersandPrototype{}%
+\def\markdownRendererUnderscorePrototype{}%
+\def\markdownRendererHashPrototype{}%
+\def\markdownRendererCircumflexPrototype{}%
+\def\markdownRendererBackslashPrototype{}%
+\def\markdownRendererTildePrototype{}%
+\def\markdownRendererPipePrototype{}%
\long\def\markdownRendererCodeSpanPrototype#1{}%
-\long\def\markdownRendererLinkPrototype#1#2#3{}%
-\long\def\markdownRendererImagePrototype#1#2#3{}%
+\long\def\markdownRendererLinkPrototype#1#2#3#4{}%
+\long\def\markdownRendererImagePrototype#1#2#3#4{}%
\def\markdownRendererUlBeginPrototype{}%
\def\markdownRendererUlBeginTightPrototype{}%
\def\markdownRendererUlItemPrototype{}%
@@ -150,6 +188,8 @@
\def\markdownRendererDlBeginPrototype{}%
\def\markdownRendererDlBeginTightPrototype{}%
\long\def\markdownRendererDlItemPrototype#1{}%
+\def\markdownRendererDlDefinitionBeginPrototype{}%
+\def\markdownRendererDlDefinitionEndPrototype{}%
\def\markdownRendererDlEndPrototype{}%
\def\markdownRendererDlEndTightPrototype{}%
\long\def\markdownRendererEmphasisPrototype#1{}%
@@ -181,6 +221,13 @@
|markdownReadAndConvert{\markdownEnd}%
{|markdownEnd}}%
|endgroup
+\ifx\markdownMode\undefined
+ \ifx\directlua\undefined
+ \def\markdownMode{0}%
+ \else
+ \def\markdownMode{2}%
+ \fi
+\fi
\def\markdownInfo#1{%
\message{(l.\the\inputlineno) markdown.tex info: #1.}}%
\def\markdownWarning#1{%
@@ -190,9 +237,20 @@
\errmessage{(l.\the\inputlineno) markdown.tex error: #1}}%
\def\markdownRendererLineBreakPrototype{\hfil\break}%
\let\markdownRendererEllipsisPrototype\dots
+\def\markdownRendererLeftBracePrototype{\char`{}%
+\def\markdownRendererRightBracePrototype{\char`}}%
+\def\markdownRendererDollarSignPrototype{\char`$}%
+\def\markdownRendererPercentSignPrototype{\char`\%}%
+\def\markdownRendererAmpersandPrototype{\char`&}%
+\def\markdownRendererUnderscorePrototype{\char`_}%
+\def\markdownRendererHashPrototype{\char`\#}%
+\def\markdownRendererCircumflexPrototype{\char`^}%
+\def\markdownRendererBackslashPrototype{\char`\\}%
+\def\markdownRendererTildePrototype{\char`~}%
+\def\markdownRendererPipePrototype{|}%
\long\def\markdownRendererCodeSpanPrototype#1{{\tt#1}}%
-\long\def\markdownRendererLinkPrototype#1#2#3{#1}%
-\long\def\markdownRendererImagePrototype#1#2#3{#1}%
+\long\def\markdownRendererLinkPrototype#1#2#3#4{#2}%
+\long\def\markdownRendererImagePrototype#1#2#3#4{#2}%
\def\markdownRendererUlBeginPrototype{}%
\def\markdownRendererUlBeginTightPrototype{}%
\def\markdownRendererUlItemPrototype{}%
@@ -207,6 +265,8 @@
\def\markdownRendererDlBeginPrototype{}%
\def\markdownRendererDlBeginTightPrototype{}%
\long\def\markdownRendererDlItemPrototype#1{#1}%
+\def\markdownRendererDlDefinitionBeginPrototype{}%
+\def\markdownRendererDlDefinitionEndPrototype{\par}%
\def\markdownRendererDlEndPrototype{}%
\def\markdownRendererDlEndTightPrototype{}%
\long\def\markdownRendererEmphasisPrototype#1{{\it#1}}%
@@ -214,7 +274,7 @@
\def\markdownRendererBlockQuoteBeginPrototype{\par\begingroup\it}%
\def\markdownRendererBlockQuoteEndPrototype{\endgroup\par}%
\long\def\markdownRendererInputVerbatimPrototype#1{%
- \par{\tt\input"#1"\relax}\par}%
+\par{\tt\input"#1"\relax}\par}%
\long\def\markdownRendererHeadingOnePrototype#1{#1}%
\long\def\markdownRendererHeadingTwoPrototype#1{#1}%
\long\def\markdownRendererHeadingThreePrototype#1{#1}%
@@ -224,126 +284,145 @@
\def\markdownRendererHorizontalRulePrototype{}%
\long\def\markdownRendererFootnotePrototype#1{#1}%
\def\markdownLuaOptions{{%
- \ifx\markdownOptionBlankBeforeBlockquote\undefined\else
- blankBeforeBlockquote = \markdownOptionBlankBeforeBlockquote,
- \fi
- \ifx\markdownOptionBlankBeforeHeading\undefined\else
- blankBeforeHeading = \markdownOptionBlankBeforeHeading,
- \fi
- \ifx\markdownOptionCacheDir\undefined\else
- cacheDir = "\markdownOptionCacheDir",
- \fi
- \ifx\markdownOptionDefinitionLists\undefined\else
- definitionLists = \markdownOptionDefinitionLists,
- \fi
- \ifx\markdownOptionHashEnumerators\undefined\else
- hashEnumerators = \markdownOptionHashEnumerators,
- \fi
- \ifx\markdownOptionHybrid\undefined\else
- hybrid = \markdownOptionHybrid,
- \fi
- \ifx\markdownOptionFootnotes\undefined\else
- footnotes = \markdownOptionFootnotes,
- \fi
- \ifx\markdownOptionPreserveTabs\undefined\else
- preserveTabs = \markdownOptionPreserveTabs,
- \fi
- \ifx\markdownOptionSmartEllipses\undefined\else
- smartEllipses = \markdownOptionSmartEllipses,
- \fi
- \ifx\markdownOptionStartNumber\undefined\else
- startNumber = \markdownOptionStartNumber,
- \fi
- \ifx\markdownOptionTightLists\undefined\else
- tightLists = \markdownOptionTightLists,
- \fi}
+\ifx\markdownOptionBlankBeforeBlockquote\undefined\else
+ blankBeforeBlockquote = \markdownOptionBlankBeforeBlockquote,
+\fi
+\ifx\markdownOptionBlankBeforeHeading\undefined\else
+ blankBeforeHeading = \markdownOptionBlankBeforeHeading,
+\fi
+\ifx\markdownOptionCacheDir\undefined\else
+ cacheDir = "\markdownOptionCacheDir",
+\fi
+\ifx\markdownOptionDefinitionLists\undefined\else
+ definitionLists = \markdownOptionDefinitionLists,
+\fi
+\ifx\markdownOptionHashEnumerators\undefined\else
+ hashEnumerators = \markdownOptionHashEnumerators,
+\fi
+\ifx\markdownOptionHybrid\undefined\else
+ hybrid = \markdownOptionHybrid,
+\fi
+\ifx\markdownOptionFootnotes\undefined\else
+ footnotes = \markdownOptionFootnotes,
+\fi
+\ifx\markdownOptionPreserveTabs\undefined\else
+ preserveTabs = \markdownOptionPreserveTabs,
+\fi
+\ifx\markdownOptionSmartEllipses\undefined\else
+ smartEllipses = \markdownOptionSmartEllipses,
+\fi
+\ifx\markdownOptionStartNumber\undefined\else
+ startNumber = \markdownOptionStartNumber,
+\fi
+\ifx\markdownOptionTightLists\undefined\else
+ tightLists = \markdownOptionTightLists,
+\fi}
}%
\def\markdownPrepare{%
- local lfs = require("lfs")
- local cacheDir = "\markdownOptionCacheDir"
- if lfs.isdir(cacheDir) == true then else
- assert(lfs.mkdir(cacheDir))
- end
- local md = require("markdown")
- local convert = md.new(\markdownLuaOptions)
+local lfs = require("lfs")
+local cacheDir = "\markdownOptionCacheDir"
+if lfs.isdir(cacheDir) == true then else
+ assert(lfs.mkdir(cacheDir))
+end
+local md = require("markdown")
+local convert = md.new(\markdownLuaOptions)
}%
-\ifx\directlua\undefined
- \csname newwrite\endcsname\markdownLuaExecuteFileStream
- \csname newcount\endcsname\markdownLuaExecuteShellEscape
+
+\ifnum\markdownMode<2\relax
+\ifnum\markdownMode=0\relax
+ \markdownInfo{Using mode 0: Shell escape via write18}%
+\else
+ \markdownInfo{Using mode 1: Shell escape via os.execute}%
+\fi
+\csname newwrite\endcsname\markdownLuaExecuteFileStream
+\ifnum\markdownMode=0\relax
\ifx\pdfshellescape\undefined
\ifx\shellescape\undefined
- \markdownLuaExecuteShellEscape=1%
+ \def\markdownExecuteShellEscape{1}%
\else
- \markdownLuaExecuteShellEscape=\shellescape
+ \let\markdownExecuteShellEscape\shellescape
\fi
\else
- \markdownLuaExecuteShellEscape=\pdfshellescape
+ \let\markdownExecuteShellEscape\pdfshellescape
\fi
- \def\markdownLuaExecute#1{%
- \ifnum\markdownLuaExecuteShellEscape=1%
- \immediate\openout\markdownLuaExecuteFileStream=%
- \markdownOptionHelperScriptFileName
- \markdownInfo{Writing a helper Lua script to the file
- "\markdownOptionHelperScriptFileName"}%
- \immediate\write\markdownLuaExecuteFileStream{%
- local kpse = require('kpse')
- kpse.set_program_name('luatex') #1}%
- \immediate\closeout\markdownLuaExecuteFileStream
- \markdownInfo{Executing a helper Lua script from the file
- "\markdownOptionHelperScriptFileName" and storing the result in the
- file "\markdownOptionOutputTempFileName"}%
- \immediate\write18{texlua "\markdownOptionHelperScriptFileName" >
- "\markdownOptionOutputTempFileName"}%
- \input\markdownOptionOutputTempFileName\relax
- \else
- \markdownError{I can not access the shell}{Either run the TeX
- compiler with the --shell-escape or the --enable-write18 flag,
- or set shell_escape=t in the texmf.cnf file}%
- \fi}%
- \begingroup
- \catcode`\^^I=12%
- \gdef\markdownReadAndConvertTab{^^I}%
- \endgroup
- \begingroup
- \catcode`\^^M=13%
- \catcode`\^^I=13%
- \catcode`|=0%
- \catcode`\\=12%
- |gdef|markdownReadAndConvert#1#2{%
- |begingroup%
- |immediate|openout|markdownLuaExecuteFileStream%
- |markdownOptionInputTempFileName%
- |markdownInfo{Buffering markdown input into the temporary %
- input file "|markdownOptionInputTempFileName" and scanning %
- for the closing token sequence "#1"}%
- |def|do##1{|catcode`##1=12}|dospecials%
- |catcode`| =12%
- |markdownMakeOther%
- |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{%
- |ifx|relax##3|relax%
- |immediate|write|markdownLuaExecuteFileStream{##1}%
- |else%
- |def^^M{%
- |markdownInfo{The ending token sequence was found}%
- |immediate|write|markdownLuaExecuteFileStream{}%
- |immediate|closeout|markdownLuaExecuteFileStream%
- |endgroup%
- |markdownInput|markdownOptionInputTempFileName%
- #2}%
- |fi%
- ^^M}%
- |catcode`|^^I=13%
- |def^^I{|markdownReadAndConvertTab}%
- |catcode`|^^M=13%
- |def^^M##1^^M{%
- |def^^M####1^^M{%
- |markdownReadAndConvertProcessLine####1#1#1|relax}%
- ^^M}%
+\else
+ \def\markdownExecuteShellEscape{%
+ \directlua{tex.sprint(status.shell_escape)}}%
+\fi
+\ifnum\markdownMode=0\relax
+ \def\markdownExecuteDirect#1{\immediate\write18{#1}}%
+\else
+ \def\markdownExecuteDirect#1{%
+ \directlua{os.execute("\luaescapestring{#1}")}}%
+\fi
+\def\markdownExecute#1{%
+ \ifnum\markdownExecuteShellEscape=1\relax
+ \markdownExecuteDirect{#1}%
+ \else
+ \markdownError{I can not access the shell}{Either run the TeX
+ compiler with the --shell-escape or the --enable-write18 flag,
+ or set shell_escape=t in the texmf.cnf file}%
+ \fi}%
+\def\markdownLuaExecute#1{%
+ \immediate\openout\markdownLuaExecuteFileStream=%
+ \markdownOptionHelperScriptFileName
+ \markdownInfo{Writing a helper Lua script to the file
+ "\markdownOptionHelperScriptFileName"}%
+ \immediate\write\markdownLuaExecuteFileStream{%
+ local kpse = require('kpse')
+ kpse.set_program_name('luatex') #1}%
+ \immediate\closeout\markdownLuaExecuteFileStream
+ \markdownInfo{Executing a helper Lua script from the file
+ "\markdownOptionHelperScriptFileName" and storing the result in the
+ file "\markdownOptionOutputTempFileName"}%
+ \markdownExecute{texlua "\markdownOptionHelperScriptFileName" >
+ "\markdownOptionOutputTempFileName"}%
+ \input\markdownOptionOutputTempFileName\relax}%
+\begingroup
+ \catcode`\^^I=12%
+ \gdef\markdownReadAndConvertTab{^^I}%
+\endgroup
+\begingroup
+ \catcode`\^^M=13%
+ \catcode`\^^I=13%
+ \catcode`|=0%
+ \catcode`\\=12%
+ |gdef|markdownReadAndConvert#1#2{%
+ |begingroup%
+ |immediate|openout|markdownLuaExecuteFileStream%
+ |markdownOptionInputTempFileName%
+ |markdownInfo{Buffering markdown input into the temporary %
+ input file "|markdownOptionInputTempFileName" and scanning %
+ for the closing token sequence "#1"}%
+ |def|do##1{|catcode`##1=12}|dospecials%
+ |catcode`| =12%
+ |markdownMakeOther%
+ |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{%
+ |ifx|relax##3|relax%
+ |immediate|write|markdownLuaExecuteFileStream{##1}%
+ |else%
+ |def^^M{%
+ |markdownInfo{The ending token sequence was found}%
+ |immediate|write|markdownLuaExecuteFileStream{}%
+ |immediate|closeout|markdownLuaExecuteFileStream%
+ |endgroup%
+ |markdownInput|markdownOptionInputTempFileName%
+ #2}%
+ |fi%
^^M}%
- |endgroup
+ |catcode`|^^I=13%
+ |def^^I{|markdownReadAndConvertTab}%
+ |catcode`|^^M=13%
+ |def^^M##1^^M{%
+ |def^^M####1^^M{%
+ |markdownReadAndConvertProcessLine####1#1#1|relax}%
+ ^^M}%
+ ^^M}%
+|endgroup
\else
- \def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}%
- \begingroup
+\markdownInfo{Using mode 2: Direct Lua access}%
+\def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}%
+\begingroup
\catcode`\_=12%
\catcode`\$=12%
\catcode`\^=12%