texlive[41855] Master/texmf-dist: markdown (16aug16)
commits+karl at tug.org
commits+karl at tug.org
Mon Aug 15 22:33:03 CEST 2016
Revision: 41855
http://tug.org/svn/texlive?view=revision&revision=41855
Author: karl
Date: 2016-08-15 22:33:02 +0200 (Mon, 15 Aug 2016)
Log Message:
-----------
markdown (16aug16)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/generic/markdown/markdown.pdf
trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx
trunk/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex
trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex
trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty
trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua
Modified: trunk/Master/texmf-dist/doc/generic/markdown/markdown.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx
===================================================================
--- trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx 2016-08-15 01:10:42 UTC (rev 41854)
+++ trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx 2016-08-15 20:33:02 UTC (rev 41855)
@@ -136,8 +136,8 @@
% packages that enable the direct inclusion of markdown documents inside \TeX{}
% documents.
%
-% Architecturally, the package consists of the \pkg{Lunamark} Lua module by
-% John MacFarlane, which was slimmed down and rewritten for the needs of the
+% Architecturally, the package consists of the \pkg{Lunamark} v1.4.0 Lua module
+% by John MacFarlane, which was slimmed down and rewritten for the needs of the
% package. On top of \pkg{Lunamark} sits code for the plain \TeX{}, \LaTeX{},
% and \Hologo{ConTeXt} formats by Vít Novotný.
%
@@ -146,7 +146,7 @@
% \fi
% \begin{macrocode}
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ý",
@@ -217,7 +217,7 @@
% \m{markdownOptionCacheDir} macro before interfacing with the
% \pkg{Lunamark} library.
%
-% The plain \TeX{} code makes use of the \luam{isDir} method that was added
+% The plain \TeX{} code makes use of the \luam{isdir} method that was added
% to the module by the Lua\TeX{} engine developers (see
% \cite[Section~3.2]{luatex16}). This method is not present in the base
% library.
@@ -312,9 +312,6 @@
% recognized by the Lua interface. (see Section \ref{sec:luaoptions}). The
% \t`options` parameter is optional; when unspecified, the behaviour will be
% the same as if \t`options` were an empty table.
-% \begin{macrocode}
-M.new = {}
-% \end{macrocode}
%
% The following example Lua code converts the markdown string \t`_Hello
% world!_` to a \TeX{} output using the default options and prints the \TeX{}
@@ -501,7 +498,8 @@
% \ref{sec:luaoptions}) used during the conversion from markdown to plain
% \TeX{}, and for changing the way markdown the tokens are rendered.
% \begin{macrocode}
-\def\markdownVersion{2016/06/03}%
+\def\markdownLastModified{2016/08/14}%
+\def\markdownVersion{1.0.2}%
% \end{macrocode}
%
% The plain \TeX{} interface is implemented by the \t`markdown.tex` file that
@@ -639,7 +637,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
@@ -673,6 +671,36 @@
\markdownRendererEllipsisPrototype}%
% \end{macrocode}
%
+% \paragraph{Special Character Renderers}
+% The following macros replace any special plain \TeX{} characters (including
+% the active pipe character (\t`|`) of \Hologo{ConTeXt}) in the input text.
+% These macros will only be produced, when the \Opt{hybrid} option is
+% \t`false`.
+% \begin{macrocode}
+\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}%
+% \end{macrocode}
+%
% \paragraph{Code Span Renderer}
% The \mdef{markdownRendererCodeSpan} macro represents inlined code span in the
% input text. It receives a single argument that corresponds to the inlined
@@ -684,7 +712,9 @@
%
% \paragraph{Link Renderer}
% The \mdef{markdownRendererLink} macro represents a hyperlink. It receives
-% three arguments: the label, the \acro{uri}, and the title of the link.
+% four arguments: the label, the fully escaped \acro{uri} that can be directly
+% typeset, the raw \acro{uri} that can be used outside typesetting, and the
+% title of the link.
% \begin{macrocode}
\def\markdownRendererLink{%
\markdownRendererLinkPrototype}%
@@ -691,8 +721,10 @@
% \end{macrocode}
%
% \paragraph{Image Renderer}
-% The \mdef{markdownRendererImage} macro represents an image. It receives three
-% arguments: the label, the \acro{url}, and the title of the image.
+% The \mdef{markdownRendererImage} macro represents an image. It receives four
+% four arguments: the label, the fully escaped \acro{uri} that can be directly
+% typeset, the raw \acro{uri} that can be used outside typesetting, and the
+% title of the link.
% \begin{macrocode}
\def\markdownRendererImage{%
\markdownRendererImagePrototype}%
@@ -813,14 +845,30 @@
\markdownRendererDlBeginTightPrototype}%
% \end{macrocode}
%
-% The \mdef{markdownRendererDlItem} macro represents an item in a definition
-% list. The macro receives a single argument that corresponds to the term being
-% defined.
+% The \mdef{markdownRendererDlItem} macro represents a term in a definition
+% list. The macro receives a single argument that corresponds to the term
+% being defined.
% \begin{macrocode}
\def\markdownRendererDlItem{%
\markdownRendererDlItemPrototype}%
% \end{macrocode}
%
+% The \mdef{markdownRendererDlDefinitionBegin} macro represents the beginning
+% of a definition in a definition list. There can be several definitions for
+% a single term.
+% \begin{macrocode}
+\def\markdownRendererDlDefinitionBegin{%
+ \markdownRendererDlDefinitionBeginPrototype}%
+% \end{macrocode}
+%
+% The \mdef{markdownRendererDlDefinitionEnd} macro represents the end of a
+% definition in a definition list. There can be several definitions for a
+% single term.
+% \begin{macrocode}
+\def\markdownRendererDlDefinitionEnd{%
+ \markdownRendererDlDefinitionEndPrototype}%
+% \end{macrocode}
+%
% The \mdef{markdownRendererDlEnd} macro represents the end of a definition
% list that contains an item with several paragraphs of text (the list is not
% tight). The macro receives no arguments.
@@ -954,9 +1002,20 @@
% \begin{macrocode}
\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{}%
@@ -971,6 +1030,8 @@
\def\markdownRendererDlBeginPrototype{}%
\def\markdownRendererDlBeginTightPrototype{}%
\long\def\markdownRendererDlItemPrototype#1{}%
+\def\markdownRendererDlDefinitionBeginPrototype{}%
+\def\markdownRendererDlDefinitionEndPrototype{}%
\def\markdownRendererDlEndPrototype{}%
\def\markdownRendererDlEndTightPrototype{}%
\long\def\markdownRendererEmphasisPrototype#1{}%
@@ -1063,6 +1124,30 @@
% Section \ref{sec:directlua}), the first argument may not contain the
% string \t`]]` (regardless of the category code of the bracket symbol (\t`]`)).
%
+% The \mdef{markdownMode} macro specifies how the plain \TeX{} implementation
+% interfaces with the Lua interface. The valid values and their meaning are
+% as follows:
+% \begin{itemize}
+% \item\t`0` -- Shell escape via the 18 output file stream
+% \item\t`1` -- Shell escape via the Lua \luam{os.execute} method
+% \item\t`2` -- Direct Lua access
+% \end{itemize}
+% By defining the macro, the user can coerce the package to use a specific mode.
+% If the user does not define the macro prior to loading the plain \TeX{}
+% implementation, the correct value will be automatically detected. The outcome
+% of changing the value of \m{markdownMode} after the implementation has been
+% loaded is undefined.
+% \begin{macrocode}
+\ifx\markdownMode\undefined
+ \ifx\directlua\undefined
+ \def\markdownMode{0}%
+ \else
+ \def\markdownMode{2}%
+ \fi
+\fi
+% \end{macrocode}
+%
+%
% \iffalse
%</tex>
%<*latex>
@@ -1223,12 +1308,34 @@
\renewcommand\markdownRendererLineBreak{#1}}%
\define at key{markdownRenderers}{ellipsis}{%
\renewcommand\markdownRendererEllipsis{#1}}%
+\define at key{markdownRenderers}{leftBrace}{%
+ \renewcommand\markdownRendererLeftBrace{#1}}%
+\define at key{markdownRenderers}{rightBrace}{%
+ \renewcommand\markdownRendererRightBrace{#1}}%
+\define at key{markdownRenderers}{dollarSign}{%
+ \renewcommand\markdownRendererDollarSign{#1}}%
+\define at key{markdownRenderers}{percentSign}{%
+ \renewcommand\markdownRendererPercentSign{#1}}%
+\define at key{markdownRenderers}{ampersand}{%
+ \renewcommand\markdownRendererAmpersand{#1}}%
+\define at key{markdownRenderers}{underscore}{%
+ \renewcommand\markdownRendererUnderscore{#1}}%
+\define at key{markdownRenderers}{hash}{%
+ \renewcommand\markdownRendererHash{#1}}%
+\define at key{markdownRenderers}{circumflex}{%
+ \renewcommand\markdownRendererCircumflex{#1}}%
+\define at key{markdownRenderers}{backslash}{%
+ \renewcommand\markdownRendererBackslash{#1}}%
+\define at key{markdownRenderers}{tilde}{%
+ \renewcommand\markdownRendererTilde{#1}}%
+\define at key{markdownRenderers}{pipe}{%
+ \renewcommand\markdownRendererPipe{#1}}%
\define at key{markdownRenderers}{codeSpan}{%
\renewcommand\markdownRendererCodeSpan[1]{#1}}%
\define at key{markdownRenderers}{link}{%
- \renewcommand\markdownRendererLink[3]{#1}}%
+ \renewcommand\markdownRendererLink[4]{#1}}%
\define at key{markdownRenderers}{image}{%
- \renewcommand\markdownRendererImage[3]{#1}}%
+ \renewcommand\markdownRendererImage[4]{#1}}%
\define at key{markdownRenderers}{ulBegin}{%
\renewcommand\markdownRendererUlBegin{#1}}%
\define at key{markdownRenderers}{ulBeginTight}{%
@@ -1257,6 +1364,10 @@
\renewcommand\markdownRendererDlBeginTight{#1}}%
\define at key{markdownRenderers}{dlItem}{%
\renewcommand\markdownRendererDlItem[1]{#1}}%
+\define at key{markdownRenderers}{dlDefinitionBegin}{%
+ \renewcommand\markdownRendererDlDefinitionBegin{#1}}%
+\define at key{markdownRenderers}{dlDefinitionEnd}{%
+ \renewcommand\markdownRendererDlDefinitionEnd{#1}}%
\define at key{markdownRenderers}{dlEnd}{%
\renewcommand\markdownRendererDlEnd{#1}}%
\define at key{markdownRenderers}{dlEndTight}{%
@@ -1295,7 +1406,7 @@
% \begin{Verbatim}
% \markdownSetup{
% renderers = {
-% link = {#3}, % Render links as the link title.
+% link = {#4}, % Render links as the link title.
% emphasis = {\emph{#1}}, % Render emphasized text via `\emph`.
% }
% }
@@ -1313,12 +1424,34 @@
\renewcommand\markdownRendererLineBreakPrototype{#1}}%
\define at key{markdownRendererPrototypes}{ellipsis}{%
\renewcommand\markdownRendererEllipsisPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{leftBrace}{%
+ \renewcommand\markdownRendererLeftBracePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{rightBrace}{%
+ \renewcommand\markdownRendererRightBracePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{dollarSign}{%
+ \renewcommand\markdownRendererDollarSignPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{percentSign}{%
+ \renewcommand\markdownRendererPercentSignPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{ampersand}{%
+ \renewcommand\markdownRendererAmpersandPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{underscore}{%
+ \renewcommand\markdownRendererUnderscorePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{hash}{%
+ \renewcommand\markdownRendererHashPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{circumflex}{%
+ \renewcommand\markdownRendererCircumflexPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{backslash}{%
+ \renewcommand\markdownRendererBackslashPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{tilde}{%
+ \renewcommand\markdownRendererTildePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{pipe}{%
+ \renewcommand\markdownRendererPipe{#1}}%
\define at key{markdownRendererPrototypes}{codeSpan}{%
\renewcommand\markdownRendererCodeSpanPrototype[1]{#1}}%
\define at key{markdownRendererPrototypes}{link}{%
- \renewcommand\markdownRendererLink[3]{#1}}%
+ \renewcommand\markdownRendererLink[4]{#1}}%
\define at key{markdownRendererPrototypes}{image}{%
- \renewcommand\markdownRendererImage[3]{#1}}%
+ \renewcommand\markdownRendererImage[4]{#1}}%
\define at key{markdownRendererPrototypes}{ulBegin}{%
\renewcommand\markdownRendererUlBeginPrototype{#1}}%
\define at key{markdownRendererPrototypes}{ulBeginTight}{%
@@ -1347,6 +1480,10 @@
\renewcommand\markdownRendererDlBeginTightPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlItem}{%
\renewcommand\markdownRendererDlItemPrototype[1]{#1}}%
+\define at key{markdownRendererPrototypes}{dlDefinitionBegin}{%
+ \renewcommand\markdownRendererDlDefinitionBeginPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{dlDefinitionEnd}{%
+ \renewcommand\markdownRendererDlDefinitionEndPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlEnd}{%
\renewcommand\markdownRendererDlEndPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlEndTight}{%
@@ -1805,36 +1942,55 @@
self.hrule = "\\markdownRendererHorizontalRule "
% \end{macrocode}
%
-% Define a table \luamdef{escaped} containing the mapping from special plain
-% \TeX{} characters to their escaped variants.
+% Define a table \luamdef{escaped_chars} containing the mapping from special
+% plain \TeX{} characters (including the active pipe character (\t`|`) of
+% \Hologo{ConTeXt}) to their escaped variants. Define tables
+% \luamdef{escaped_minimal_chars} and \luamdef{escaped_minimal_strings}
+% containing the mapping from special plain characters and character strings
+% that need to be escaped even in content that will not be typeset.
% \begin{macrocode}
- local escaped = {
- ["{"] = "\\{",
- ["}"] = "\\}",
- ["$"] = "\\$",
- ["%"] = "\\%",
- ["&"] = "\\&",
- ["_"] = "\\_",
- ["#"] = "\\#",
- ["^"] = "\\^{}",
- ["\\"] = "\\char92{}",
- ["~"] = "\\char126{}",
- ["|"] = "\\char124{}", }
+ 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 ", }
% \end{macrocode}
-% Use the \luam{escaped} table to create an escaper function \luamdef{escape}.
+% Use the \luam{escaped_chars} table to create an escaper function
+% \luamdef{escape} and the \luam{escaped_minimal_chars} and
+% \luam{escaped_minimal_strings} tables to create an escaper function
+% \luamdef{escape_minimal}.
% \begin{macrocode}
- local escape = util.escaper(escaped)
+ local escape = util.escaper(escaped_chars)
+ local escape_minimal = util.escaper(escaped_minimal_chars,
+ escaped_minimal_strings)
% \end{macrocode}
%
% Define \luamdef{writer->string} as a function that will transform an input
-% plain text span \t`s` to the output format. If the \Opt{hybrid} option is
-% \t`true`, use an identity function. Otherwise, use the \luam{escape}
-% function.
+% plain text span \t`s` to the output format and \luamdef{writer->uri} as a
+% function that will transform an input \acro{uri} \t`u` to the output format.
+% If the \Opt{hybrid} option is \t`true`, use identity functions. Otherwise,
+% use the \luam{escape} and \luam{escape_minimal} functions.
% \begin{macrocode}
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
% \end{macrocode}
%
@@ -1847,13 +2003,14 @@
% \end{macrocode}
%
% Define \luamdef{writer->link} as a function that will transform an input
-% hyperlink to the output format, where \t`lab` corresponds to thelabel,
+% hyperlink to the output format, where \t`lab` corresponds to the label,
% \t`src` to \acro{uri}, and \t`tit` to the title of the link.
% \begin{macrocode}
function self.link(lab,src,tit)
return {"\\markdownRendererLink{",lab,"}",
"{",self.string(src),"}",
- "{",self.string(tit),"}"}
+ "{",self.uri(src),"}",
+ "{",self.string(tit or ""),"}"}
end
% \end{macrocode}
%
@@ -1864,7 +2021,8 @@
function self.image(lab,src,tit)
return {"\\markdownRendererImage{",lab,"}",
"{",self.string(src),"}",
- "{",self.string(tit),"}"}
+ "{",self.uri(src),"}",
+ "{",self.string(tit or ""),"}"}
end
% \end{macrocode}
%
@@ -1932,15 +2090,19 @@
% is a term and \t`defs` is an array of definitions. \t`tight` specifies,
% whether the list is tight or not.
% \begin{macrocode}
- 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
@@ -2163,7 +2325,7 @@
local fail = any - 1
local always = P("")
- local escapable = S("\\`*_{}[]()+_.!#-~:^")
+ local escapable = S("\\`*_{}[]()+_.!<>#-~:^")
local anyescaped = P("\\") / "" * escapable
+ any
@@ -2176,9 +2338,9 @@
local specialchar
if options.smartEllipses then
- specialchar = S("*_`&[]!\\.")
+ specialchar = S("*_`&[]<!\\.")
else
- specialchar = S("*_`&[]!\\")
+ specialchar = S("*_`&[]<!\\")
end
local normalchar = any -
@@ -2321,7 +2483,7 @@
if found then
return writer.note(parse_blocks(found))
else
- return {"[^", ref, "]"}
+ return {"[", parse_inlines("^" .. ref), "]"}
end
end
end
@@ -2835,14 +2997,25 @@
\errmessage{(l.\the\inputlineno) markdown.tex error: #1}}%
% \end{macrocode}
%
-% \subsubsection{Options}
+% \subsubsection{Token Renderers}
% The following definitions should be considered placeholder.
% \begin{macrocode}
\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{}%
@@ -2857,6 +3030,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}}%
@@ -2864,7 +3039,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}%
@@ -2883,39 +3058,39 @@
% to expand to either \t`true` or \t`false`.
% \begin{macrocode}
\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}
}%
% \end{macrocode}
%
@@ -2927,25 +3102,26 @@
% \end{macrocode}
% First, ensure that the \m{markdownOptionCacheDir} directory exists.
% \begin{macrocode}
- local lfs = require("lfs")
- local cacheDir = "\markdownOptionCacheDir"
- if lfs.isdir(cacheDir) == true then else
- assert(lfs.mkdir(cacheDir))
- end
+local lfs = require("lfs")
+local cacheDir = "\markdownOptionCacheDir"
+if lfs.isdir(cacheDir) == true then else
+ assert(lfs.mkdir(cacheDir))
+end
% \end{macrocode}
% Next, load the \t`markdown` module and create a converter function using
% the plain \TeX{} options, which were serialized to a Lua table via the
% \m{markdownLuaOptions} macro.
% \begin{macrocode}
- local md = require("markdown")
- local convert = md.new(\markdownLuaOptions)
+local md = require("markdown")
+local convert = md.new(\markdownLuaOptions)
}%
% \end{macrocode}
%
-% \subsubsection{Lua \t`\textbackslash write18` Bridge}\label{sec:luabridge}
+% \subsubsection{Lua Shell Escape Bridge}\label{sec:luabridge}
% The following \TeX{} code is intended for \TeX{} engines that do not provide
-% direct access to Lua, but expose the shell of the operating system through
-% the output file stream 18 (\Hologo{XeTeX}, \hologo{pdfLaTeX}).
+% direct access to Lua, but expose the shell of the operating system. This
+% corresponds to the \m{markdownMode} values of \t`0` and \t`1`.
+%
% The \m{markdownLuaExecute} and \m{markdownReadAndConvert} macros defined here
% and in Section \ref{sec:directlua} are meant to be transparent to the
% remaining code.
@@ -2955,7 +3131,13 @@
% execute Lua scripts using the \TeX{}Lua interpreter (see
% \cite[Section~3.1.1]{luatex16}).
% \begin{macrocode}
-\ifx\directlua\undefined
+
+\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
% \end{macrocode}
%
% The macro \mdef{markdownLuaExecuteFileStream} contains the number of the output
@@ -2965,125 +3147,153 @@
% named \m{markdownOptionInputTempFileName} during the expansion of the macro
% \m{markdownReadAndConvert}.
% \begin{macrocode}
- \csname newwrite\endcsname\markdownLuaExecuteFileStream
+\csname newwrite\endcsname\markdownLuaExecuteFileStream
% \end{macrocode}
%
-% The \mdef{markdownLuaExecuteShellEscape} macro contains the numeric value of
-% either the \m{pdfshellescape} (Lua\TeX{}, \Hologo{pdfTeX}) or the
-% \m{shellescape} (\Hologo{XeTeX}) commands. This value indicates, whether the
-% shell access is enabled (\t`1`), disabled (\t`0`), or restricted (\t`2`). If
-% neither of these commands is defined, act as if the shell access were enabled.
+% The \mdef{markdownExecuteShellEscape} macro contains the numeric value indicating
+% whether the shell access is enabled (\t`1`), disabled (\t`0`), or restricted
+% (\t`2`).
+%
+% If Lua is unavailable, inherit the value of the the \m{pdfshellescape}
+% (Lua\TeX{}, \Hologo{pdfTeX}) or the \m{shellescape} (\Hologo{XeTeX})
+% commands. If neither of these commands is defined, act as if the shell access
+% were enabled.
% \begin{macrocode}
- \csname newcount\endcsname\markdownLuaExecuteShellEscape
+\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
% \end{macrocode}
+% If Lua is available, inherit the value of the \t`status.shell_escape`
+% configuration item.
+% \begin{macrocode}
+\else
+ \def\markdownExecuteShellEscape{%
+ \directlua{tex.sprint(status.shell_escape)}}%
+\fi
+% \end{macrocode}
%
+% The \mdef{markdownExecuteDirect} macro executes the code it has received as
+% its first argument by writing it to the output file stream 18, if Lua is
+% unavailable, or by using the Lua \luam{markdown.execute} method otherwise.
+% \begin{macrocode}
+\ifnum\markdownMode=0\relax
+ \def\markdownExecuteDirect#1{\immediate\write18{#1}}%
+\else
+ \def\markdownExecuteDirect#1{%
+ \directlua{os.execute("\luaescapestring{#1}")}}%
+\fi
+% \end{macrocode}
+%
+% The \mdef{markdownExecute} macro is a wrapper on top of
+% \m{markdownExecuteDirect} that checks the value of
+% \m{markdownExecuteShellEscape} and prints an error message if the shell is
+% inaccessible.
+% \begin{macrocode}
+\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}%
+% \end{macrocode}
+%
% The \mdef{markdownLuaExecute} macro executes the Lua code it has received as
% its first argument. The Lua code may not directly interact with the \TeX{}
% engine, but it can use the \luam{print} function in the same manner it
% would use the \luam{tex.print} method.
% \begin{macrocode}
- \def\markdownLuaExecute#1{%
+\def\markdownLuaExecute#1{%
% \end{macrocode}
-% If the shell is accessible, create the file
-% \m{markdownOptionHelperScriptFileName} and fill it with the input Lua code
-% prepended with \pkg{kpathsea} initialization, so that Lua modules from the
-% \TeX{} distribution are available.
+% Create the file \m{markdownOptionHelperScriptFileName} and fill it with the
+% input Lua code prepended with \pkg{kpathsea} initialization, so that Lua
+% modules from the \TeX{} distribution are available.
% \begin{macrocode}
- \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
+ \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
% \end{macrocode}
% Execute the generated \m{markdownOptionHelperScriptFileName} Lua script using
% the \TeX{}Lua binary and store the output in the
% \m{markdownOptionOutputTempFileName} file.
% \begin{macrocode}
- \markdownInfo{Executing a helper Lua script from the file
- "\markdownOptionHelperScriptFileName" and storing the result in the
- file "\markdownOptionOutputTempFileName"}%
- \immediate\write18{texlua "\markdownOptionHelperScriptFileName" >
- "\markdownOptionOutputTempFileName"}%
+ \markdownInfo{Executing a helper Lua script from the file
+ "\markdownOptionHelperScriptFileName" and storing the result in the
+ file "\markdownOptionOutputTempFileName"}%
+ \markdownExecute{texlua "\markdownOptionHelperScriptFileName" >
+ "\markdownOptionOutputTempFileName"}%
% \end{macrocode}
% \m{input} the generated \m{markdownOptionOutputTempFileName} file.
% \begin{macrocode}
- \input\markdownOptionOutputTempFileName\relax
- \else
+ \input\markdownOptionOutputTempFileName\relax}%
% \end{macrocode}
-% If the shell is inaccessible, let the user know and suggest a remedy.
-% \begin{macrocode}
- \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}%
-% \end{macrocode}
%
% The \mdef{markdownReadAndConvertTab} macro contains the tab character literal.
% \begin{macrocode}
- \begingroup
- \catcode`\^^I=12%
- \gdef\markdownReadAndConvertTab{^^I}%
- \endgroup
+\begingroup
+ \catcode`\^^I=12%
+ \gdef\markdownReadAndConvertTab{^^I}%
+\endgroup
% \end{macrocode}
%
% The \m{markdownReadAndConvert} macro is largely a rewrite of the
% \Hologo{LaTeX2e} \m{filecontents} macro to plain \TeX{}.
% \begin{macrocode}
- \begingroup
+\begingroup
% \end{macrocode}
% Make the newline and tab characters active and swap the character codes of the
% backslash symbol (\t`\textbackslash`) and the pipe symbol (\t`|`), so that
% we can use the backslash as an ordinary character inside the macro definition.
% \begin{macrocode}
- \catcode`\^^M=13%
- \catcode`\^^I=13%
- \catcode`|=0%
- \catcode`\\=12%
- |gdef|markdownReadAndConvert#1#2{%
- |begingroup%
+ \catcode`\^^M=13%
+ \catcode`\^^I=13%
+ \catcode`|=0%
+ \catcode`\\=12%
+ |gdef|markdownReadAndConvert#1#2{%
+ |begingroup%
% \end{macrocode}
% Open the \m{markdownOptionInputTempFileName} file for writing.
% \begin{macrocode}
- |immediate|openout|markdownLuaExecuteFileStream%
- |markdownOptionInputTempFileName%
- |markdownInfo{Buffering markdown input into the temporary %
- input file "|markdownOptionInputTempFileName" and scanning %
- for the closing token sequence "#1"}%
+ |immediate|openout|markdownLuaExecuteFileStream%
+ |markdownOptionInputTempFileName%
+ |markdownInfo{Buffering markdown input into the temporary %
+ input file "|markdownOptionInputTempFileName" and scanning %
+ for the closing token sequence "#1"}%
% \end{macrocode}
% Locally change the category of the special plain \TeX{} characters to
% \emph{other} in order to prevent unwanted interpretation of the input.
-% Change also the category of the space and tab characters, so that we
-% can retrieve them unaltered.
+% Change also the category of the space character, so that we can retrieve it
+% unaltered.
% \begin{macrocode}
- |def|do##1{|catcode`##1=12}|dospecials%
- |catcode`| =12%
- |markdownMakeOther%
+ |def|do##1{|catcode`##1=12}|dospecials%
+ |catcode`| =12%
+ |markdownMakeOther%
% \end{macrocode}
% The \mdef{markdownReadAndConvertProcessLine} macro will process the individual
% lines of output. Note the use of the comments to ensure that the entire macro
% is at a single line and therefore no (active) newline symbols are produced.
% \begin{macrocode}
- |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{%
+ |def|markdownReadAndConvertProcessLine##1#1##2#1##3|relax{%
% \end{macrocode}
% When the ending token sequence does not appear in the line, store the line in
% the \m{markdownOptionInputTempFileName} file.
% \begin{macrocode}
- |ifx|relax##3|relax%
- |immediate|write|markdownLuaExecuteFileStream{##1}%
- |else%
+ |ifx|relax##3|relax%
+ |immediate|write|markdownLuaExecuteFileStream{##1}%
+ |else%
% \end{macrocode}
% When the ending token sequence appears in the line, make the next newline
% character close the \m{markdownOptionInputTempFileName} file, return the
@@ -3092,39 +3302,39 @@
% \m{input} the result of the conversion, and expand the ending control
% sequence.
% \begin{macrocode}
- |def^^M{%
- |markdownInfo{The ending token sequence was found}%
- |immediate|write|markdownLuaExecuteFileStream{}%
- |immediate|closeout|markdownLuaExecuteFileStream%
- |endgroup%
- |markdownInput|markdownOptionInputTempFileName%
- #2}%
- |fi%
+ |def^^M{%
+ |markdownInfo{The ending token sequence was found}%
+ |immediate|write|markdownLuaExecuteFileStream{}%
+ |immediate|closeout|markdownLuaExecuteFileStream%
+ |endgroup%
+ |markdownInput|markdownOptionInputTempFileName%
+ #2}%
+ |fi%
% \end{macrocode}
% Repeat with the next line.
% \begin{macrocode}
- ^^M}%
+ ^^M}%
% \end{macrocode}
% Make the tab character active at expansion time and make it expand to a
% literal tab character.
% \begin{macrocode}
- |catcode`|^^I=13%
- |def^^I{|markdownReadAndConvertTab}%
+ |catcode`|^^I=13%
+ |def^^I{|markdownReadAndConvertTab}%
% \end{macrocode}
% Make the newline character active at expansion time and make it consume the
% rest of the line on expansion. Throw away the rest of the first line and
% pass the second line to the \m{markdownReadAndConvertProcessLine} macro.
% \begin{macrocode}
- |catcode`|^^M=13%
- |def^^M##1^^M{%
- |def^^M####1^^M{%
- |markdownReadAndConvertProcessLine####1#1#1|relax}%
- ^^M}%
+ |catcode`|^^M=13%
+ |def^^M##1^^M{%
+ |def^^M####1^^M{%
+ |markdownReadAndConvertProcessLine####1#1#1|relax}%
^^M}%
+ ^^M}%
% \end{macrocode}
% Reset the character categories back to the former state.
% \begin{macrocode}
- |endgroup
+|endgroup
% \end{macrocode}
%
% \subsubsection{Direct Lua Access}\label{sec:directlua}
@@ -3131,9 +3341,11 @@
% The following \TeX{} code is intended for \TeX{} engines that provide
% direct access to Lua (Lua\TeX{}). The \m{markdownLuaExecute} and
% \m{markdownReadAndConvert} defined here and in Section \ref{sec:luabridge}
-% are meant to be transparent to the remaining code.
+% are meant to be transparent to the remaining code. This corresponds to the
+% \m{markdownMode} value of \t`2`.
% \begin{macrocode}
\else
+\markdownInfo{Using mode 2: Direct Lua access}%
% \end{macrocode}
% The direct Lua access version of the \m{markdownLuaExecute} macro is defined
% in terms of the \m{directlua} primitive. The \luam{print} function is set as
@@ -3140,20 +3352,20 @@
% an alias to the \m{tex.print} method in order to mimic the behaviour of the
% \m{markdownLuaExecute} definition from Section \ref{sec:luabridge},
% \begin{macrocode}
- \def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}%
+\def\markdownLuaExecute#1{\directlua{local print = tex.print #1}}%
% \end{macrocode}
%
% In the definition of the direct Lua access version of the
% \m{markdownReadAndConvert} macro, we will be using the hash symbol
-% (\t`\#`), the underscore symbol (\t`_`), the caret symbol (\t`\^`), the
+% (\t`\#`), the underscore symbol (\t`_`), the circumflex symbol (\t`\^`), the
% dollar sign (\t`\$`), the backslash symbol (\t`\textbackslash`), the percent
% sign (\t`\%`), and the braces (\t`\{\}`) as a part of the Lua syntax.
% \begin{macrocode}
- \begingroup
+\begingroup
% \end{macrocode}
%
-% To this end, we will make the underscore symbol, the dollar sign, and caret
-% symbols ordinary characters,
+% To this end, we will make the underscore symbol, the dollar sign, and
+% circumflex symbols ordinary characters,
% \begin{macrocode}
\catcode`\_=12%
\catcode`\$=12%
@@ -3272,7 +3484,9 @@
% existing plain \TeX{} implementation.
% \begin{macrocode}
\input markdown
-\ProvidesPackage{markdown}[\markdownVersion]%
+\def\markdownVersionSpace{ }%
+\ProvidesPackage{markdown}[\markdownLastModified\markdownVersionSpace v%
+ \markdownVersion\markdownVersionSpace markdown renderer]%
% \end{macrocode}
%
% \subsubsection{Logging Facilities}
@@ -3337,7 +3551,8 @@
\RequirePackage{graphicx}
% \end{macrocode}
% If the \m{markdownOptionTightLists} macro expands to \t`false`, do not load
-% the \pkg{paralist} package.
+% the \pkg{paralist} package. This is necessary for \Hologo{LaTeX2e} document
+% classes that do not play nice with \pkg{paralist}, such as \pkg{beamer}.
% \begin{macrocode}
\RequirePackage{ifthen}
\ifx\markdownOptionTightLists\undefined
@@ -3349,15 +3564,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}},
@@ -3382,7 +3605,7 @@
\ifx\alert\undefined
\textbf{\emph{#1}}%
\else % Beamer support
- \alert{\emph{#1}}
+ \alert{\emph{#1}}%
\fi},
blockQuoteBegin = {\begin{quotation}},
blockQuoteEnd = {\end{quotation}},
@@ -3476,19 +3699,17 @@
% If we can not, we are probably using ConTeXt Mark IV. In ConTeXt Mark IV, the
% \t`process_input_buffer` callback is currently frozen (inaccessible from the
% user code) and, due to the lack of available documentation, it is unclear to
-% me how to emulate it. Therefore, we will just force the plain \TeX{}
-% implementation to use the \m{write18} bridge (see Section
-% \ref{sec:luabridge}) by locally undefining the \m{directlua} primitive.
+% me how to emulate it. As a workaround, we will force the plain \TeX{}
+% implementation to use the Lua shell escape bridge (see Section
+% \ref{sec:luabridge}) by setting the \m{markdownMode} macro to the value of
+% \t`1`.
% \begin{macrocode}
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]]))
% \end{macrocode}
%
-% If we can, then just load the plain \TeX{} implementation.
+% If we can set the \t`process_input_buffer` Lua\TeX{} callback, then just load
+% the plain \TeX{} implementation.
% \begin{macrocode}
else
callback.register("process_input_buffer", old_callback)
@@ -3497,6 +3718,16 @@
\fi
% \end{macrocode}
%
+% If the shell escape bridge is being used, define the \m{markdownMakeOther}
+% macro, so that the pipe character (\t`|`) is inactive during the scanning.
+% This is necessary, since the character is active in \Hologo{ConTeXt}.
+% \begin{macrocode}
+\ifnum\markdownMode<2
+ \def\markdownMakeOther{%
+ \catcode`|=12}%
+\fi
+% \end{macrocode}
+%
% \subsubsection{Logging Facilities}
% The \Hologo{ConTeXt} implementation redefines the plain \TeX{} logging macros (see
% Section \ref{sec:texinterfacelogging}) to use the \Hologo{ConTeXt}
@@ -3529,11 +3760,20 @@
% The following configuration should be considered placeholder.
% \begin{macrocode}
\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}%
@@ -3562,7 +3802,7 @@
\startMarkdownConTeXtDlPrototype}%
\def\markdownRendererDlBeginTightPrototype{%
\startMarkdownConTeXtDlTightPrototype}%
-\long\long\def\markdownRendererDlItemPrototype#1{%
+\long\def\markdownRendererDlItemPrototype#1{%
\markdownConTeXtDlItemPrototype{#1}}%
\def\markdownRendererDlEndPrototype{%
\stopMarkdownConTeXtDlPrototype}%
Modified: trunk/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex 2016-08-15 01:10:42 UTC (rev 41854)
+++ trunk/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex 2016-08-15 20:33:02 UTC (rev 41855)
@@ -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}%
Modified: trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex 2016-08-15 01:10:42 UTC (rev 41854)
+++ trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex 2016-08-15 20:33:02 UTC (rev 41855)
@@ -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%
Modified: trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty 2016-08-15 01:10:42 UTC (rev 41854)
+++ trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty 2016-08-15 20:33:02 UTC (rev 41855)
@@ -85,12 +85,34 @@
\renewcommand\markdownRendererLineBreak{#1}}%
\define at key{markdownRenderers}{ellipsis}{%
\renewcommand\markdownRendererEllipsis{#1}}%
+\define at key{markdownRenderers}{leftBrace}{%
+ \renewcommand\markdownRendererLeftBrace{#1}}%
+\define at key{markdownRenderers}{rightBrace}{%
+ \renewcommand\markdownRendererRightBrace{#1}}%
+\define at key{markdownRenderers}{dollarSign}{%
+ \renewcommand\markdownRendererDollarSign{#1}}%
+\define at key{markdownRenderers}{percentSign}{%
+ \renewcommand\markdownRendererPercentSign{#1}}%
+\define at key{markdownRenderers}{ampersand}{%
+ \renewcommand\markdownRendererAmpersand{#1}}%
+\define at key{markdownRenderers}{underscore}{%
+ \renewcommand\markdownRendererUnderscore{#1}}%
+\define at key{markdownRenderers}{hash}{%
+ \renewcommand\markdownRendererHash{#1}}%
+\define at key{markdownRenderers}{circumflex}{%
+ \renewcommand\markdownRendererCircumflex{#1}}%
+\define at key{markdownRenderers}{backslash}{%
+ \renewcommand\markdownRendererBackslash{#1}}%
+\define at key{markdownRenderers}{tilde}{%
+ \renewcommand\markdownRendererTilde{#1}}%
+\define at key{markdownRenderers}{pipe}{%
+ \renewcommand\markdownRendererPipe{#1}}%
\define at key{markdownRenderers}{codeSpan}{%
\renewcommand\markdownRendererCodeSpan[1]{#1}}%
\define at key{markdownRenderers}{link}{%
- \renewcommand\markdownRendererLink[3]{#1}}%
+ \renewcommand\markdownRendererLink[4]{#1}}%
\define at key{markdownRenderers}{image}{%
- \renewcommand\markdownRendererImage[3]{#1}}%
+ \renewcommand\markdownRendererImage[4]{#1}}%
\define at key{markdownRenderers}{ulBegin}{%
\renewcommand\markdownRendererUlBegin{#1}}%
\define at key{markdownRenderers}{ulBeginTight}{%
@@ -119,6 +141,10 @@
\renewcommand\markdownRendererDlBeginTight{#1}}%
\define at key{markdownRenderers}{dlItem}{%
\renewcommand\markdownRendererDlItem[1]{#1}}%
+\define at key{markdownRenderers}{dlDefinitionBegin}{%
+ \renewcommand\markdownRendererDlDefinitionBegin{#1}}%
+\define at key{markdownRenderers}{dlDefinitionEnd}{%
+ \renewcommand\markdownRendererDlDefinitionEnd{#1}}%
\define at key{markdownRenderers}{dlEnd}{%
\renewcommand\markdownRendererDlEnd{#1}}%
\define at key{markdownRenderers}{dlEndTight}{%
@@ -155,12 +181,34 @@
\renewcommand\markdownRendererLineBreakPrototype{#1}}%
\define at key{markdownRendererPrototypes}{ellipsis}{%
\renewcommand\markdownRendererEllipsisPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{leftBrace}{%
+ \renewcommand\markdownRendererLeftBracePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{rightBrace}{%
+ \renewcommand\markdownRendererRightBracePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{dollarSign}{%
+ \renewcommand\markdownRendererDollarSignPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{percentSign}{%
+ \renewcommand\markdownRendererPercentSignPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{ampersand}{%
+ \renewcommand\markdownRendererAmpersandPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{underscore}{%
+ \renewcommand\markdownRendererUnderscorePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{hash}{%
+ \renewcommand\markdownRendererHashPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{circumflex}{%
+ \renewcommand\markdownRendererCircumflexPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{backslash}{%
+ \renewcommand\markdownRendererBackslashPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{tilde}{%
+ \renewcommand\markdownRendererTildePrototype{#1}}%
+\define at key{markdownRendererPrototypes}{pipe}{%
+ \renewcommand\markdownRendererPipe{#1}}%
\define at key{markdownRendererPrototypes}{codeSpan}{%
\renewcommand\markdownRendererCodeSpanPrototype[1]{#1}}%
\define at key{markdownRendererPrototypes}{link}{%
- \renewcommand\markdownRendererLink[3]{#1}}%
+ \renewcommand\markdownRendererLink[4]{#1}}%
\define at key{markdownRendererPrototypes}{image}{%
- \renewcommand\markdownRendererImage[3]{#1}}%
+ \renewcommand\markdownRendererImage[4]{#1}}%
\define at key{markdownRendererPrototypes}{ulBegin}{%
\renewcommand\markdownRendererUlBeginPrototype{#1}}%
\define at key{markdownRendererPrototypes}{ulBeginTight}{%
@@ -189,6 +237,10 @@
\renewcommand\markdownRendererDlBeginTightPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlItem}{%
\renewcommand\markdownRendererDlItemPrototype[1]{#1}}%
+\define at key{markdownRendererPrototypes}{dlDefinitionBegin}{%
+ \renewcommand\markdownRendererDlDefinitionBeginPrototype{#1}}%
+\define at key{markdownRendererPrototypes}{dlDefinitionEnd}{%
+ \renewcommand\markdownRendererDlDefinitionEndPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlEnd}{%
\renewcommand\markdownRendererDlEndPrototype{#1}}%
\define at key{markdownRendererPrototypes}{dlEndTight}{%
@@ -220,7 +272,9 @@
\define at 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}},
Modified: trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua 2016-08-15 01:10:42 UTC (rev 41854)
+++ trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua 2016-08-15 20:33:02 UTC (rev 41855)
@@ -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 unicode = require("unicode")
local md5 = require("md5")
local M = {}
-M.new = {}
local defaultOptions = {}
defaultOptions.blankBeforeBlockquote = false
defaultOptions.blankBeforeHeading = false
@@ -238,23 +237,34 @@
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 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 @@
"\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 @@
local fail = any - 1
local always = P("")
- local escapable = S("\\`*_{}[]()+_.!#-~:^")
+ local escapable = S("\\`*_{}[]()+_.!<>#-~:^")
local anyescaped = P("\\") / "" * escapable
+ any
@@ -480,9 +496,9 @@
local specialchar
if options.smartEllipses then
- specialchar = S("*_`&[]!\\.")
+ specialchar = S("*_`&[]<!\\.")
else
- specialchar = S("*_`&[]!\\")
+ specialchar = S("*_`&[]<!\\")
end
local normalchar = any -
@@ -613,7 +629,7 @@
if found then
return writer.note(parse_blocks(found))
else
- return {"[^", ref, "]"}
+ return {"[", parse_inlines("^" .. ref), "]"}
end
end
end
More information about the tex-live-commits
mailing list