diff options
author | Karl Berry <karl@freefriends.org> | 2023-04-27 20:37:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-04-27 20:37:52 +0000 |
commit | fd9564b21054e27d1e4f4bfcca7683ae3b84e2fb (patch) | |
tree | f98ea8c61cbdc8546aabe2957323aca8776c3bca /Master/texmf-dist/tex | |
parent | eaf38b0e316452820428aaa331b98c6b2c9d8edf (diff) |
markdown (27apr23)
git-svn-id: svn://tug.org/texlive/trunk@66954 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
4 files changed, 314 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex index 0d71a2f98e3..8ad545ea609 100644 --- a/Master/texmf-dist/tex/generic/markdown/markdown.tex +++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex @@ -107,7 +107,7 @@ } { \msg_error:nnnV - { __markdown } + { markdown } { failed-typecheck-for-boolean-option } { #1 } \l_tmpa_tl @@ -116,7 +116,7 @@ } } \msg_new:nnn - { __markdown } + { markdown } { failed-typecheck-for-boolean-option } { Option~#1~has~value~#2,~ @@ -165,7 +165,7 @@ \l_tmpa_bool { \msg_error:nnn - { __markdown } + { markdown } { undefined-option } { #1 } } @@ -174,7 +174,7 @@ \l_tmpa_tl { \msg_error:nnnV - { __markdown } + { markdown } { unknown-option-type } { #1 } \l_tmpa_tl @@ -184,13 +184,13 @@ \l_tmpa_tl } \msg_new:nnn - { __markdown } + { markdown } { unknown-option-type } { Option~#1~has~unknown~type~#2. } \msg_new:nnn - { __markdown } + { markdown } { undefined-option } { Option~#1~is~undefined. @@ -217,7 +217,7 @@ \l_tmpa_bool { \msg_error:nnn - { __markdown } + { markdown } { undefined-option } { #1 } } @@ -273,7 +273,6 @@ \tl_tail:n { #1 } } } -\seq_new:N \g__markdown_cases_seq \cs_new:Nn \__markdown_with_various_cases:nn { \seq_clear:N @@ -294,6 +293,11 @@ \l_tmpa_seq { #2 } } +\cs_new:Nn \__markdown_with_various_cases_break: + { + \seq_map_break: + } +\seq_new:N \g__markdown_cases_seq \cs_new:Nn \__markdown_camel_case:N { \regex_replace_all:nnN @@ -552,8 +556,8 @@ { boolean } { true } \ExplSyntaxOff -\def\markdownLastModified{2023-04-02}% -\def\markdownVersion{2.22.0-0-g5a3d0fe}% +\def\markdownLastModified{2023-04-27}% +\def\markdownVersion{2.23.0-0-g0b22f91}% \let\markdownBegin\relax \let\markdownEnd\relax \let\markdownInput\relax @@ -2547,8 +2551,9 @@ local convert = md.new(\markdownLuaOptions) }% \ExplSyntaxOn -\cs_new:Nn - \__markdown_if_option:nTF +\prg_new_conditional:Nnn + \__markdown_if_option:n + { TF, T, F } { \__markdown_get_option_type:nN { #1 } @@ -2558,7 +2563,7 @@ \c__markdown_option_type_boolean_tl { \msg_error:nnxx - { __markdown } + { markdown } { expected-boolean-option } { #1 } { \l_tmpa_tl } @@ -2569,11 +2574,11 @@ \str_if_eq:NNTF \l_tmpa_tl \c__markdown_option_value_true_tl - { #2 } - { #3 } + { \prg_return_true: } + { \prg_return_false: } } \msg_new:nnn - { __markdown } + { markdown } { expected-boolean-option } { Option~#1~has~type~#2,~ diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index c887db1c16a..661ea377553 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -318,7 +318,7 @@ { s } { \msg_error:nnn - { __markdown } + { markdown } { malformed-name-for-clist-option } { #3 } } @@ -364,7 +364,7 @@ { en } { F } \msg_new:nnn - { __markdown } + { markdown } { malformed-name-for-clist-option } { Clist~option~name~#1~does~not~end~with~-s. @@ -430,6 +430,103 @@ { ncV } \ExplSyntaxOff \ExplSyntaxOn +\tl_new:N + \l__markdown_renderer_definition_tl +\keys_define:nn + { markdown/latex-options/renderers } + { + unknown .code:n = { + \regex_match:nVTF + { \* } + \l_keys_key_str + { + \tl_set:Nn + \l__markdown_renderer_definition_tl + { #1 } + \tl_set:NV + \l_tmpa_tl + \l_keys_key_str + \regex_replace_all:nnN + { \* } + { .* } + \l_tmpa_tl + \regex_set:NV + \l_tmpa_regex + \l_tmpa_tl + \int_zero:N + \l_tmpa_int + \seq_map_inline:Nn + \g__markdown_renderers_seq + { + \__markdown_with_various_cases:nn + { ##1 } + { + \regex_match:NnT + \l_tmpa_regex + { ####1 } + { + \__markdown_renderer_tl_to_csname:nN + { ##1 } + \l_tmpa_tl + \prop_get:NnN + \g__markdown_renderer_arities_prop + { ##1 } + \l_tmpb_tl + \cs_generate_from_arg_count:cNVV + { \l_tmpa_tl } + \cs_set:Npn + \l_tmpb_tl + \l__markdown_renderer_definition_tl + \int_incr:N + \l_tmpa_int + \__markdown_with_various_cases_break: + } + } + } + \int_compare:nNnT + { \l_tmpa_int } = { 0 } + { + \msg_error:nnV + { markdown } + { nonmatched-renderer-wildcard } + \l_keys_key_str + } + } + { + \msg_error:nnV + { markdown } + { undefined-renderer } + \l_keys_key_str + } + }, + } +\msg_new:nnn + { markdown } + { undefined-renderer } + { + Renderer~#1~is~undefined. + } +\msg_new:nnn + { markdown } + { nonmatched-renderer-wildcard } + { + Wildcard~#1~matches~no~renderers. + } +\cs_generate_variant:Nn + \regex_set:Nn + { NV } +\cs_generate_variant:Nn + \cs_generate_from_arg_count:NNnn + { cNVV } +\cs_generate_variant:Nn + \msg_error:nnn + { nnV } +\prg_generate_conditional_variant:Nnn + \regex_match:nn + { nV } + { TF } +\ExplSyntaxOff +\ExplSyntaxOn \cs_new:Nn \__markdown_latex_define_renderer_prototypes: { \seq_map_function:NN @@ -472,6 +569,103 @@ \__markdown_latex_define_renderer_prototype:nNn { ncV } \ExplSyntaxOff +\ExplSyntaxOn +\tl_new:N + \l__markdown_renderer_prototype_definition_tl +\keys_define:nn + { markdown/latex-options/renderer-prototypes } + { + unknown .code:n = { + \regex_match:nVTF + { \* } + \l_keys_key_str + { + \tl_set:Nn + \l__markdown_renderer_prototype_definition_tl + { #1 } + \tl_set:NV + \l_tmpa_tl + \l_keys_key_str + \regex_replace_all:nnN + { \* } + { .* } + \l_tmpa_tl + \regex_set:NV + \l_tmpa_regex + \l_tmpa_tl + \int_zero:N + \l_tmpa_int + \seq_map_inline:Nn + \g__markdown_renderers_seq + { + \__markdown_with_various_cases:nn + { ##1 } + { + \regex_match:NnT + \l_tmpa_regex + { ####1 } + { + \__markdown_renderer_prototype_tl_to_csname:nN + { ##1 } + \l_tmpa_tl + \prop_get:NnN + \g__markdown_renderer_arities_prop + { ##1 } + \l_tmpb_tl + \cs_generate_from_arg_count:cNVV + { \l_tmpa_tl } + \cs_set:Npn + \l_tmpb_tl + \l__markdown_renderer_prototype_definition_tl + \int_incr:N + \l_tmpa_int + \__markdown_with_various_cases_break: + } + } + } + \int_compare:nNnT + { \l_tmpa_int } = { 0 } + { + \msg_error:nnV + { markdown } + { nonmatched-renderer-prototype-wildcard } + \l_keys_key_str + } + } + { + \msg_error:nnV + { markdown } + { undefined-renderer-prototype } + \l_keys_key_str + } + }, + } +\msg_new:nnn + { markdown } + { undefined-renderer-prototype } + { + Renderer~prototype~#1~is~undefined. + } +\msg_new:nnn + { markdown } + { nonmatched-renderer-prototype-wildcard } + { + Wildcard~#1~matches~no~renderer~prototypes. + } +\cs_generate_variant:Nn + \regex_set:Nn + { NV } +\cs_generate_variant:Nn + \cs_generate_from_arg_count:NNnn + { cNVV } +\cs_generate_variant:Nn + \msg_error:nnn + { nnV } +\prg_generate_conditional_variant:Nnn + \regex_match:nn + { nV } + { TF } +\ExplSyntaxOff \def\markdownVersionSpace{ }% \ProvidesPackage{markdown}[\markdownLastModified\markdownVersionSpace v% \markdownVersion\markdownVersionSpace markdown renderer]% @@ -666,8 +860,16 @@ { #2 } } \markdownSetup{rendererPrototypes={ - ulBeginTight = {\begin{compactitem}}, - ulEndTight = {\end{compactitem}}, + ulBeginTight = {% + \group_begin: + \pltopsep=\topsep + \plpartopsep=\partopsep + \begin{compactitem} + }, + ulEndTight = { + \end{compactitem} + \group_end: + }, fancyOlBegin = { \group_begin: \tl_set:Nn @@ -691,8 +893,16 @@ \end{enumerate} \group_end: }, - olBeginTight = {\begin{compactenum}}, - olEndTight = {\end{compactenum}}, + olBeginTight = {% + \group_begin: + \plpartopsep=\partopsep + \pltopsep=\topsep + \begin{compactenum} + }, + olEndTight = { + \end{compactenum} + \group_end: + }, fancyOlBeginTight = { \group_begin: \tl_set:Nn @@ -703,7 +913,11 @@ { #2 } \tl_set:Nn \l_tmpa_tl - { \begin{compactenum}[ } + { + \plpartopsep=\partopsep + \pltopsep=\topsep + \begin{compactenum}[ + } \tl_put_right:Nx \l_tmpa_tl { \__markdown_latex_paralist_style:nn { #1 } { #2 } } @@ -725,8 +939,16 @@ { #1 } ] }, - dlBeginTight = {\begin{compactdesc}}, - dlEndTight = {\end{compactdesc}}}} + dlBeginTight = { + \group_begin: + \plpartopsep=\partopsep + \pltopsep=\topsep + \begin{compactdesc} + }, + dlEndTight = { + \end{compactdesc} + \group_end: + }}} \cs_generate_variant:Nn \__markdown_latex_fancy_list_item_label:nnn { VVn } @@ -1390,7 +1612,7 @@ } }{} \ExplSyntaxOn -\__markdown_if_option:nTF +\__markdown_if_option:nT { linkAttributes } { \RequirePackage{graphicx} @@ -1414,7 +1636,6 @@ }, } } - { } \ExplSyntaxOff \ExplSyntaxOn \cs_gset:Npn diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua b/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua index 7a57ef2422d..074ad79446e 100644 --- a/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua +++ b/Master/texmf-dist/tex/luatex/markdown/markdown-tinyyaml.lua @@ -38,6 +38,8 @@ local tonumber = tonumber local math = math local getmetatable = getmetatable local error = error +local end_symbol = "..." +local end_break_symbol = "...\n" local UNESCAPES = { ['0'] = "\x00", z = "\x00", N = "\x85", @@ -183,7 +185,14 @@ function Parser:parsestring(line, stopper) if not i then return nil, line end - return ssub(line, 2, i-1), ssub(line, i+1) + -- Unescape repeated single quotes. + while i < #line and ssub(line, i+1, i+1) == "'" do + i = sfind(line, "'", i + 2, true) + if not i then + return nil, line + end + end + return ssub(line, 2, i-1):gsub("''", "'"), ssub(line, i+1) end if q == '"' then local i, buf = 2, '' @@ -702,6 +711,13 @@ function Parser:parsemap(line, lines, indent) while #lines > 0 do -- Check for a new document line = lines[1] + if line == end_symbol or line == end_break_symbol then + for i, _ in ipairs(lines) do + lines[i] = nil + end + return map + end + if startswith(line, '---') then while #lines > 0 and not startswith(lines, '---') do tremove(lines, 1) diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index 1e68b8ae84f..225428abe03 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.22.0-0-g5a3d0fe", + version = "2.23.0-0-g0b22f91", 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", @@ -2503,7 +2503,7 @@ function M.writer.new(options) {"\\markdownRendererCodeSpan{", self.escape(s), "}"}) if attributes ~= nil then table.insert(buf, - "\n\\markdownRendererCodeSpanAttributeContextEnd ") + "\\markdownRendererCodeSpanAttributeContextEnd{}") end return buf end @@ -2520,7 +2520,7 @@ function M.writer.new(options) "{",self.string(tit or ""),"}"}) if attributes ~= nil then table.insert(buf, - "\n\\markdownRendererLinkAttributeContextEnd ") + "\\markdownRendererLinkAttributeContextEnd{}") end return buf end @@ -2537,7 +2537,7 @@ function M.writer.new(options) "{",self.string(tit or ""),"}"}) if attributes ~= nil then table.insert(buf, - "\n\\markdownRendererImageAttributeContextEnd ") + "\\markdownRendererImageAttributeContextEnd{}") end return buf end @@ -2640,26 +2640,49 @@ function M.writer.new(options) return buf end - function self.attributes(attr) - local buf = {} + function self.attributes(attributes) + local expanded_attributes = {} + local key_value_regex = "([^= ]+)%s*=%s*(.*)" + local key, value + for _, attribute in ipairs(attributes) do + if attribute:sub(1, 1) == "#" or attribute:sub(1, 1) == "." then + table.insert(expanded_attributes, attribute) + else + key, value = attribute:match(key_value_regex) + if key:lower() == "id" then + table.insert(expanded_attributes, "#" .. value) + elseif key:lower() == "class" then + local classes = {} + for class in value:gmatch("%S+") do + table.insert(classes, class) + end + table.sort(classes) + for _, class in ipairs(classes) do + table.insert(expanded_attributes, "." .. class) + end + else + table.insert(expanded_attributes, attribute) + end + end + end + table.sort(expanded_attributes) - table.sort(attr) + local buf = {} local seen = {} - local key, value - for i = 1, #attr do - if seen[attr[i]] ~= nil then + for _, attribute in ipairs(expanded_attributes) do + if seen[attribute] ~= nil then goto continue -- prevent duplicate attributes else - seen[attr[i]] = true + seen[attribute] = true end - if attr[i]:sub(1, 1) == "#" then + if attribute:sub(1, 1) == "#" then table.insert(buf, {"\\markdownRendererAttributeIdentifier{", - attr[i]:sub(2), "}"}) - elseif attr[i]:sub(1, 1) == "." then + attribute:sub(2), "}"}) + elseif attribute:sub(1, 1) == "." then table.insert(buf, {"\\markdownRendererAttributeClassName{", - attr[i]:sub(2), "}"}) + attribute:sub(2), "}"}) else - key, value = attr[i]:match("([^= ]+)%s*=%s*(.*)") + key, value = attribute:match(key_value_regex) table.insert(buf, {"\\markdownRendererAttributeKeyValue{", key, "}{", value, "}"}) end @@ -2971,13 +2994,16 @@ parsers.commented_line = Cg(Cc(""), "backslashes") parsers.chunk = parsers.line * (parsers.optionallyindentedline - parsers.blankline)^0 -parsers.attribute_key_char = parsers.alphanumeric + S("_-") +parsers.attribute_key_char = parsers.alphanumeric + S("-_:.") parsers.attribute_key = (parsers.attribute_key_char - parsers.dash - parsers.digit) * parsers.attribute_key_char^0 parsers.attribute_value = ( (parsers.dquote / "") * (parsers.anyescaped - parsers.dquote)^0 * (parsers.dquote / "")) + + ( (parsers.squote / "") + * (parsers.anyescaped - parsers.squote)^0 + * (parsers.squote / "")) + ( parsers.anyescaped - parsers.dquote - parsers.rbrace - parsers.space)^0 @@ -5652,6 +5678,7 @@ M.extensions.jekyll_data = function(expect_jekyll_data) , function(s, i, text) -- luacheck: ignore s i local data local ran_ok, _ = pcall(function() + -- TODO: Replace with `require("tinyyaml")` in TeX Live 2023 local tinyyaml = require("markdown-tinyyaml") data = tinyyaml.parse(text, {timestamps=false}) end) |