diff options
author | Karl Berry <karl@freefriends.org> | 2016-08-15 20:33:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-08-15 20:33:02 +0000 |
commit | 1850016c7aa713d8e5b7e6ac583199a938407287 (patch) | |
tree | 5d19cb8b694fbffc7b7606bfe1c1f98b764d5d08 /Master/texmf-dist/tex | |
parent | c412591dd67ff53334e28fc8f17cc9593a5d5f59 (diff) |
markdown (16aug16)
git-svn-id: svn://tug.org/texlive/trunk@41855 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
4 files changed, 329 insertions, 163 deletions
diff --git a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex index 115836433e6..bad0124577b 100644 --- a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex +++ b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex @@ -61,16 +61,16 @@ callback.register("process_input_buffer", function() end) local new_callback = callback.find("process_input_buffer") if new_callback == false then - tex.print(unescape([[|let|markdownDirectLua|directlua - |let|directlua|undefined - |input markdown - |let|directlua|markdownDirectLua - |let|markdownDirectLua|undefined]])) + tex.print(unescape([[|def|markdownMode{1}|input markdown]])) else callback.register("process_input_buffer", old_callback) tex.print(unescape("|input markdown")) end}% \fi +\ifnum\markdownMode<2 + \def\markdownMakeOther{% + \catcode`|=12}% +\fi \def\markdownInfo#1{\writestatus{markdown}{#1.}}% \def\markdownWarning#1{\writestatus{markdown\space warn}{#1.}}% \begingroup @@ -81,11 +81,20 @@ {|stopmarkdown}}% |endgroup \def\markdownRendererLineBreakPrototype{\blank}% -\long\def\markdownRendererLinkPrototype#1#2#3{% - \useURL[#1][#2][][#3]#1\footnote[#1]{\ifx\empty#3\empty\else#3: - \fi\tt<\hyphenatedurl{#2}>}}% -\long\def\markdownRendererImagePrototype#1#2#3{% - \placefigure[][fig:#1]{#3}{\externalfigure[#2]}}% +\def\markdownRendererLeftBracePrototype{\textbraceleft}% +\def\markdownRendererRightBracePrototype{\textbraceright}% +\def\markdownRendererDollarSignPrototype{\textdollar}% +\def\markdownRendererPercentSignPrototype{\percent}% +\def\markdownRendererUnderscorePrototype{\textunderscore}% +\def\markdownRendererCircumflexPrototype{\textcircumflex}% +\def\markdownRendererBackslashPrototype{\textbackslash}% +\def\markdownRendererTildePrototype{\textasciitilde}% +\def\markdownRendererPipePrototype{\char`|}% +\long\def\markdownRendererLinkPrototype#1#2#3#4{% + \useURL[#1][#3][][#4]#1\footnote[#1]{\ifx\empty#4\empty\else#4: + \fi\tt<\hyphenatedurl{#3}>}}% +\long\def\markdownRendererImagePrototype#1#2#3#4{% + \placefigure[][fig:#1]{#4}{\externalfigure[#3]}}% \def\markdownRendererUlBeginPrototype{\startitemize}% \def\markdownRendererUlBeginTightPrototype{\startitemize[packed]}% \def\markdownRendererUlItemPrototype{\item}% @@ -114,7 +123,7 @@ \startMarkdownConTeXtDlPrototype}% \def\markdownRendererDlBeginTightPrototype{% \startMarkdownConTeXtDlTightPrototype}% -\long\long\def\markdownRendererDlItemPrototype#1{% +\long\def\markdownRendererDlItemPrototype#1{% \markdownConTeXtDlItemPrototype{#1}}% \def\markdownRendererDlEndPrototype{% \stopMarkdownConTeXtDlPrototype}% 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% diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index c568c8212b5..08dc59ef1e8 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -85,12 +85,34 @@ \renewcommand\markdownRendererLineBreak{#1}}% \define@key{markdownRenderers}{ellipsis}{% \renewcommand\markdownRendererEllipsis{#1}}% +\define@key{markdownRenderers}{leftBrace}{% + \renewcommand\markdownRendererLeftBrace{#1}}% +\define@key{markdownRenderers}{rightBrace}{% + \renewcommand\markdownRendererRightBrace{#1}}% +\define@key{markdownRenderers}{dollarSign}{% + \renewcommand\markdownRendererDollarSign{#1}}% +\define@key{markdownRenderers}{percentSign}{% + \renewcommand\markdownRendererPercentSign{#1}}% +\define@key{markdownRenderers}{ampersand}{% + \renewcommand\markdownRendererAmpersand{#1}}% +\define@key{markdownRenderers}{underscore}{% + \renewcommand\markdownRendererUnderscore{#1}}% +\define@key{markdownRenderers}{hash}{% + \renewcommand\markdownRendererHash{#1}}% +\define@key{markdownRenderers}{circumflex}{% + \renewcommand\markdownRendererCircumflex{#1}}% +\define@key{markdownRenderers}{backslash}{% + \renewcommand\markdownRendererBackslash{#1}}% +\define@key{markdownRenderers}{tilde}{% + \renewcommand\markdownRendererTilde{#1}}% +\define@key{markdownRenderers}{pipe}{% + \renewcommand\markdownRendererPipe{#1}}% \define@key{markdownRenderers}{codeSpan}{% \renewcommand\markdownRendererCodeSpan[1]{#1}}% \define@key{markdownRenderers}{link}{% - \renewcommand\markdownRendererLink[3]{#1}}% + \renewcommand\markdownRendererLink[4]{#1}}% \define@key{markdownRenderers}{image}{% - \renewcommand\markdownRendererImage[3]{#1}}% + \renewcommand\markdownRendererImage[4]{#1}}% \define@key{markdownRenderers}{ulBegin}{% \renewcommand\markdownRendererUlBegin{#1}}% \define@key{markdownRenderers}{ulBeginTight}{% @@ -119,6 +141,10 @@ \renewcommand\markdownRendererDlBeginTight{#1}}% \define@key{markdownRenderers}{dlItem}{% \renewcommand\markdownRendererDlItem[1]{#1}}% +\define@key{markdownRenderers}{dlDefinitionBegin}{% + \renewcommand\markdownRendererDlDefinitionBegin{#1}}% +\define@key{markdownRenderers}{dlDefinitionEnd}{% + \renewcommand\markdownRendererDlDefinitionEnd{#1}}% \define@key{markdownRenderers}{dlEnd}{% \renewcommand\markdownRendererDlEnd{#1}}% \define@key{markdownRenderers}{dlEndTight}{% @@ -155,12 +181,34 @@ \renewcommand\markdownRendererLineBreakPrototype{#1}}% \define@key{markdownRendererPrototypes}{ellipsis}{% \renewcommand\markdownRendererEllipsisPrototype{#1}}% +\define@key{markdownRendererPrototypes}{leftBrace}{% + \renewcommand\markdownRendererLeftBracePrototype{#1}}% +\define@key{markdownRendererPrototypes}{rightBrace}{% + \renewcommand\markdownRendererRightBracePrototype{#1}}% +\define@key{markdownRendererPrototypes}{dollarSign}{% + \renewcommand\markdownRendererDollarSignPrototype{#1}}% +\define@key{markdownRendererPrototypes}{percentSign}{% + \renewcommand\markdownRendererPercentSignPrototype{#1}}% +\define@key{markdownRendererPrototypes}{ampersand}{% + \renewcommand\markdownRendererAmpersandPrototype{#1}}% +\define@key{markdownRendererPrototypes}{underscore}{% + \renewcommand\markdownRendererUnderscorePrototype{#1}}% +\define@key{markdownRendererPrototypes}{hash}{% + \renewcommand\markdownRendererHashPrototype{#1}}% +\define@key{markdownRendererPrototypes}{circumflex}{% + \renewcommand\markdownRendererCircumflexPrototype{#1}}% +\define@key{markdownRendererPrototypes}{backslash}{% + \renewcommand\markdownRendererBackslashPrototype{#1}}% +\define@key{markdownRendererPrototypes}{tilde}{% + \renewcommand\markdownRendererTildePrototype{#1}}% +\define@key{markdownRendererPrototypes}{pipe}{% + \renewcommand\markdownRendererPipe{#1}}% \define@key{markdownRendererPrototypes}{codeSpan}{% \renewcommand\markdownRendererCodeSpanPrototype[1]{#1}}% \define@key{markdownRendererPrototypes}{link}{% - \renewcommand\markdownRendererLink[3]{#1}}% + \renewcommand\markdownRendererLink[4]{#1}}% \define@key{markdownRendererPrototypes}{image}{% - \renewcommand\markdownRendererImage[3]{#1}}% + \renewcommand\markdownRendererImage[4]{#1}}% \define@key{markdownRendererPrototypes}{ulBegin}{% \renewcommand\markdownRendererUlBeginPrototype{#1}}% \define@key{markdownRendererPrototypes}{ulBeginTight}{% @@ -189,6 +237,10 @@ \renewcommand\markdownRendererDlBeginTightPrototype{#1}}% \define@key{markdownRendererPrototypes}{dlItem}{% \renewcommand\markdownRendererDlItemPrototype[1]{#1}}% +\define@key{markdownRendererPrototypes}{dlDefinitionBegin}{% + \renewcommand\markdownRendererDlDefinitionBeginPrototype{#1}}% +\define@key{markdownRendererPrototypes}{dlDefinitionEnd}{% + \renewcommand\markdownRendererDlDefinitionEndPrototype{#1}}% \define@key{markdownRendererPrototypes}{dlEnd}{% \renewcommand\markdownRendererDlEndPrototype{#1}}% \define@key{markdownRendererPrototypes}{dlEndTight}{% @@ -220,7 +272,9 @@ \define@key{markdownRendererPrototypes}{footnote}{% \renewcommand\markdownRendererFootnotePrototype[1]{#1}}% \input markdown -\ProvidesPackage{markdown}[\markdownVersion]% +\def\markdownVersionSpace{ }% +\ProvidesPackage{markdown}[\markdownLastModified\markdownVersionSpace v% + \markdownVersion\markdownVersionSpace markdown renderer]% \renewcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}% \renewcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}% \renewcommand\markdownError[2]{\PackageError{markdown}{#1}{#2.}}% @@ -257,15 +311,23 @@ \RequirePackage{fancyvrb} \markdownSetup{rendererPrototypes={ lineBreak = {\\}, + leftBrace = {\textbraceleft}, + rightBrace = {\textbraceright}, + dollarSign = {\textdollar}, + underscore = {\textunderscore}, + circumflex = {\textasciicircum}, + backslash = {\textbackslash}, + tilde = {\textasciitilde}, + pipe = {\textbar}, codeSpan = {\texttt{#1}}, - link = {#1\footnote{\ifx\empty#3\empty\else#3: - \fi\texttt<\url{#2}\texttt>}}, + link = {#1\footnote{\ifx\empty#4\empty\else#4: + \fi\texttt<\url{#3}\texttt>}}, image = {\begin{figure} \begin{center}% - \includegraphics{#2}% + \includegraphics{#3}% \end{center}% - \ifx\empty#3\empty\else - \caption{#3}% + \ifx\empty#4\empty\else + \caption{#4}% \fi \label{fig:#1}% \end{figure}}, @@ -290,7 +352,7 @@ \ifx\alert\undefined \textbf{\emph{#1}}% \else % Beamer support - \alert{\emph{#1}} + \alert{\emph{#1}}% \fi}, blockQuoteBegin = {\begin{quotation}}, blockQuoteEnd = {\end{quotation}}, diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index e740d18c92e..8a0f237c1d7 100644 --- a/Master/texmf-dist/tex/luatex/markdown/markdown.lua +++ b/Master/texmf-dist/tex/luatex/markdown/markdown.lua @@ -58,7 +58,7 @@ -- those in the standard .ins files. -- if not modules then modules = { } end modules ['markdown'] = { - version = "1.0.1", + version = "1.0.2", comment = "A module for the conversion from markdown to plain TeX", author = "John MacFarlane, Hans Hagen, Vít Novotný", copyright = "2009-2016 John MacFarlane, Hans Hagen; 2016 Vít Novotný", @@ -68,7 +68,6 @@ local lpeg = require("lpeg") local unicode = require("unicode") local md5 = require("md5") local M = {} -M.new = {} local defaultOptions = {} defaultOptions.blankBeforeBlockquote = false defaultOptions.blankBeforeHeading = false @@ -238,23 +237,34 @@ function M.writer.new(options) self.linebreak = "\\markdownRendererLineBreak " self.ellipsis = "\\markdownRendererEllipsis{}" self.hrule = "\\markdownRendererHorizontalRule " - local escaped = { - ["{"] = "\\{", - ["}"] = "\\}", - ["$"] = "\\$", - ["%"] = "\\%", - ["&"] = "\\&", - ["_"] = "\\_", - ["#"] = "\\#", - ["^"] = "\\^{}", - ["\\"] = "\\char92{}", - ["~"] = "\\char126{}", - ["|"] = "\\char124{}", } - local escape = util.escaper(escaped) + local escaped_chars = { + ["{"] = "\\markdownRendererLeftBrace{}", + ["}"] = "\\markdownRendererRightBrace{}", + ["$"] = "\\markdownRendererDollarSign{}", + ["%"] = "\\markdownRendererPercentSign{}", + ["&"] = "\\markdownRendererAmpersand{}", + ["_"] = "\\markdownRendererUnderscore{}", + ["#"] = "\\markdownRendererHash{}", + ["^"] = "\\markdownRendererCircumflex{}", + ["\\"] = "\\markdownRendererBackslash{}", + ["~"] = "\\markdownRendererTilde{}", + ["|"] = "\\markdownRendererPipe{}", } + local escaped_minimal_chars = { + ["{"] = "\\markdownRendererLeftBrace{}", + ["}"] = "\\markdownRendererRightBrace{}", + ["%"] = "\\markdownRendererPercentSign{}", + ["\\"] = "\\markdownRendererBackslash{}", } + local escaped_minimal_strings = { + ["^^"] = "\\markdownRendererCircumflex\\markdownRendererCircumflex ", } + local escape = util.escaper(escaped_chars) + local escape_minimal = util.escaper(escaped_minimal_chars, + escaped_minimal_strings) if options.hybrid then self.string = function(s) return s end + self.uri = function(u) return u end else self.string = escape + self.uri = escape_minimal end function self.code(s) return {"\\markdownRendererCodeSpan{",escape(s),"}"} @@ -262,12 +272,14 @@ function M.writer.new(options) function self.link(lab,src,tit) return {"\\markdownRendererLink{",lab,"}", "{",self.string(src),"}", - "{",self.string(tit),"}"} + "{",self.uri(src),"}", + "{",self.string(tit or ""),"}"} end function self.image(lab,src,tit) return {"\\markdownRendererImage{",lab,"}", "{",self.string(src),"}", - "{",self.string(tit),"}"} + "{",self.uri(src),"}", + "{",self.string(tit or ""),"}"} end local function ulitem(s) return {"\\markdownRendererUlItem ",s} @@ -313,15 +325,19 @@ function M.writer.new(options) "\n\\markdownRendererOlEnd "} end end - local function dlitem(term,defs) - return {"\\markdownRendererDlItem{",term,"}\n",defs} + local function dlitem(term, defs) + local retVal = {"\\markdownRendererDlItem{",term,"}"} + for _, def in ipairs(defs) do + retVal[#retVal+1] = {"\\markdownRendererDlDefinitionBegin ",def, + "\\markdownRendererDlDefinitionEnd "} + end + return retVal end function self.definitionlist(items,tight) local buffer = {} for _,item in ipairs(items) do - buffer[#buffer + 1] = dlitem(item.term, - util.intersperse(item.definitions, self.interblocksep)) + buffer[#buffer + 1] = dlitem(item.term, item.definitions) end local contents = util.intersperse(buffer, self.containersep) if tight and options.tightLists then @@ -467,7 +483,7 @@ function M.reader.new(writer, options) local fail = any - 1 local always = P("") - local escapable = S("\\`*_{}[]()+_.!#-~:^") + local escapable = S("\\`*_{}[]()+_.!<>#-~:^") local anyescaped = P("\\") / "" * escapable + any @@ -480,9 +496,9 @@ function M.reader.new(writer, options) local specialchar if options.smartEllipses then - specialchar = S("*_`&[]!\\.") + specialchar = S("*_`&[]<!\\.") else - specialchar = S("*_`&[]!\\") + specialchar = S("*_`&[]<!\\") end local normalchar = any - @@ -613,7 +629,7 @@ function M.reader.new(writer, options) if found then return writer.note(parse_blocks(found)) else - return {"[^", ref, "]"} + return {"[", parse_inlines("^" .. ref), "]"} end end end |