summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/markdown/markdown.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/markdown/markdown.dtx')
-rw-r--r--Master/texmf-dist/source/generic/markdown/markdown.dtx250
1 files changed, 145 insertions, 105 deletions
diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx
index 894d6063472..5b3f8f65963 100644
--- a/Master/texmf-dist/source/generic/markdown/markdown.dtx
+++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx
@@ -74,10 +74,10 @@
\begin{filecontents}{markdown.bib}
@book{luatex16,
author = {{Lua\TeX{} development team}},
- title = {Lua\TeX{} reference manual (0.98.3)},
- date = {2016-08-23},
+ title = {Lua\TeX{} reference manual},
+ date = {2016-09-27},
url = {http://www.luatex.org/svn/trunk/manual/luatex.pdf},
- urldate = {2016-08-30}}
+ urldate = {2016-11-27}}
@book{latex16,
author = {Braams, Johannes and Carlisle, David and Jeffrey, Alan and
Lamport, Leslie and Mittelbach, Frank and Rowley, Chris and
@@ -85,7 +85,7 @@
title = {The \Hologo{LaTeX2e} Sources},
date = {2016-03-31},
url = {http://mirrors.ctan.org/macros/latex/base/source2e.pdf},
- urldate = {2016-06-02}}
+ urldate = {2016-09-27}}
@book{ierusalimschy13,
author = {Ierusalimschy, Roberto},
year = {2013},
@@ -137,7 +137,7 @@
% packages that enable the direct inclusion of markdown documents inside \TeX{}
% documents.
%
-% Architecturally, the package consists of the \pkg{Lunamark} v1.4.0 Lua module
+% Architecturally, the package consists of the \pkg{Lunamark} v0.5.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ý.
@@ -147,7 +147,7 @@
% \fi
% \begin{macrocode}
local metadata = {
- version = "2.1.3",
+ version = "2.2.1",
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ý",
@@ -530,6 +530,20 @@ defaultOptions.fencedCode = false
defaultOptions.footnotes = false
% \end{macrocode}
%
+% \Optitem[false]{inlineFootnotes}{\opt{true}, \opt{false}}
+% \begin{valuelist}
+% \item[true] Enable the pandoc inline footnote syntax extension:
+% \begin{Verbatim}
+% Here is an inline note.^[Inlines notes are easier to
+% write, since you don't have to pick an identifier and
+% move down to type the note.]
+% \end{Verbatim}
+% \item[false] Disable the pandoc inline footnote syntax extension.
+% \end{valuelist}
+% \begin{macrocode}
+defaultOptions.inlineFootnotes = false
+% \end{macrocode}
+%
% \Optitem[false]{preserveTabs}{\opt{true}, \opt{false}}
% \begin{valuelist}
% \item[true] Preserve all tabs in the input.
@@ -586,8 +600,8 @@ defaultOptions.tightLists = true
% \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\markdownLastModified{2016/09/15}%
-\def\markdownVersion{2.1.3}%
+\def\markdownLastModified{2016/12/07}%
+\def\markdownVersion{2.2.1}%
% \end{macrocode}
%
% The plain \TeX{} interface is implemented by the \t`markdown.tex` file that
@@ -732,6 +746,7 @@ defaultOptions.tightLists = true
\let\markdownOptionFencedCode\undefined
\let\markdownOptionHashEnumerators\undefined
\let\markdownOptionHybrid\undefined
+\let\markdownOptionInlineFootnotes\undefined
\let\markdownOptionPreserveTabs\undefined
\let\markdownOptionSmartEllipses\undefined
\let\markdownOptionStartNumber\undefined
@@ -1449,6 +1464,8 @@ defaultOptions.tightLists = true
\def\markdownOptionHashEnumerators{#1}}%
\define@key{markdownOptions}{hybrid}[true]{%
\def\markdownOptionHybrid{#1}}%
+\define@key{markdownOptions}{inlineFotnotes}[true]{%
+ \def\markdownOptionInlineFootnotes{#1}}%
\define@key{markdownOptions}{preserveTabs}[true]{%
\def\markdownOptionPreserveTabs{#1}}%
\define@key{markdownOptions}{smartEllipses}[true]{%
@@ -2424,6 +2441,100 @@ function M.writer.new(options)
return self
end
% \end{macrocode}
+% \subsubsection{Generic \acro{peg} Patterns}
+% These \acro{peg} patterns have been temporarily moved outside the
+% \luam{reader.new} method, which is currently hitting the limit of 200 local
+% variables. To resolve this issue, all the \acro{peg} patterns local to
+% \luam{reader.new} will be moved to a static hash table at some point in the
+% future.
+% \begin{macrocode}
+local percent = P("%")
+local at = P("@")
+local comma = P(",")
+local asterisk = P("*")
+local dash = P("-")
+local plus = P("+")
+local underscore = P("_")
+local period = P(".")
+local hash = P("#")
+local ampersand = P("&")
+local backtick = P("`")
+local less = P("<")
+local more = P(">")
+local space = P(" ")
+local squote = P("'")
+local dquote = P('"')
+local lparent = P("(")
+local rparent = P(")")
+local lbracket = P("[")
+local rbracket = P("]")
+local circumflex = P("^")
+local slash = P("/")
+local equal = P("=")
+local colon = P(":")
+local semicolon = P(";")
+local exclamation = P("!")
+local tilde = P("~")
+
+local digit = R("09")
+local hexdigit = R("09","af","AF")
+local letter = R("AZ","az")
+local alphanumeric = R("AZ","az","09")
+local keyword = letter * alphanumeric^0
+local internal_punctuation = S(":;,.#$%&-+?<>~/")
+
+local doubleasterisks = P("**")
+local doubleunderscores = P("__")
+local fourspaces = P(" ")
+
+local any = P(1)
+local fail = any - 1
+local always = P("")
+
+local escapable = S("\\`*_{}[]()+_.!<>#-~:^@;")
+
+local anyescaped = P("\\") / "" * escapable
+ + any
+
+local tab = P("\t")
+local spacechar = S("\t ")
+local spacing = S(" \n\r\t")
+local newline = P("\n")
+local nonspacechar = any - spacing
+local tightblocksep = P("\001")
+
+local specialchar = S("*_`&[]<!\\.@-^")
+
+local normalchar = any -
+ (specialchar + spacing + tightblocksep)
+local optionalspace = spacechar^0
+local eof = - any
+local nonindentspace = space^-3 * - spacechar
+local indent = space^-3 * tab
+ + fourspaces / ""
+local linechar = P(1 - newline)
+
+local blankline = optionalspace * newline / "\n"
+local blanklines = blankline^0
+local skipblanklines = (optionalspace * newline)^0
+local indentedline = indent /"" * C(linechar^1 * newline^-1)
+local optionallyindentedline = indent^-1 /"" * C(linechar^1 * newline^-1)
+local sp = spacing^0
+local spnl = optionalspace * (newline * optionalspace)^-1
+local line = linechar^0 * newline
+ + linechar^1 * eof
+local nonemptyline = line - blankline
+
+local chunk = line * (optionallyindentedline - blankline)^0
+
+-- block followed by 0 or more optionally
+-- indented blocks with first line indented.
+local function indented_blocks(bl)
+ return Cs( bl
+ * (blankline^1 * indent * -blankline * bl)^0
+ * (blankline^1 + eof) )
+end
+% \end{macrocode}
%
% \subsubsection{Markdown Reader}\label{sec:markdownreader}
% This section documents the \luam{reader} object, which implements the
@@ -2492,7 +2603,10 @@ function M.reader.new(writer, options)
local syntax
local blocks_toplevel
local blocks
- local inlines, inlines_no_link, inlines_nbsp
+ local inlines
+ local inlines_no_link
+ local inlines_no_inline_note
+ local inlines_nbsp
local function create_parser(name, grammar)
return function(str)
@@ -2513,98 +2627,12 @@ function M.reader.new(writer, options)
function() return inlines end)
local parse_inlines_no_link = create_parser("parse_inlines_no_link",
function() return inlines_no_link end)
+ local parse_inlines_no_inline_note = create_parser(
+ "parse_inlines_no_inline_note",
+ function() return inlines_no_inline_note end)
local parse_inlines_nbsp = create_parser("parse_inlines_nbsp",
function() return inlines_nbsp end)
% \end{macrocode}
-% \paragraph{Generic \acro{peg} Patterns}
-% \begin{macrocode}
- local percent = P("%")
- local at = P("@")
- local comma = P(",")
- local asterisk = P("*")
- local dash = P("-")
- local plus = P("+")
- local underscore = P("_")
- local period = P(".")
- local hash = P("#")
- local ampersand = P("&")
- local backtick = P("`")
- local less = P("<")
- local more = P(">")
- local space = P(" ")
- local squote = P("'")
- local dquote = P('"')
- local lparent = P("(")
- local rparent = P(")")
- local lbracket = P("[")
- local rbracket = P("]")
- local circumflex = P("^")
- local slash = P("/")
- local equal = P("=")
- local colon = P(":")
- local semicolon = P(";")
- local exclamation = P("!")
- local tilde = P("~")
-
- local digit = R("09")
- local hexdigit = R("09","af","AF")
- local letter = R("AZ","az")
- local alphanumeric = R("AZ","az","09")
- local keyword = letter * alphanumeric^0
- local internal_punctuation = S(":;,.#$%&-+?<>~/")
-
- local doubleasterisks = P("**")
- local doubleunderscores = P("__")
- local fourspaces = P(" ")
-
- local any = P(1)
- local fail = any - 1
- local always = P("")
-
- local escapable = S("\\`*_{}[]()+_.!<>#-~:^@;")
-
- local anyescaped = P("\\") / "" * escapable
- + any
-
- local tab = P("\t")
- local spacechar = S("\t ")
- local spacing = S(" \n\r\t")
- local newline = P("\n")
- local nonspacechar = any - spacing
- local tightblocksep = P("\001")
-
- local specialchar = S("*_`&[]<!\\.@-")
-
- local normalchar = any -
- (specialchar + spacing + tightblocksep)
- local optionalspace = spacechar^0
- local eof = - any
- local nonindentspace = space^-3 * - spacechar
- local indent = space^-3 * tab
- + fourspaces / ""
- local linechar = P(1 - newline)
-
- local blankline = optionalspace * newline / "\n"
- local blanklines = blankline^0
- local skipblanklines = (optionalspace * newline)^0
- local indentedline = indent /"" * C(linechar^1 * newline^-1)
- local optionallyindentedline = indent^-1 /"" * C(linechar^1 * newline^-1)
- local sp = spacing^0
- local spnl = optionalspace * (newline * optionalspace)^-1
- local line = linechar^0 * newline
- + linechar^1 * eof
- local nonemptyline = line - blankline
-
- local chunk = line * (optionallyindentedline - blankline)^0
-
- -- block followed by 0 or more optionally
- -- indented blocks with first line indented.
- local function indented_blocks(bl)
- return Cs( bl
- * (blankline^1 * indent * -blankline * bl)^0
- * (blankline^1 + eof) )
- end
-% \end{macrocode}
% \paragraph{List \acro{peg} Patterns}
% \begin{macrocode}
local bulletchar = C(plus + asterisk + dash)
@@ -2803,14 +2831,13 @@ function M.reader.new(writer, options)
local NoteRef = RawNoteRef / lookup_note
- local NoteBlock
- if options.footnotes then
- NoteBlock = leader * RawNoteRef * colon * spnl *
- indented_blocks(chunk) / register_note
- else
- NoteBlock = fail
- end
+ local NoteBlock = leader * RawNoteRef * colon * spnl
+ * indented_blocks(chunk) / register_note
+
+ local InlineNote = circumflex -- no notes inside notes
+ * (tag / parse_inlines_no_inline_note)
+ / writer.note
% \end{macrocode}
% \paragraph{Link and Image \acro{peg} Patterns}
% \begin{macrocode}
@@ -3295,6 +3322,7 @@ function M.reader.new(writer, options)
+ V("UlOrStarLine")
+ V("Strong")
+ V("Emph")
+ + V("InlineNote")
+ V("NoteRef")
+ V("Citations")
+ V("Link")
@@ -3312,6 +3340,7 @@ function M.reader.new(writer, options)
UlOrStarLine = UlOrStarLine,
Strong = Strong,
Emph = Emph,
+ InlineNote = InlineNote,
NoteRef = NoteRef,
Citations = Citations,
Link = Link,
@@ -3342,6 +3371,10 @@ function M.reader.new(writer, options)
syntax.NoteRef = fail
end
+ if not options.inlineFootnotes then
+ syntax.InlineNote = fail
+ end
+
if not options.smartEllipses then
syntax.Smart = fail
end
@@ -3361,6 +3394,10 @@ function M.reader.new(writer, options)
inlines_no_link_t.Link = fail
inlines_no_link = Ct(inlines_no_link_t)
+ local inlines_no_inline_note_t = util.table_copy(inlines_t)
+ inlines_no_inline_note_t.InlineNote = fail
+ inlines_no_inline_note = Ct(inlines_no_inline_note_t)
+
local inlines_nbsp_t = util.table_copy(inlines_t)
inlines_nbsp_t.Endline = NonbreakingEndline
inlines_nbsp_t.Space = NonbreakingSpace
@@ -3539,6 +3576,9 @@ return M
\ifx\markdownOptionHybrid\undefined\else
hybrid = \markdownOptionHybrid,
\fi
+\ifx\markdownOptionInlineFootnotes\undefined\else
+ inlineFootnotes = \markdownOptionInlineFootnotes,
+\fi
\ifx\markdownOptionPreserveTabs\undefined\else
preserveTabs = \markdownOptionPreserveTabs,
\fi