diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-11 23:15:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-11 23:15:05 +0000 |
commit | a0bab753834e0c87c19800c7748fccccee26b4be (patch) | |
tree | 24455a5f82eed5399e434c1ff8f7acefbef5e85e /Master/texmf-dist/tex/generic | |
parent | c636c196ee98440b64ff0252aec19b5d800b749f (diff) |
markdown (6jun16)
git-svn-id: svn://tug.org/texlive/trunk@41376 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r-- | Master/texmf-dist/tex/generic/markdown/markdown.tex | 392 |
1 files changed, 392 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex new file mode 100644 index 00000000000..1a90792aacf --- /dev/null +++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex @@ -0,0 +1,392 @@ +%% +%% This is file `markdown.tex', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% markdown.dtx (with options: `tex') +%% +%% Copyright (C) 2016 Vít Novotný +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3 +%% 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ý. +%% +%% Send bug reports, requests for additions and questions +%% either to the GitHub issue tracker at +%% +%% https://github.com/Witiko/markdown/issues +%% +%% or to the e-mail address <witiko@mail.muni.cz>. +%% +%% MODIFICATION ADVICE: +%% +%% If you want to customize this file, it is best to make a copy of +%% the source file(s) from which it was produced. Use a different +%% name for your copy(ies) and modify the copy(ies); this will ensure +%% that your modifications do not get overwritten when you install a +%% new release of the standard system. You should also ensure that +%% your modified source file does not generate any modified file with +%% the same name as a standard file. +%% +%% You will also need to produce your own, suitably named, .ins file to +%% control the generation of files from your source file; this file +%% should contain your own preambles for the files it generates, not +%% those in the standard .ins files. +%% +%% The names of the source files used are shown above. +%% +\def\markdownVersion{2016/06/03}% +\let\markdownBegin\relax +\let\markdownEnd\relax +\let\markdownInput\relax +\def\markdownOptionHelperScriptFileName{\jobname.markdown.lua}% +\def\markdownOptionInputTempFileName{\jobname.markdown.in}% +\def\markdownOptionOutputTempFileName{\jobname.markdown.out}% +\def\markdownOptionCacheDir{_markdown-\jobname}% +\let\markdownOptionBlankBeforeBlockquote\undefined +\let\markdownOptionBlankBeforeHeading\undefined +\let\markdownOptionDefinitionLists\undefined +\let\markdownOptionHashEnumerator\undefined +\let\markdownOptionHybrid\undefined +\let\markdownOptionFootnotes\undefined +\let\markdownOptionPreserveTabs\undefined +\let\markdownOptionSmartEllipses\undefined +\let\markdownOptionStartNumber\undefined +\let\markdownOptionTightLists\undefined +\def\markdownRendererLineBreak{% + \markdownRendererLineBreakPrototype}% +\def\markdownRendererEllipsis{% + \markdownRendererEllipsisPrototype}% +\def\markdownRendererCodeSpan{% + \markdownRendererCodeSpanPrototype}% +\def\markdownRendererLink{% + \markdownRendererLinkPrototype}% +\def\markdownRendererImage{% + \markdownRendererImagePrototype}% +\def\markdownRendererUlBegin{% + \markdownRendererUlBeginPrototype}% +\def\markdownRendererUlBeginTight{% + \markdownRendererUlBeginTightPrototype}% +\def\markdownRendererUlItem{% + \markdownRendererUlItemPrototype}% +\def\markdownRendererUlEnd{% + \markdownRendererUlEndPrototype}% +\def\markdownRendererUlEndTight{% + \markdownRendererUlEndTightPrototype}% +\def\markdownRendererOlBegin{% + \markdownRendererOlBeginPrototype}% +\def\markdownRendererOlBeginTight{% + \markdownRendererOlBeginTightPrototype}% +\def\markdownRendererOlItem{% + \markdownRendererOlItemPrototype}% +\def\markdownRendererOlItemWithNumber{% + \markdownRendererOlItemWithNumberPrototype}% +\def\markdownRendererOlEnd{% + \markdownRendererOlEndPrototype}% +\def\markdownRendererOlEndTight{% + \markdownRendererOlEndTightPrototype}% +\def\markdownRendererDlBegin{% + \markdownRendererDlBeginPrototype}% +\def\markdownRendererDlBeginTight{% + \markdownRendererDlBeginTightPrototype}% +\def\markdownRendererDlItem{% + \markdownRendererDlItemPrototype}% +\def\markdownRendererDlEnd{% + \markdownRendererDlEndPrototype}% +\def\markdownRendererDlEndTight{% + \markdownRendererDlEndTightPrototype}% +\def\markdownRendererEmphasis{% + \markdownRendererEmphasisPrototype}% +\def\markdownRendererStrongEmphasis{% + \markdownRendererStrongEmphasisPrototype}% +\def\markdownRendererBlockQuoteBegin{% + \markdownRendererBlockQuoteBeginPrototype}% +\def\markdownRendererBlockQuoteEnd{% + \markdownRendererBlockQuoteEndPrototype}% +\def\markdownRendererInputVerbatim{% + \markdownRendererInputVerbatimPrototype}% +\def\markdownRendererHeadingOne{% + \markdownRendererHeadingOnePrototype}% +\def\markdownRendererHeadingTwo{% + \markdownRendererHeadingTwoPrototype}% +\def\markdownRendererHeadingThree{% + \markdownRendererHeadingThreePrototype}% +\def\markdownRendererHeadingFour{% + \markdownRendererHeadingFourPrototype}% +\def\markdownRendererHeadingFive{% + \markdownRendererHeadingFivePrototype}% +\def\markdownRendererHeadingSix{% + \markdownRendererHeadingSixPrototype}% +\def\markdownRendererHorizontalRule{% + \markdownRendererHorizontalRulePrototype}% +\def\markdownRendererFootnote{% + \markdownRendererFootnotePrototype}% +\def\markdownRendererLineBreakPrototype{}% +\def\markdownRendererEllipsisPrototype{}% +\long\def\markdownRendererCodeSpanPrototype#1{}% +\long\def\markdownRendererLinkPrototype#1#2#3{}% +\long\def\markdownRendererImagePrototype#1#2#3{}% +\def\markdownRendererUlBeginPrototype{}% +\def\markdownRendererUlBeginTightPrototype{}% +\def\markdownRendererUlItemPrototype{}% +\def\markdownRendererUlEndPrototype{}% +\def\markdownRendererUlEndTightPrototype{}% +\def\markdownRendererOlBeginPrototype{}% +\def\markdownRendererOlBeginTightPrototype{}% +\def\markdownRendererOlItemPrototype{}% +\long\def\markdownRendererOlItemWithNumberPrototype#1{}% +\def\markdownRendererOlEndPrototype{}% +\def\markdownRendererOlEndTightPrototype{}% +\def\markdownRendererDlBeginPrototype{}% +\def\markdownRendererDlBeginTightPrototype{}% +\long\def\markdownRendererDlItemPrototype#1{}% +\def\markdownRendererDlEndPrototype{}% +\def\markdownRendererDlEndTightPrototype{}% +\long\def\markdownRendererEmphasisPrototype#1{}% +\long\def\markdownRendererStrongEmphasisPrototype#1{}% +\def\markdownRendererBlockQuoteBeginPrototype{}% +\def\markdownRendererBlockQuoteEndPrototype{}% +\long\def\markdownRendererInputVerbatimPrototype#1{}% +\long\def\markdownRendererHeadingOnePrototype#1{}% +\long\def\markdownRendererHeadingTwoPrototype#1{}% +\long\def\markdownRendererHeadingThreePrototype#1{}% +\long\def\markdownRendererHeadingFourPrototype#1{}% +\long\def\markdownRendererHeadingFivePrototype#1{}% +\long\def\markdownRendererHeadingSixPrototype#1{}% +\def\markdownRendererHorizontalRulePrototype{}% +\long\def\markdownRendererFootnotePrototype#1{}% +\def\markdownInfo#1{}% +\def\markdownWarning#1{}% +\def\markdownError#1{}% +\def\markdownLuaRegisterIBCallback#1{% + local old_callback = callback.find("process_input_buffer") + callback.register("process_input_buffer", #1)}% +\def\markdownLuaUnregisterIBCallback{% + callback.register("process_input_buffer", old_callback)}% +\let\markdownMakeOther\relax +\let\markdownReadAndConvert\relax +\begingroup + \catcode`\|=0\catcode`\\=12% + |gdef|markdownBegin{% + |markdownReadAndConvert{\markdownEnd}% + {|markdownEnd}}% +|endgroup +\def\markdownInfo#1{% + \message{(l.\the\inputlineno) markdown.tex info: #1.}}% +\def\markdownWarning#1{% + \message{(l.\the\inputlineno) markdown.tex warning: #1}}% +\def\markdownError#1#2{% + \errhelp{#2.}% + \errmessage{(l.\the\inputlineno) markdown.tex error: #1}}% +\def\markdownRendererLineBreakPrototype{\hfil\break}% +\let\markdownRendererEllipsisPrototype\dots +\long\def\markdownRendererCodeSpanPrototype#1{{\tt#1}}% +\long\def\markdownRendererLinkPrototype#1#2#3{#1}% +\long\def\markdownRendererImagePrototype#1#2#3{#1}% +\def\markdownRendererUlBeginPrototype{}% +\def\markdownRendererUlBeginTightPrototype{}% +\def\markdownRendererUlItemPrototype{}% +\def\markdownRendererUlEndPrototype{}% +\def\markdownRendererUlEndTightPrototype{}% +\def\markdownRendererOlBeginPrototype{}% +\def\markdownRendererOlBeginTightPrototype{}% +\def\markdownRendererOlItemPrototype{}% +\long\def\markdownRendererOlItemWithNumberPrototype#1{}% +\def\markdownRendererOlEndPrototype{}% +\def\markdownRendererOlEndTightPrototype{}% +\def\markdownRendererDlBeginPrototype{}% +\def\markdownRendererDlBeginTightPrototype{}% +\long\def\markdownRendererDlItemPrototype#1{#1}% +\def\markdownRendererDlEndPrototype{}% +\def\markdownRendererDlEndTightPrototype{}% +\long\def\markdownRendererEmphasisPrototype#1{{\it#1}}% +\long\def\markdownRendererStrongEmphasisPrototype#1{{\it#1}}% +\def\markdownRendererBlockQuoteBeginPrototype{\par\begingroup\it}% +\def\markdownRendererBlockQuoteEndPrototype{\endgroup\par}% +\long\def\markdownRendererInputVerbatimPrototype#1{% + \par{\tt\input"#1"\relax}\par}% +\long\def\markdownRendererHeadingOnePrototype#1{#1}% +\long\def\markdownRendererHeadingTwoPrototype#1{#1}% +\long\def\markdownRendererHeadingThreePrototype#1{#1}% +\long\def\markdownRendererHeadingFourPrototype#1{#1}% +\long\def\markdownRendererHeadingFivePrototype#1{#1}% +\long\def\markdownRendererHeadingSixPrototype#1{#1}% +\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} +}% +\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) +}% +\ifx\directlua\undefined + \csname newwrite\endcsname\markdownLuaExecuteFileStream + \csname newcount\endcsname\markdownLuaExecuteShellEscape + \ifx\pdfshellescape\undefined + \ifx\shellescape\undefined + \markdownLuaExecuteShellEscape=1% + \else + \markdownLuaExecuteShellEscape=\shellescape + \fi + \else + \markdownLuaExecuteShellEscape=\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}% + ^^M}% + |endgroup +\else + \def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}% + \begingroup + \catcode`\_=12% + \catcode`\$=12% + \catcode`\^=12% + \catcode`\/=6% + \catcode`\#=12% + \catcode`\@=14% + \catcode`\%=12% + \catcode`|=0@ + \catcode`\\=12@ + |gdef|markdownReadAndConvert/1/2{@ + |def|markdownReadAndConvertAfter{/2}@ + |markdownInfo{Buffering markdown input and scanning for the + closing token sequence "/1"}@ + |directlua{@ + |markdownPrepare + local buffer = {} + local ending_sequence = "^.-" .. ([[/1]]):gsub( + "([%(%)%.%%%+%-%*%?%[%]%^%$])", "%%%1") + |markdownLuaRegisterIBCallback{function(line) + if line:match(ending_sequence) then + |markdownLuaUnregisterIBCallback + local input = table.concat(buffer, "\n") .. "\n\n" + local output = convert(input) + return [[\markdownInfo{The ending token sequence was found}]] .. + output .. [[\markdownReadAndConvertAfter]] + else + buffer[#buffer+1] = line + return [[\]] .. (#buffer == 1 and "fi" or "relax") + end + end}}@ + |iffalse}@ + |endgroup +\fi +\begingroup + \catcode`|=0% + \catcode`\\=12% + |gdef|markdownInput#1{% + |markdownInfo{Including markdown document "#1"}% + |markdownLuaExecute{% + |markdownPrepare + local input = assert(io.open("#1","r")):read("*a") .. "\n\n" + print(convert(input:gsub("\r\n?", "\n")))}}% +|endgroup +\endinput +%% +%% End of file `markdown.tex'. |