summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-12-08 23:00:36 +0000
committerKarl Berry <karl@freefriends.org>2016-12-08 23:00:36 +0000
commit0289f1e978eb4e6e1c0b025309fdcfe3eb43e5c9 (patch)
treec4684ce2aa25a5d09c0b23e5063c870e9810d417 /Master/texmf-dist/tex/luatex
parent75ab39a4900b7447f06b9e39d9b6480d266fb254 (diff)
markdown (8dec16)
git-svn-id: svn://tug.org/texlive/trunk@42652 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown.lua205
1 files changed, 110 insertions, 95 deletions
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua
index bddbcaa6c07..8b374e3af3b 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.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ý",
@@ -82,6 +82,7 @@ defaultOptions.hashEnumerators = false
defaultOptions.hybrid = false
defaultOptions.fencedCode = false
defaultOptions.footnotes = false
+defaultOptions.inlineFootnotes = false
defaultOptions.preserveTabs = false
defaultOptions.smartEllipses = false
defaultOptions.startNumber = true
@@ -409,6 +410,92 @@ function M.writer.new(options)
return self
end
+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
M.reader = {}
function M.reader.new(writer, options)
local self = {}
@@ -434,7 +521,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)
@@ -455,94 +545,11 @@ 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)
- 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
local bulletchar = C(plus + asterisk + dash)
local bullet = ( Cg(bulletchar, "bulletchar") * #spacing * (tab + space^-3)
@@ -725,14 +732,12 @@ function M.reader.new(writer, options)
local NoteRef = RawNoteRef / lookup_note
- local NoteBlock
+ local NoteBlock = leader * RawNoteRef * colon * spnl
+ * indented_blocks(chunk) / register_note
- if options.footnotes then
- NoteBlock = leader * RawNoteRef * colon * spnl *
- indented_blocks(chunk) / register_note
- else
- NoteBlock = fail
- end
+ local InlineNote = circumflex -- no notes inside notes
+ * (tag / parse_inlines_no_inline_note)
+ / writer.note
-- List of references defined in the document
local references
@@ -1160,6 +1165,7 @@ function M.reader.new(writer, options)
+ V("UlOrStarLine")
+ V("Strong")
+ V("Emph")
+ + V("InlineNote")
+ V("NoteRef")
+ V("Citations")
+ V("Link")
@@ -1177,6 +1183,7 @@ function M.reader.new(writer, options)
UlOrStarLine = UlOrStarLine,
Strong = Strong,
Emph = Emph,
+ InlineNote = InlineNote,
NoteRef = NoteRef,
Citations = Citations,
Link = Link,
@@ -1207,6 +1214,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
@@ -1226,6 +1237,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