summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-01-30 21:14:20 +0000
committerKarl Berry <karl@freefriends.org>2022-01-30 21:14:20 +0000
commitd88c12c479ddbadc494d4967e6c4777f1afeb537 (patch)
tree6392333f6f77518cfb8a6b4f71116138225703da /Master/texmf-dist/tex
parent88ea99da9ff53c27e892b7524db90febe4a28b22 (diff)
markdown (30jan22)
git-svn-id: svn://tug.org/texlive/trunk@61807 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/generic/markdown/markdown.tex10
-rw-r--r--Master/texmf-dist/tex/latex/markdown/markdown.sty28
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua104
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown.lua12
4 files changed, 105 insertions, 49 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex
index a9568c2ad7b..1586d5579a7 100644
--- a/Master/texmf-dist/tex/generic/markdown/markdown.tex
+++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex
@@ -45,8 +45,8 @@
%%
%% The names of the source files used are shown above.
%%
-\def\markdownLastModified{2021/12/30}%
-\def\markdownVersion{2.12.0-1-g976f074}%
+\def\markdownLastModified{2022/01/30}%
+\def\markdownVersion{2.13.0-0-g1f680a8}%
\let\markdownBegin\relax
\let\markdownEnd\relax
\let\markdownInput\relax
@@ -95,6 +95,10 @@
\markdownRendererHalfTickedBoxPrototype}%
\def\markdownRendererUntickedBox{%
\markdownRendererUntickedBoxPrototype}%
+\def\markdownRendererDocumentBegin{%
+ \markdownRendererDocumentBeginPrototype}%
+\def\markdownRendererDocumentEnd{%
+ \markdownRendererDocumentEndPrototype}%
\def\markdownRendererInterblockSeparator{%
\markdownRendererInterblockSeparatorPrototype}%
\def\markdownRendererLineBreak{%
@@ -235,6 +239,8 @@
\markdownRendererTablePrototype}%
\def\markdownRendererInlineHtmlComment{%
\markdownRendererInlineHtmlCommentPrototype}%
+\def\markdownRendererDocumentBeginPrototype{}%
+\def\markdownRendererDocumentEndPrototype{}%
\def\markdownRendererInterblockSeparatorPrototype{}%
\def\markdownRendererLineBreakPrototype{}%
\def\markdownRendererEllipsisPrototype{}%
diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty
index b1d229209ae..7ddde4014b1 100644
--- a/Master/texmf-dist/tex/latex/markdown/markdown.sty
+++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty
@@ -188,6 +188,10 @@
\DeclareOption{frozencache}{\markdownSetup{frozenCache}}
\define@key{markdownOptions}{frozenCacheFileName}{%
\def\markdownOptionFrozenCacheFileName{#1}}%
+\define@key{markdownRenderers}{documentBegin}{%
+ \renewcommand\markdownRendererDocumentBegin{#1}}%
+\define@key{markdownRenderers}{documentEnd}{%
+ \renewcommand\markdownRendererDocumentEnd{#1}}%
\define@key{markdownRenderers}{interblockSeparator}{%
\renewcommand\markdownRendererInterblockSeparator{#1}}%
\define@key{markdownRenderers}{lineBreak}{%
@@ -334,6 +338,10 @@
\renewcommand\markdownRendererHalfTickedBox{#1}}%
\define@key{markdownRenderers}{untickedBox}{%
\renewcommand\markdownRendererUntickedBox{#1}}%
+\define@key{markdownRendererPrototypes}{documentBegin}{%
+ \renewcommand\markdownRendererDocumentBeginPrototype{#1}}%
+\define@key{markdownRendererPrototypes}{documentEnd}{%
+ \renewcommand\markdownRendererDocumentEndPrototype{#1}}%
\define@key{markdownRendererPrototypes}{interblockSeparator}{%
\renewcommand\markdownRendererInterblockSeparatorPrototype{#1}}%
\define@key{markdownRendererPrototypes}{lineBreak}{%
@@ -543,7 +551,16 @@
dlBeginTight = {\markdownRendererDlBegin},
dlEndTight = {\markdownRendererDlEnd}}}}
\RequirePackage{amsmath}
-\RequirePackage{amssymb}
+\@ifpackageloaded{unicode-math}{
+ \markdownSetup{rendererPrototypes={
+ untickedBox = {$\mdlgwhtsquare$},
+ }}
+}{
+ \RequirePackage{amssymb}
+ \markdownSetup{rendererPrototypes={
+ untickedBox = {$\square$},
+ }}
+}
\RequirePackage{csvsimple}
\RequirePackage{fancyvrb}
\RequirePackage{graphicx}
@@ -557,7 +574,13 @@
backslash = {\textbackslash},
tilde = {\textasciitilde},
pipe = {\textbar},
- codeSpan = {\texttt{#1}},
+ codeSpan = {%
+ \ifmmode
+ \text{#1}%
+ \else
+ \texttt{#1}%
+ \fi
+ },
contentBlock = {%
\ifthenelse{\equal{#1}{csv}}{%
\begin{table}%
@@ -600,7 +623,6 @@
emphasis = {\emph{#1}},
tickedBox = {$\boxtimes$},
halfTickedBox = {$\boxdot$},
- untickedBox = {$\square$},
blockQuoteBegin = {\begin{quotation}},
blockQuoteEnd = {\end{quotation}},
inputVerbatim = {\VerbatimInput{#1}},
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua b/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua
index f921ac45716..7a57ef2422d 100644
--- a/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua
+++ b/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua
@@ -32,6 +32,7 @@ local sfind, smatch = string.find, string.match
local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
local setmetatable = setmetatable
local pairs = pairs
+local rawget = rawget
local type = type
local tonumber = tonumber
local math = math
@@ -167,11 +168,15 @@ local function countindent(line)
return j, ssub(line, j+1)
end
-local function parsestring(line, stopper)
+local Parser = {
+ timestamps=true,-- parse timestamps as objects instead of strings
+}
+
+function Parser:parsestring(line, stopper)
stopper = stopper or ''
local q = ssub(line, 1, 1)
if q == ' ' or q == '\t' then
- return parsestring(ssub(line, 2))
+ return self:parsestring(ssub(line, 2))
end
if q == "'" then
local i = sfind(line, "'", 2, true)
@@ -220,6 +225,11 @@ local function parsestring(line, stopper)
return nil, line
end
end
+
+ if line == "*" then
+ error("did not find expected alphabetic or numeric character")
+ end
+
local buf = ''
while #line > 0 do
local c = ssub(line, 1, 1)
@@ -269,10 +279,10 @@ local function compactifyemptylines(lines)
end
local function checkdupekey(map, key)
- if map[key] ~= nil then
+ if rawget(map, key) ~= nil then
-- print("found a duplicate key '"..key.."' in line: "..line)
local suffix = 1
- while map[key..'_'..suffix] do
+ while rawget(map, key..'_'..suffix) do
suffix = suffix + 1
end
key = key ..'_'..suffix
@@ -280,7 +290,8 @@ local function checkdupekey(map, key)
return key
end
-local function parseflowstyle(line, lines)
+
+function Parser:parseflowstyle(line, lines)
local stack = {}
while true do
if #line == 0 then
@@ -335,7 +346,7 @@ local function parseflowstyle(line, lines)
line = ','..line
end
else
- local s, rest = parsestring(line, ',{}[]')
+ local s, rest = self:parsestring(line, ',{}[]')
if not s then
error('invalid flowstyle line: '..line)
end
@@ -346,7 +357,7 @@ local function parseflowstyle(line, lines)
return stack[1].v, line
end
-local function parseblockstylestring(line, lines, indent)
+function Parser:parseblockstylestring(line, lines, indent)
if #lines == 0 then
error("failed to find multi-line scalar content")
end
@@ -402,6 +413,11 @@ local function parseblockstylestring(line, lines, indent)
else
error('invalid blockstyle string:'..line)
end
+
+ if #s == 0 then
+ return ""
+ end
+
local _, eonl = s[#s]:gsub('\n', '\n')
s[#s] = rtrim(s[#s])
if striptrailing then
@@ -416,7 +432,7 @@ local function parseblockstylestring(line, lines, indent)
return tconcat(s, sep)..string.rep('\n', eonl)
end
-local function parsetimestamp(line)
+function Parser:parsetimestamp(line)
local _, p1, y, m, d = sfind(line, '^(%d%d%d%d)%-(%d%d)%-(%d%d)')
if not p1 then
return nil, line
@@ -455,7 +471,7 @@ local function parsetimestamp(line)
return types.timestamp(y, m, d, h, i, s, f, z), ssub(line, p4+1)
end
-local function parsescalar(line, lines, indent)
+function Parser:parsescalar(line, lines, indent)
line = trim(line)
line = gsub(line, '^%s*#.*$', '') -- comment only -> ''
line = gsub(line, '^%s*', '') -- trim head spaces
@@ -464,12 +480,14 @@ local function parsescalar(line, lines, indent)
return null
end
- local ts, _ = parsetimestamp(line)
- if ts then
- return ts
+ if self.timestamps then
+ local ts, _ = self:parsetimestamp(line)
+ if ts then
+ return ts
+ end
end
- local s, _ = parsestring(line)
+ local s, _ = self:parsestring(line)
-- startswith quote ... string
-- not startswith quote ... maybe string
if s and (startswith(line, '"') or startswith(line, "'")) then
@@ -488,11 +506,11 @@ local function parsescalar(line, lines, indent)
end
if startswith(line, '{') or startswith(line, '[') then
- return parseflowstyle(line, lines)
+ return self:parseflowstyle(line, lines)
end
if startswith(line, '|') or startswith(line, '>') then
- return parseblockstylestring(line, lines, indent)
+ return self:parseblockstylestring(line, lines, indent)
end
-- Regular unquoted string
@@ -520,9 +538,7 @@ local function parsescalar(line, lines, indent)
return s or v
end
-local parsemap; -- : func
-
-local function parseseq(line, lines, indent)
+function Parser:parseseq(line, lines, indent)
local seq = setmetatable({}, types.seq)
if line ~= '' then
error()
@@ -576,12 +592,12 @@ local function parseseq(line, lines, indent)
-- - foo:bar
local indent2 = j
lines[1] = string.rep(' ', indent2)..rest
- tinsert(seq, parsemap('', lines, indent2))
+ tinsert(seq, self:parsemap('', lines, indent2))
elseif sfind(rest, '^%-%s+') then
-- Inline nested seq
local indent2 = j
lines[1] = string.rep(' ', indent2)..rest
- tinsert(seq, parseseq('', lines, indent2))
+ tinsert(seq, self:parseseq('', lines, indent2))
elseif isemptyline(rest) then
tremove(lines, 1)
if #lines == 0 then
@@ -595,25 +611,27 @@ local function parseseq(line, lines, indent)
-- Null seqay entry
tinsert(seq, null)
else
- tinsert(seq, parseseq('', lines, indent2))
+ tinsert(seq, self:parseseq('', lines, indent2))
end
else
-- - # comment
-- key: value
local nextline = lines[1]
local indent2 = countindent(nextline)
- tinsert(seq, parsemap('', lines, indent2))
+ tinsert(seq, self:parsemap('', lines, indent2))
end
+ elseif line == "*" then
+ error("did not find expected alphabetic or numeric character")
elseif rest then
-- Array entry with a value
tremove(lines, 1)
- tinsert(seq, parsescalar(rest, lines))
+ tinsert(seq, self:parsescalar(rest, lines))
end
end
return seq
end
-local function parseset(line, lines, indent)
+function Parser:parseset(line, lines, indent)
if not isemptyline(line) then
error('not seq line: '..line)
end
@@ -649,7 +667,7 @@ local function parseset(line, lines, indent)
-- Inline nested hash
local indent2 = j
lines[1] = string.rep(' ', indent2)..rest
- set[parsemap('', lines, indent2)] = true
+ set[self:parsemap('', lines, indent2)] = true
elseif sfind(rest, '^%s+$') then
tremove(lines, 1)
if #lines == 0 then
@@ -662,13 +680,13 @@ local function parseset(line, lines, indent)
-- Null array entry
set[null] = true
else
- set[parseseq('', lines, indent2)] = true
+ set[self:parseseq('', lines, indent2)] = true
end
end
elseif rest then
tremove(lines, 1)
- set[parsescalar(rest, lines)] = true
+ set[self:parsescalar(rest, lines)] = true
else
error("failed to classify line: "..line)
end
@@ -676,7 +694,7 @@ local function parseset(line, lines, indent)
return set
end
-function parsemap(line, lines, indent)
+function Parser:parsemap(line, lines, indent)
if not isemptyline(line) then
error('not map line: '..line)
end
@@ -701,11 +719,11 @@ function parsemap(line, lines, indent)
-- Find the key
local key
- local s, rest = parsestring(line)
+ local s, rest = self:parsestring(line)
-- Quoted keys
if s and startswith(rest, ':') then
- local sc = parsescalar(s, {}, 0)
+ local sc = self:parsescalar(s, {}, 0)
if sc and type(sc) ~= 'string' then
key = sc
else
@@ -729,7 +747,7 @@ function parsemap(line, lines, indent)
if not isemptyline(line) then
tremove(lines, 1)
line = ltrim(line)
- map[key] = parsescalar(line, lines, indent)
+ map[key] = self:parsescalar(line, lines, indent)
else
-- An indent
tremove(lines, 1)
@@ -739,17 +757,17 @@ function parsemap(line, lines, indent)
end
if sfind(lines[1], '^%s*%-') then
local indent2 = countindent(lines[1])
- map[key] = parseseq('', lines, indent2)
+ map[key] = self:parseseq('', lines, indent2)
elseif sfind(lines[1], '^%s*%?') then
local indent2 = countindent(lines[1])
- map[key] = parseset('', lines, indent2)
+ map[key] = self:parseset('', lines, indent2)
else
local indent2 = countindent(lines[1])
if indent >= indent2 then
-- Null hash entry
map[key] = null
else
- map[key] = parsemap('', lines, indent2)
+ map[key] = self:parsemap('', lines, indent2)
end
end
end
@@ -759,7 +777,7 @@ end
-- : (list<str>)->dict
-local function parsedocuments(lines)
+function Parser:parsedocuments(lines)
lines = compactifyemptylines(lines)
if sfind(lines[1], '^%%YAML') then tremove(lines, 1) end
@@ -779,7 +797,7 @@ local function parsedocuments(lines)
if docright then
if (not sfind(docright, '^%s+$') and
not sfind(docright, '^%s+#')) then
- tinsert(root, parsescalar(docright, lines))
+ tinsert(root, self:parsescalar(docright, lines))
end
elseif #lines == 0 or startswith(line, '---') then
-- A naked document
@@ -795,11 +813,11 @@ local function parsedocuments(lines)
error('parse error: '..line)
elseif sfind(line, '^%s*%-') then
-- An array at the root
- tinsert(root, parseseq('', lines, 0))
+ tinsert(root, self:parseseq('', lines, 0))
elseif sfind(line, '^%s*[^%s]') then
-- A hash at the root
local level = countindent(line)
- tinsert(root, parsemap('', lines, level))
+ tinsert(root, self:parsemap('', lines, level))
else
-- Shouldn't get here. @lines have whitespace-only lines
-- stripped, and previous match is a line with any
@@ -818,13 +836,13 @@ local function parsedocuments(lines)
end
--- Parse yaml string into table.
-local function parse(source)
+function Parser:parse(source)
local lines = {}
for line in string.gmatch(source .. '\n', '(.-)\r?\n') do
tinsert(lines, line)
end
- local docs = parsedocuments(lines)
+ local docs = self:parsedocuments(lines)
if #docs == 1 then
return docs[1]
end
@@ -832,6 +850,12 @@ local function parse(source)
return docs
end
+local function parse(source, options)
+ local options = options or {}
+ local parser = setmetatable (options, {__index=Parser})
+ return parser:parse(source)
+end
+
return {
version = 0.1,
parse = parse,
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua
index 4241d6cc3b9..aac73da3c9f 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.12.0-1-g976f074",
+ version = "2.13.0-0-g1f680a8",
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",
@@ -2343,7 +2343,6 @@ function M.writer.new(options)
if not self.is_writing then return "" end
return "\\markdownRendererInterblockSeparator\n{}"
end
- self.eof = [[\relax]]
self.linebreak = "\\markdownRendererLineBreak\n{}"
self.ellipsis = "\\markdownRendererEllipsis{}"
function self.hrule()
@@ -2593,6 +2592,10 @@ function M.writer.new(options)
local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim")
return {"\\markdownRendererInputFencedCode{",name,"}{",i,"}"}
end
+ function self.document(d)
+ return {"\\markdownRendererDocumentBegin\n", d,
+ "\\markdownRendererDocumentEnd"}
+ end
function self.jekyllData(d, t, p)
if not self.is_writing then return "" end
@@ -3933,7 +3936,7 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline
* (P("---") + P("..."))
/ function(text)
local tinyyaml = require("markdown-tinyyaml")
- data = tinyyaml.parse(text)
+ data = tinyyaml.parse(text,{timestamps=false})
return writer.jekyllData(data, function(s)
return parse_blocks(s)
end, nil)
@@ -4317,7 +4320,8 @@ larsers.PipeTable = Ct(larsers.table_row * parsers.newline
local salt = table.concat(opt_string, ",") .. "," .. metadata.version
local output
local function convert(input)
- return util.rope_to_string(parse_blocks_toplevel(input)) .. writer.eof
+ local document = parse_blocks_toplevel(input)
+ return util.rope_to_string(writer.document(document))
end
if options.eagerCache or options.finalizeCache then
local name = util.cache(options.cacheDir, input, salt, convert, ".md" .. writer.suffix)