From 78cc5f15a2679016b4fc8dc5948a5575276c7637 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 12 Sep 2017 22:15:30 +0000 Subject: markdown (12sep17) git-svn-id: svn://tug.org/texlive/trunk@45278 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/generic/markdown/markdown.tex | 78 ++++++++++++++-------- Master/texmf-dist/tex/latex/markdown/markdown.sty | 20 +++--- Master/texmf-dist/tex/luatex/markdown/markdown.lua | 5 +- 3 files changed, 67 insertions(+), 36 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex index 9900f543122..1e5d4618516 100644 --- a/Master/texmf-dist/tex/generic/markdown/markdown.tex +++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex @@ -45,15 +45,17 @@ %% %% The names of the source files used are shown above. %% -\def\markdownLastModified{2017/05/07}% -\def\markdownVersion{2.5.3}% +\def\markdownLastModified{2017/09/12}% +\def\markdownVersion{2.5.4}% \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}% +\def\markdownOptionErrorTempFileName{\jobname.markdown.err}% +\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}% +\def\markdownOptionOutputDir{.}% \let\markdownOptionBlankBeforeBlockquote\undefined \let\markdownOptionBlankBeforeCodeFence\undefined \let\markdownOptionBlankBeforeHeading\undefined @@ -268,9 +270,9 @@ \def\markdownLuaRegisterIBCallback#1{\relax}% \def\markdownLuaUnregisterIBCallback#1{\relax}% \def\markdownInfo#1{% - \message{(l.\the\inputlineno) markdown.tex info: #1.}}% + \immediate\write-1{(l.\the\inputlineno) markdown.tex info: #1.}}% \def\markdownWarning#1{% - \message{(l.\the\inputlineno) markdown.tex warning: #1}}% + \immediate\write16{(l.\the\inputlineno) markdown.tex warning: #1}}% \def\markdownError#1#2{% \errhelp{#2.}% \errmessage{(l.\the\inputlineno) markdown.tex error: #1}}% @@ -350,9 +352,7 @@ \ifx\markdownOptionBreakableBlockquotes\undefined\else breakableBlockquotes = \markdownOptionBreakableBlockquotes, \fi -\ifx\markdownOptionCacheDir\undefined\else cacheDir = "\markdownOptionCacheDir", -\fi \ifx\markdownOptionCitations\undefined\else citations = \markdownOptionCitations, \fi @@ -390,6 +390,7 @@ \ifx\markdownOptionInlineFootnotes\undefined\else inlineFootnotes = \markdownOptionInlineFootnotes, \fi + outputDir = "\markdownOptionOutputDir", \ifx\markdownOptionPreserveTabs\undefined\else preserveTabs = \markdownOptionPreserveTabs, \fi @@ -415,7 +416,8 @@ end local md = require("markdown") local convert = md.new(\markdownLuaOptions) }% -\csname newwrite\endcsname\markdownLuaExecuteFileStream +\csname newread\endcsname\markdownInputFileStream +\csname newwrite\endcsname\markdownOutputFileStream \begingroup \catcode`\^^I=12% \gdef\markdownReadAndConvertTab{^^I}% @@ -427,7 +429,7 @@ local convert = md.new(\markdownLuaOptions) \catcode`\\=12% |gdef|markdownReadAndConvert#1#2{% |begingroup% - |immediate|openout|markdownLuaExecuteFileStream% + |immediate|openout|markdownOutputFileStream% |markdownOptionInputTempFileName% |markdownInfo{Buffering markdown input into the temporary % input file "|markdownOptionInputTempFileName" and scanning % @@ -437,11 +439,11 @@ local convert = md.new(\markdownLuaOptions) |markdownMakeOther% |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{% |ifx|relax##3|relax% - |immediate|write|markdownLuaExecuteFileStream{##1}% + |immediate|write|markdownOutputFileStream{##1}% |else% |def^^M{% |markdownInfo{The ending token sequence was found}% - |immediate|closeout|markdownLuaExecuteFileStream% + |immediate|closeout|markdownOutputFileStream% |endgroup% |markdownInput|markdownOptionInputTempFileName% #2}% @@ -490,21 +492,43 @@ local convert = md.new(\markdownLuaOptions) 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`|=0% + \catcode`\\=12% + |gdef|markdownLuaExecute#1{% + |immediate|openout|markdownOutputFileStream=% + |markdownOptionHelperScriptFileName + |markdownInfo{Writing a helper Lua script to the file + "|markdownOptionHelperScriptFileName"}% + |immediate|write|markdownOutputFileStream{% + local ran_ok, error = pcall(function() + local kpse = require('kpse') + kpse.set_program_name('luatex') + #1 + end) + if not ran_ok then + local file = io.open("% + |markdownOptionOutputDir + /|markdownOptionErrorTempFileName", "w") + if file then + file:write(error .. "\n") + file:close() + end + print('\\markdownError{An error was encountered while executing + Lua code}{For further clues, examine the file + "|markdownOptionOutputDir + /|markdownOptionErrorTempFileName"}') + end}% + |immediate|closeout|markdownOutputFileStream + |markdownInfo{Executing a helper Lua script from the file + "|markdownOptionHelperScriptFileName" and storing the result in the + file "|markdownOptionOutputTempFileName"}% + |markdownExecute{texlua "|markdownOptionOutputDir + /|markdownOptionHelperScriptFileName" > % + "|markdownOptionOutputDir + /|markdownOptionOutputTempFileName"}% + |input|markdownOptionOutputTempFileName|relax}% +|endgroup \else \markdownInfo{Using mode 2: Direct Lua access}% \def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}% @@ -514,6 +538,8 @@ local convert = md.new(\markdownLuaOptions) \catcode`\\=12% |gdef|markdownInput#1{% |markdownInfo{Including markdown document "#1"}% + |openin|markdownInputFileStream#1 + |closein|markdownInputFileStream |markdownLuaExecute{% |markdownPrepare local input = assert(io.open("#1","r")):read("*a") diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index 80ba474bdbf..f60dc234e7e 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -46,17 +46,28 @@ %% The names of the source files used are shown above. %% \NeedsTeXFormat{LaTeX2e}% +\RequirePackage{keyval} +\RequirePackage{url} +\RequirePackage{graphicx} +\RequirePackage{ifthen} +\RequirePackage{fancyvrb} +\RequirePackage{csvsimple} \newenvironment{markdown}\relax\relax \newenvironment{markdown*}[1]\relax\relax \newcommand\markdownSetup[1]{% \setkeys{markdownOptions}{#1}}% -\RequirePackage{keyval} \define@key{markdownOptions}{helperScriptFileName}{% \def\markdownOptionHelperScriptFileName{#1}}% \define@key{markdownOptions}{inputTempFileName}{% \def\markdownOptionInputTempFileName{#1}}% \define@key{markdownOptions}{outputTempFileName}{% \def\markdownOptionOutputTempFileName{#1}}% +\define@key{markdownOptions}{errorTempFileName}{% + \def\markdownOptionErrorTempFileName{#1}}% +\define@key{markdownOptions}{cacheDir}{% + \def\markdownOptionCacheDir{#1}}% +\define@key{markdownOptions}{outputDir}{% + \def\markdownOptionOutputDir{#1}}% \define@key{markdownOptions}{blankBeforeBlockquote}[true]{% \def\markdownOptionBlankBeforeBlockquote{#1}}% \define@key{markdownOptions}{blankBeforeCodeFence}[true]{% @@ -65,8 +76,6 @@ \def\markdownOptionBlankBeforeHeading{#1}}% \define@key{markdownOptions}{breakableBlockquotes}[true]{% \def\markdownOptionBreakableBlockquotes{#1}}% -\define@key{markdownOptions}{cacheDir}{% - \def\markdownOptionCacheDir{#1}}% \define@key{markdownOptions}{citations}[true]{% \def\markdownOptionCitations{#1}}% \define@key{markdownOptions}{citationNbsps}[true]{% @@ -367,9 +376,6 @@ \define@key{markdownOptions}{rendererPrototypes}{% \setkeys{markdownRendererPrototypes}{#1}% \def\KV@prefix{KV@markdownOptions@}}% -\RequirePackage{url} -\RequirePackage{graphicx} -\RequirePackage{ifthen} \ifx\markdownOptionTightLists\undefined \@ifclassloaded{beamer}{}{ \RequirePackage{paralist}} @@ -393,8 +399,6 @@ olEndTight = {\markdownRendererOlEnd}, dlBeginTight = {\markdownRendererDlBegin}, dlEndTight = {\markdownRendererDlEnd}}}} -\RequirePackage{fancyvrb} -\RequirePackage{csvsimple} \markdownSetup{rendererPrototypes={ lineBreak = {\\}, leftBrace = {\textbraceleft}, diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index fdb0d624982..fd190e628c6 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. -- local metadata = { - version = "2.5.3", + version = "2.5.4", comment = "A module for the conversion from markdown to plain TeX", author = "John MacFarlane, Hans Hagen, Vít Novotný", copyright = "2009-2017 John MacFarlane, Hans Hagen; " .. @@ -72,11 +72,12 @@ local unicode = require("unicode") local md5 = require("md5") local M = {} local defaultOptions = {} +defaultOptions.cacheDir = "." +defaultOptions.outputDir = "." defaultOptions.blankBeforeBlockquote = false defaultOptions.blankBeforeCodeFence = false defaultOptions.blankBeforeHeading = false defaultOptions.breakableBlockquotes = false -defaultOptions.cacheDir = "." defaultOptions.citationNbsps = true defaultOptions.citations = false defaultOptions.codeSpans = true -- cgit v1.2.3