summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/markdown
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-05-28 19:27:46 +0000
committerKarl Berry <karl@freefriends.org>2024-05-28 19:27:46 +0000
commit64304ec2dbfd8f37ddb60de7807cc0d87ba6ce1f (patch)
treeb2289448adb054e2be5f236fc8d6414ff52054ad /Master/texmf-dist/tex/luatex/markdown
parent38bc6dbea6a969856de132f557a281abd09cd9e1 (diff)
markdown (28may24)
git-svn-id: svn://tug.org/texlive/trunk@71378 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/markdown')
-rw-r--r--Master/texmf-dist/tex/luatex/markdown/markdown.lua53
1 files changed, 47 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua
index e65712cdcb6..d3711c4f243 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 = "3.5.0-0-gfd01a252",
+ version = "3.6.0-0-g83c781b4",
comment = "A module for the conversion from markdown to plain TeX",
author = "John MacFarlane, Hans Hagen, Vít Starý Novotný",
copyright = {"2009-2016 John MacFarlane, Hans Hagen",
@@ -120,6 +120,8 @@ local singletonCache = {
convert = nil,
options = nil,
}
+defaultOptions.unicodeNormalization = true
+defaultOptions.unicodeNormalizationForm = "nfc"
defaultOptions.cacheDir = "."
defaultOptions.contentBlocksLanguageMap = "markdown-languages.json"
defaultOptions.debugExtensionsFileName = "debug-extensions.json"
@@ -2971,8 +2973,12 @@ function M.writer.new(options)
local buffer = {}
local prev_space = false
local letter_found = false
+ local normalized_s = s
+ if not options.unicodeNormalization or options.unicodeNormalizationForm ~= "nfc" then
+ normalized_s = uni_algos.normalize.NFC(normalized_s)
+ end
- for _, code in utf8.codes(uni_algos.normalize.NFC(s)) do
+ for _, code in utf8.codes(normalized_s) do
local char = utf8.char(code)
-- Remove everything up to the first letter.
@@ -3020,8 +3026,12 @@ function M.writer.new(options)
local buffer = {}
local prev_space = false
local letter_found = false
+ local normalized_s = s
+ if not options.unicodeNormalization or options.unicodeNormalizationForm ~= "nfc" then
+ normalized_s = uni_algos.normalize.NFC(normalized_s)
+ end
- for _, code in utf8.codes(uni_algos.normalize.NFC(s)) do
+ for _, code in utf8.codes(normalized_s) do
local char = utf8.char(code)
-- Remove everything up to the first non-space.
@@ -6164,6 +6174,20 @@ end
inlines_no_link_or_emphasis_t.EndlineExceptions = parsers.EndlineExceptions - parsers.eof
parsers.inlines_no_link_or_emphasis = Ct(inlines_no_link_or_emphasis_t)
return function(input)
+ if options.unicodeNormalization then
+ local form = options.unicodeNormalizationForm
+ if form == "nfc" then
+ input = uni_algos.normalize.NFC(input)
+ elseif form == "nfd" then
+ input = uni_algos.normalize.NFD(input)
+ elseif form == "nfkc" then
+ input = uni_algos.normalize.NFKC(input)
+ elseif form == "nfkd" then
+ input = uni_algos.normalize.NFKD(input)
+ else
+ error(format("Unknown normalization form %s", form))
+ end
+ end
input = input:gsub("\r\n?", "\n")
if input:sub(-1) ~= "\n" then
input = input .. "\n"
@@ -8004,13 +8028,30 @@ M.extensions.jekyll_data = function(expect_jekyll_data)
for k, _ in pairs(d) do
table.insert(keys, k)
end
- table.sort(keys)
+ table.sort(keys, function(first, second)
+ if type(first) ~= type(second) then
+ return type(first) < type(second)
+ else
+ return first < second
+ end
+ end)
if not p then
table.insert(buf, "\\markdownRendererJekyllDataBegin")
end
- if #d > 0 then
+ local is_sequence = false
+ if #d > 0 and #d == #keys then
+ for i=1, #d do
+ if d[i] == nil then
+ goto not_a_sequence
+ end
+ end
+ is_sequence = true
+ end
+ ::not_a_sequence::
+
+ if is_sequence then
table.insert(buf, "\\markdownRendererJekyllDataSequenceBegin{")
table.insert(buf, self.identifier(p or "null"))
table.insert(buf, "}{")
@@ -8065,7 +8106,7 @@ M.extensions.jekyll_data = function(expect_jekyll_data)
end
end
- if #d > 0 then
+ if is_sequence then
table.insert(buf, "\\markdownRendererJekyllDataSequenceEnd")
else
table.insert(buf, "\\markdownRendererJekyllDataMappingEnd")