summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/markdown
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-08-15 20:33:02 +0000
committerKarl Berry <karl@freefriends.org>2016-08-15 20:33:02 +0000
commit1850016c7aa713d8e5b7e6ac583199a938407287 (patch)
tree5d19cb8b694fbffc7b7606bfe1c1f98b764d5d08 /Master/texmf-dist/tex/luatex/markdown
parentc412591dd67ff53334e28fc8f17cc9593a5d5f59 (diff)
markdown (16aug16)
git-svn-id: svn://tug.org/texlive/trunk@41855 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/markdown')
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown.lua66
1 files changed, 41 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua
index e740d18c92e..8a0f237c1d7 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.
--
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 lpeg = require("lpeg")
local unicode = require("unicode")
local md5 = require("md5")
local M = {}
-M.new = {}
local defaultOptions = {}
defaultOptions.blankBeforeBlockquote = false
defaultOptions.blankBeforeHeading = false
@@ -238,23 +237,34 @@ function M.writer.new(options)
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 M.writer.new(options)
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 @@ function M.writer.new(options)
"\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 @@ function M.reader.new(writer, options)
local fail = any - 1
local always = P("")
- local escapable = S("\\`*_{}[]()+_.!#-~:^")
+ local escapable = S("\\`*_{}[]()+_.!<>#-~:^")
local anyescaped = P("\\") / "" * escapable
+ any
@@ -480,9 +496,9 @@ function M.reader.new(writer, options)
local specialchar
if options.smartEllipses then
- specialchar = S("*_`&[]!\\.")
+ specialchar = S("*_`&[]<!\\.")
else
- specialchar = S("*_`&[]!\\")
+ specialchar = S("*_`&[]<!\\")
end
local normalchar = any -
@@ -613,7 +629,7 @@ function M.reader.new(writer, options)
if found then
return writer.note(parse_blocks(found))
else
- return {"[^", ref, "]"}
+ return {"[", parse_inlines("^" .. ref), "]"}
end
end
end