summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/markdown/markdown.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-09-06 21:30:37 +0000
committerKarl Berry <karl@freefriends.org>2016-09-06 21:30:37 +0000
commitb17c2558bca9c4b79e1b9352a7cee8c940542e1b (patch)
treee4e3fb16c5a40c5702fd85af92da59157d791948 /Master/texmf-dist/tex/luatex/markdown/markdown.lua
parent3a322c171ab33afe5d5481ca124f9c2b3d3e1fc9 (diff)
markdown (6sep16)
git-svn-id: svn://tug.org/texlive/trunk@42000 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/markdown/markdown.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown.lua44
1 files changed, 29 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua
index 6a194bbf7ea..c62b5ed8b95 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.0",
+ version = "2.1.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ý",
@@ -459,6 +459,7 @@ function M.reader.new(writer, options)
function() return inlines_nbsp end)
local percent = P("%")
local at = P("@")
+ local comma = P(",")
local asterisk = P("*")
local dash = P("-")
local plus = P("+")
@@ -489,7 +490,7 @@ function M.reader.new(writer, options)
local letter = R("AZ","az")
local alphanumeric = R("AZ","az","09")
local keyword = letter * alphanumeric^0
- local punctuation = S("!?,.:;")
+ local internal_punctuation = S(":;,.#$%&-+?<>~/")
local doubleasterisks = P("**")
local doubleunderscores = P("__")
@@ -516,9 +517,6 @@ function M.reader.new(writer, options)
local normalchar = any -
(specialchar + spacing + tightblocksep)
local optionalspace = spacechar^0
- local optionalspaceor = function(pattern)
- return (spacechar + pattern)^0
- end
local eof = - any
local nonindentspace = space^-3 * - spacechar
local indent = space^-3 * tab
@@ -532,10 +530,6 @@ function M.reader.new(writer, options)
local optionallyindentedline = indent^-1 /"" * C(linechar^1 * newline^-1)
local sp = spacing^0
local spnl = optionalspace * (newline * optionalspace)^-1
- local spnlor = function(pattern)
- local optional = optionalspaceor(pattern)
- return optional * (newline * optional)^-1
- end
local line = linechar^0 * newline
+ linechar^1 * eof
local nonemptyline = line - blankline
@@ -663,16 +657,17 @@ function M.reader.new(writer, options)
local optionaltitle = spnl * title * spacechar^0
+ Cc("")
- local citation_name = (Cs(dash^-1)
- * at * Cs((anyescaped
- - (rbracket + spacing + punctuation + semicolon))^1))
+ local citation_name = Cs(dash^-1) * at
+ * Cs(alphanumeric
+ * (alphanumeric + internal_punctuation
+ - comma - semicolon)^0)
local citation_body_prenote
= Cs((alphanumeric^1
+ bracketed
+ inticks
+ (anyescaped
- - (rbracket + semicolon + blankline^2))
+ - (rbracket + blankline^2))
- (spnl * dash^-1 * at))^0)
local citation_body_postnote
@@ -686,14 +681,22 @@ function M.reader.new(writer, options)
local citation_body_chunk
= citation_body_prenote
* spnl * citation_name
- * spnlor(punctuation - (semicolon + rbracket))
+ * (comma * spnl)^-1
* citation_body_postnote
local citation_body = citation_body_chunk
* (semicolon * spnl * citation_body_chunk)^0
+ local citation_headless_body_postnote
+ = Cs((alphanumeric^1
+ + bracketed
+ + inticks
+ + (anyescaped
+ - (rbracket + at + semicolon + blankline^2))
+ - (spnl * rbracket))^0)
+
local citation_headless_body
- = citation_body_postnote
+ = citation_headless_body_postnote
* (sp * semicolon * spnl * citation_body_chunk)^0
local rawnotes = {}
@@ -830,6 +833,16 @@ function M.reader.new(writer, options)
+ spacechar^1 * Endline^-1 * eof / ""
+ spacechar^1 * Endline^-1 * optionalspace / writer.space
+ local NonbreakingEndline
+ = newline * -( -- newline, but not before...
+ blankline -- paragraph break
+ + tightblocksep -- nested list
+ + eof -- end of document
+ + bqstart
+ + headerstart
+ + fencestart
+ ) * spacechar^0 / writer.nbsp
+
local NonbreakingSpace
= spacechar^2 * Endline / writer.linebreak
+ spacechar^1 * Endline^-1 * eof / ""
@@ -1214,6 +1227,7 @@ function M.reader.new(writer, options)
inlines_no_link = Ct(inlines_no_link_t)
local inlines_nbsp_t = util.table_copy(inlines_t)
+ inlines_nbsp_t.Endline = NonbreakingEndline
inlines_nbsp_t.Space = NonbreakingSpace
inlines_nbsp = Ct(inlines_nbsp_t)
function self.convert(input)