texlive[64000] Master/texmf-dist: markdown (28jul22)

commits+karl at tug.org commits+karl at tug.org
Fri Jul 29 23:00:05 CEST 2022


Revision: 64000
          http://tug.org/svn/texlive?view=revision&revision=64000
Author:   karl
Date:     2022-07-29 23:00:05 +0200 (Fri, 29 Jul 2022)
Log Message:
-----------
markdown (28jul22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/generic/markdown/VERSION
    trunk/Master/texmf-dist/doc/generic/markdown/markdown.html
    trunk/Master/texmf-dist/doc/generic/markdown/markdown.pdf
    trunk/Master/texmf-dist/scripts/markdown/markdown-cli.lua
    trunk/Master/texmf-dist/source/generic/markdown/docstrip.cfg
    trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx
    trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex
    trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty
    trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua

Modified: trunk/Master/texmf-dist/doc/generic/markdown/VERSION
===================================================================
--- trunk/Master/texmf-dist/doc/generic/markdown/VERSION	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/doc/generic/markdown/VERSION	2022-07-29 21:00:05 UTC (rev 64000)
@@ -1 +1 @@
-2.15.3-0-g7c8e03d (2022/06/27)
+2.15.4-0-g4cbe4e3 (2022/07/29)

Modified: trunk/Master/texmf-dist/doc/generic/markdown/markdown.html
===================================================================
--- trunk/Master/texmf-dist/doc/generic/markdown/markdown.html	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/doc/generic/markdown/markdown.html	2022-07-29 21:00:05 UTC (rev 64000)
@@ -82,7 +82,7 @@
 <header id="title-block-header">
 <h1 class="title">Markdown Package User Manual</h1>
 <p class="author">Vít Novotný</p>
-<p class="date">2.15.3-0-g7c8e03d (2022/06/27)</p>
+<p class="date">2.15.4-0-g4cbe4e3 (2022/07/29)</p>
 </header>
 <nav id="TOC" role="doc-toc">
 <ul>

Modified: trunk/Master/texmf-dist/doc/generic/markdown/markdown.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/markdown/markdown-cli.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/markdown/markdown-cli.lua	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/scripts/markdown/markdown-cli.lua	2022-07-29 21:00:05 UTC (rev 64000)
@@ -1,6 +1,6 @@
--- 
+--
 -- Copyright (C) 2009-2016 John MacFarlane, Hans Hagen
--- 
+--
 -- Permission is hereby granted, free of charge, to any person obtaining
 -- a copy of this software and associated documentation files (the
 -- "Software"), to deal in the Software without restriction, including
@@ -8,10 +8,10 @@
 -- distribute, sublicense, and/or sell copies of the Software, and to
 -- permit persons to whom the Software is furnished to do so, subject to
 -- the following conditions:
--- 
+--
 -- The above copyright notice and this permission notice shall be included
 -- in all copies or substantial portions of the Software.
--- 
+--
 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19,31 +19,31 @@
 -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- 
+--
 -- Copyright (C) 2016-2022 Vít Novotný
--- 
+--
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3
 -- of this license or (at your option) any later version.
 -- The latest version of this license is in
--- 
+--
 --     http://www.latex-project.org/lppl.txt
--- 
+--
 -- and version 1.3 or later is part of all distributions of LaTeX
 -- version 2005/12/01 or later.
--- 
+--
 -- This work has the LPPL maintenance status `maintained'.
 -- The Current Maintainer of this work is Vít Novotný.
--- 
+--
 -- Send bug reports, requests for additions and questions
 -- either to the GitHub issue tracker at
--- 
+--
 --     https://github.com/witiko/markdown/issues
--- 
+--
 -- or to the e-mail address <witiko at mail.muni.cz>.
--- 
+--
 -- MODIFICATION ADVICE:
--- 
+--
 -- If you want to customize this file, it is best to make a copy of
 -- the source file(s) from which it was produced. Use a different
 -- name for your copy(ies) and modify the copy(ies); this will ensure
@@ -51,14 +51,14 @@
 -- new release of the standard system. You should also ensure that
 -- your modified source file does not generate any modified file with
 -- the same name as a standard file.
--- 
+--
 -- You will also need to produce your own, suitably named, .ins file to
 -- control the generation of files from your source file; this file
 -- should contain your own preambles for the files it generates, not
 -- those in the standard .ins files.
--- 
+--
 local metadata = {
-    version   = "2.15.3-0-g7c8e03d",
+    version   = "2.15.4-0-g4cbe4e3",
     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",
@@ -106,7 +106,7 @@
 defaultOptions.tightLists = true
 defaultOptions.underscores = true
 
-HELP_STRING = [[
+local HELP_STRING = [[
 Usage: texlua ]] .. arg[0] .. [[ [OPTIONS] -- [INPUT_FILE] [OUTPUT_FILE]
 where OPTIONS are documented in the Lua interface section of the
 technical Markdown package documentation.
@@ -118,7 +118,7 @@
 Report bugs to: witiko at mail.muni.cz
 Markdown package home page: <https://github.com/witiko/markdown>]]
 
-VERSION_STRING = [[
+local VERSION_STRING = [[
 markdown-cli.lua (Markdown) ]] .. metadata.version .. [[
 
 Copyright (C) ]] .. table.concat(metadata.copyright,
@@ -143,8 +143,8 @@
       process_options = false
       goto continue
     elseif arg[i]:match("=") then
-      key, value = arg[i]:match("(.-)=(.*)")
-      default_type = type(defaultOptions[key])
+      local key, value = arg[i]:match("(.-)=(.*)")
+      local default_type = type(defaultOptions[key])
       if default_type == "boolean" then
         options[key] = (value == "true")
       elseif default_type == "number" then

Modified: trunk/Master/texmf-dist/source/generic/markdown/docstrip.cfg
===================================================================
--- trunk/Master/texmf-dist/source/generic/markdown/docstrip.cfg	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/source/generic/markdown/docstrip.cfg	2022-07-29 21:00:05 UTC (rev 64000)
@@ -1,8 +1,8 @@
 \askforoverwritefalse
 \def\luapreamble{%
--- ^^J%
+--^^J%
 -- Copyright (C) 2009-2016 John MacFarlane, Hans Hagen^^J%
--- ^^J%
+--^^J%
 -- Permission is hereby granted, free of charge, to any person obtaining^^J%
 -- a copy of this software and associated documentation files (the^^J%
 -- "Software"), to deal in the Software without restriction, including^^J%
@@ -10,10 +10,10 @@
 -- distribute, sublicense, and/or sell copies of the Software, and to^^J%
 -- permit persons to whom the Software is furnished to do so, subject to^^J%
 -- the following conditions:^^J%
--- ^^J%
+--^^J%
 -- The above copyright notice and this permission notice shall be included^^J%
 -- in all copies or substantial portions of the Software.^^J%
--- ^^J%
+--^^J%
 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,^^J%
 -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF^^J%
 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.^^J%
@@ -21,31 +21,31 @@
 -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,^^J%
 -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE^^J%
 -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.^^J%
--- ^^J%
+--^^J%
 -- Copyright (C) 2016-2022 Vít Novotný^^J%
--- ^^J%
+--^^J%
 -- This work may be distributed and/or modified under the^^J%
 -- conditions of the LaTeX Project Public License, either version 1.3^^J%
 -- of this license or (at your option) any later version.^^J%
 -- The latest version of this license is in^^J%
--- ^^J%
+--^^J%
 -- \space\space\space\space http://www.latex-project.org/lppl.txt^^J%
--- ^^J%
+--^^J%
 -- and version 1.3 or later is part of all distributions of LaTeX^^J%
 -- version 2005/12/01 or later.^^J%
--- ^^J%
+--^^J%
 -- This work has the LPPL maintenance status `maintained'.^^J%
 -- The Current Maintainer of this work is Vít Novotný.^^J%
--- ^^J%
+--^^J%
 -- Send bug reports, requests for additions and questions^^J%
 -- either to the GitHub issue tracker at^^J%
--- ^^J%
+--^^J%
 -- \space\space\space\space https://github.com/witiko/markdown/issues^^J%
--- ^^J%
+--^^J%
 -- or to the e-mail address <witiko at mail.muni.cz>.^^J%
--- ^^J%
+--^^J%
 -- MODIFICATION ADVICE:^^J%
--- ^^J%
+--^^J%
 -- If you want to customize this file, it is best to make a copy of^^J%
 -- the source file(s) from which it was produced.  Use a different^^J%
 -- name for your copy(ies) and modify the copy(ies); this will ensure^^J%
@@ -53,12 +53,12 @@
 -- new release of the standard system.  You should also ensure that^^J%
 -- your modified source file does not generate any modified file with^^J%
 -- the same name as a standard file.^^J%
--- ^^J%
+--^^J%
 -- You will also need to produce your own, suitably named, .ins file to^^J%
 -- control the generation of files from your source file; this file^^J%
 -- should contain your own preambles for the files it generates, not^^J%
 -- those in the standard .ins files.^^J%
--- }
+--}
 \let\luapostamble\empty
 \declarepreamble\texpreamble
 

Modified: trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx
===================================================================
--- trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/source/generic/markdown/markdown.dtx	2022-07-29 21:00:05 UTC (rev 64000)
@@ -1051,7 +1051,10 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
-local ran_ok, unicode = pcall(require, "unicode")
+local unicode
+(function()
+  local ran_ok
+  ran_ok, unicode = pcall(require, "unicode")
 %    \end{macrocode}
 % \begin{markdown}
 %
@@ -1060,9 +1063,10 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
-if not ran_ok then
-  unicode = {["utf8"]={char=utf8.char}}
-end
+  if not ran_ok then
+    unicode = {["utf8"]={char=utf8.char}}
+  end
+end)()
 %    \end{macrocode}
 % \par
 % \begin{markdown}
@@ -1178,35 +1182,9 @@
 %</latex-themes-witiko-dot,latex-themes-witiko-graphicx-http,latex-themes-witiko-tilde>
 % \fi
 % \begin{markdown}
-% a \TeX{} engine that extends \Hologo{eTeX}, all the plain \TeX{}
-% prerequisites (see Section <#sec:texprerequisites>), and the following
-% \Hologo{LaTeX2e} packages:
+% a \TeX{} engine that extends \Hologo{eTeX}, and all the plain \TeX{}
+% prerequisites (see Section <#sec:texprerequisites>):
 %
-% \pkg{keyval}
-%
-%:    A package that enables the creation of parameter sets. This package is
-%     used to provide the \mref{markdownSetup} macro, the package options
-%     processing, as well as the parameters of the \envmref{markdown*} \LaTeX{}
-%     environment.
-%
-% \end{markdown}
-%  \begin{macrocode}
-\RequirePackage{keyval}
-%    \end{macrocode}
-% \par
-% \begin{markdown}
-%
-% \pkg{xstring}
-%
-%:    A package that provides useful macros for manipulating strings of tokens.
-%
-% \end{markdown}
-%  \begin{macrocode}
-\RequirePackage{xstring}
-%    \end{macrocode}
-% \par
-% \begin{markdown}
-%
 % The following packages are soft prerequisites. They are only used to provide
 % default token renderer prototypes (see sections
 % <#sec:texrendererprototypes> and
@@ -2061,8 +2039,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-%     TODO: Replace with \str_uppercase:n in TeX Live 2020.
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -7826,7 +7803,7 @@
 % \end{figure}
 %  \begin{macrocode}
 
-HELP_STRING = [[
+local HELP_STRING = [[
 Usage: texlua ]] .. arg[0] .. [[ [OPTIONS] -- [INPUT_FILE] [OUTPUT_FILE]
 where OPTIONS are documented in the Lua interface section of the
 technical Markdown package documentation.
@@ -7838,7 +7815,7 @@
 Report bugs to: witiko at mail.muni.cz
 Markdown package home page: <https://github.com/witiko/markdown>]]
 
-VERSION_STRING = [[
+local VERSION_STRING = [[
 markdown-cli.lua (Markdown) ]] .. metadata.version .. [[
 
 Copyright (C) ]] .. table.concat(metadata.copyright,
@@ -7879,7 +7856,7 @@
 % \end{markdown}
 %  \begin{macrocode}
     elseif arg[i]:match("=") then
-      key, value = arg[i]:match("(.-)=(.*)")
+      local key, value = arg[i]:match("(.-)=(.*)")
 %    \end{macrocode}
 % \begin{markdown}
 % The \luamref{defaultOptions} table is consulted to identify whether \meta{value}
@@ -7886,7 +7863,7 @@
 % should be parsed as a string or as a boolean.
 % \end{markdown}
 %  \begin{macrocode}
-      default_type = type(defaultOptions[key])
+      local default_type = type(defaultOptions[key])
       if default_type == "boolean" then
         options[key] = (value == "true")
       elseif default_type == "number" then
@@ -14308,8 +14285,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-%     TODO: Replace with \str_uppercase:n in TeX Live 2020.
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -14651,8 +14627,16 @@
 %
 % \markdownEnd
 %  \begin{macrocode}
-\newcommand\markdownSetup[1]{%
-  \setkeys{markdownOptions}{#1}}%
+\ExplSyntaxOn
+\cs_new:Nn
+  \@@_setup:n
+  {
+    \keys_set:nn
+      { markdown/latex-options }
+      { #1 }
+  }
+\let\markdownSetup=\@@_setup:n
+\ExplSyntaxOff
 %    \end{macrocode}
 % \begin{markdown}
 %
@@ -14873,16 +14857,35 @@
 \newif\ifmarkdownLaTeXLoaded
   \markdownLaTeXLoadedfalse
 \AtEndOfPackage{\markdownLaTeXLoadedtrue}
-\define at key{markdownOptions}{theme}{%
-  \IfSubStr{#1}{/}{}{%
-    \markdownError
-      {Won't load theme with unqualified name #1}%
-      {Theme names must contain at least one forward slash}}%
-  \StrSubstitute{#1}{/}{_}[\markdownLaTeXThemePackageName]%
-  \edef\markdownLaTeXThemePackageName{%
-    markdowntheme\markdownLaTeXThemePackageName}%
-  \expandafter\markdownLaTeXThemeLoad\expandafter{%
-    \markdownLaTeXThemePackageName}{#1/}}%
+\ExplSyntaxOn
+\tl_new:N \markdownLaTeXThemePackageName
+\cs_new:Nn
+  \@@_set_latex_theme:n
+  {
+    \str_if_in:NnF
+      { #1 }
+      { / }
+      {
+        \markdownError
+        { Won't load theme with unqualified name #1 }
+        { Theme names must contain at least one forward slash }
+      }
+    \tl_set:Nn \markdownLaTeXThemePackageName { #1 }
+    \str_replace_all:Nnn
+      \markdownLaTeXThemePackageName
+      { / }
+      { _ }
+    \edef\markdownLaTeXThemePackageName{
+      markdowntheme\markdownLaTeXThemePackageName}
+    \expandafter\markdownLaTeXThemeLoad\expandafter{
+      \markdownLaTeXThemePackageName}{#1/}
+  }
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    theme .code:n = { \@@_set_latex_theme:n { #1 } },
+  }
+\ExplSyntaxOff
 %    \end{macrocode}
 % \begin{markdown}
 %
@@ -14910,7 +14913,10 @@
 %<*latex>
 % \fi
 %  \begin{macrocode}
-\@onlypreamble\KV at markdownOptions@theme
+\ExplSyntaxOn
+\@onlypreamble
+  \@@_set_latex_theme:n
+\ExplSyntaxOff
 %    \end{macrocode}
 % \iffalse
 %</latex>
@@ -15201,18 +15207,24 @@
 %<*latex>
 % \fi
 %  \begin{macrocode}
-\define at key{markdownOptions}{snippet}{%
-  \markdownIfSnippetExists{#1}%
-    {%
-      \expandafter\markdownSetup\expandafter{%
-        \the\csname markdownLaTeXSetupSnippet%
-        \markdownLaTeXThemeName#1\endcsname}%
-    }{%
-      \markdownError
-        {Can't invoke setup snippet #1}%
-        {The setup snippet is undefined}%
-    }%
-  }%
+\ExplSyntaxOn
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    snippet .code:n = {
+      \markdownIfSnippetExists{#1}
+        {
+          \expandafter\markdownSetup\expandafter{
+            \the\csname markdownLaTeXSetupSnippet
+            \markdownLaTeXThemeName#1\endcsname}
+        }{
+          \markdownError
+            {Can't~invoke~setup~snippet~#1}
+            {The~setup~snippet~is~undefined}
+        }
+    }
+  }
+\ExplSyntaxOff
 %    \end{macrocode}
 % \iffalse
 %</latex>
@@ -15298,30 +15310,25 @@
       { g_@@_ #1 _option_types_prop }
       { #2 }
       \l_tmpa_tl
-    \str_if_eq:VVTF
+    \keys_define:nn
+      { markdown/latex-options }
+      {
+        #2 .code:n = {
+          \@@_set_option_value:nn
+            { #2 }
+            { ##1 }
+        },
+      }
+    \str_if_eq:VVT
       \l_tmpa_tl
       \c_@@_option_type_boolean_tl
       {
-        \define at key
-          { markdownOptions }
-          { #2 }
-          [ true ]
+        \keys_define:nn
+          { markdown/latex-options }
           {
-            \@@_set_option_value:nn
-              { #2 }
-              { ##1 }
+            #2 .default:n = { true },
           }
       }
-      {
-        \define at key
-          { markdownOptions }
-          { #2 }
-          {
-            \@@_set_option_value:nn
-              { #2 }
-              { ##1 }
-          }
-      }
   }
 \@@_latex_define_option_commands_and_keyvals:
 \ExplSyntaxOff
@@ -15405,8 +15412,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-%     TODO: Replace with \str_uppercase:n in TeX Live 2020.
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -15417,15 +15423,16 @@
   }
 \cs_new:Nn \@@_latex_define_renderer:nNn
   {
-    \define at key
-      { markdownRenderers }
-      { #1 }
+    \keys_define:nn
+      { markdown/latex-options/renderers }
       {
-        \cs_generate_from_arg_count:NNnn
-          #2
-          \cs_set:Npn
-          { #3 }
-          { ##1 }
+        #1 .code:n = {
+          \cs_generate_from_arg_count:NNnn
+            #2
+            \cs_set:Npn
+            { #3 }
+            { ##1 }
+        },
       }
   }
 \cs_generate_variant:Nn
@@ -15480,15 +15487,16 @@
   }
 \cs_new:Nn \@@_latex_define_renderer_prototype:nNn
   {
-    \define at key
-      { markdownRendererPrototypes }
-      { #1 }
+    \keys_define:nn
+      { markdown/latex-options/renderer-prototypes }
       {
-        \cs_generate_from_arg_count:NNnn
-          #2
-          \cs_set:Npn
-          { #3 }
-          { ##1 }
+        #1 .code:n = {
+          \cs_generate_from_arg_count:NNnn
+            #2
+            \cs_set:Npn
+            { #3 }
+            { ##1 }
+        },
       }
   }
 \cs_generate_variant:Nn
@@ -15662,7 +15670,6 @@
 %  \begin{macrocode}
 local upper, gsub, format, length =
   string.upper, string.gsub, string.format, string.len
-local concat = table.concat
 local P, R, S, V, C, Cg, Cb, Cmt, Cc, Ct, B, Cs, any =
   lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cg, lpeg.Cb,
   lpeg.Cmt, lpeg.Cc, lpeg.Ct, lpeg.B, lpeg.Cs, lpeg.P(1)
@@ -15709,7 +15716,7 @@
   local name = util.pathname(dir, digest .. suffix)
   local file = io.open(name, "r")
   if file == nil then -- If no cache entry exists, then create a new one.
-    local file = assert(io.open(name, "w"),
+    file = assert(io.open(name, "w"),
       [[could not open file "]] .. name .. [[" for writing]])
     local result = string
     if transform ~= nil then
@@ -18879,9 +18886,7 @@
 parsers.nonspacechar           = parsers.any - parsers.spacing
 parsers.optionalspace          = parsers.spacechar^0
 
-parsers.specialchar            = S("*_`&[]<!\\. at -^")
-
-parsers.normalchar             = parsers.any - (parsers.specialchar
+parsers.normalchar             = parsers.any - (V("SpecialChar")
                                                 + parsers.spacing
                                                 + parsers.tightblocksep)
 parsers.eof                    = -parsers.any
@@ -19052,7 +19057,7 @@
 %  \begin{macrocode}
 parsers.openticks   = Cg(parsers.backtick^1, "ticks")
 
-local function captures_equal_length(s,i,a,b)
+local function captures_equal_length(_,i,a,b)
   return #a == #b and i
 end
 
@@ -19075,7 +19080,7 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
-local function captures_geq_length(s,i,a,b)
+local function captures_geq_length(_,i,a,b)
   return #a >= #b and i
 end
 
@@ -19100,10 +19105,10 @@
 parsers.fencedline   = function(char)
   return               C(parsers.line - parsers.fencetail(char))
                      / function(s)
-                         i = 1
-                         remaining = fenceindent
+                         local i = 1
+                         local remaining = fenceindent
                          while true do
-                           c = s:sub(i, i)
+                           local c = s:sub(i, i)
                            if c == " " and remaining > 0 then
                              remaining = remaining - 1
                              i = i + 1
@@ -19486,7 +19491,7 @@
 % \end{markdown}
 %  \begin{macrocode}
   local function iterlines(s, f)
-    rope = lpeg.match(Ct((parsers.line / f)^1), s)
+    local rope = lpeg.match(Ct((parsers.line / f)^1), s)
     return util.rope_to_string(rope)
   end
 %    \end{macrocode}
@@ -19546,7 +19551,7 @@
                   return line
               end
               line = util.expand_tabs_in_line(line)
-              prefix = lpeg.match(C(parsers.optionalspace), line)
+              local prefix = lpeg.match(C(parsers.optionalspace), line)
               local prefix_length = #prefix
               local is_shorter = min_prefix_length == nil
               is_shorter = is_shorter or prefix_length < min_prefix_length
@@ -19750,7 +19755,7 @@
   parsers.Str      = (parsers.normalchar * (parsers.normalchar + parsers.at)^0)
                    / writer.string
 
-  parsers.Symbol   = (parsers.specialchar - parsers.tightblocksep)
+  parsers.Symbol   = (V("SpecialChar") - parsers.tightblocksep)
                    / writer.string
 
   parsers.Ellipsis = P("...") / writer.ellipsis
@@ -20184,12 +20189,28 @@
       EscapedChar           = parsers.EscapedChar,
       Smart                 = parsers.Smart,
       Symbol                = parsers.Symbol,
+      SpecialChar           = parsers.fail,
     }
-
 %    \end{macrocode}
 % \par
 % \begin{markdown}
 %
+% Define a hash table of all characters with a special meaning that can be
+% escaped and add method `reader->add_special_character` that extends the
+% hash table and updates the \acro{peg} grammar.
+%
+% \end{markdown}
+%  \begin{macrocode}
+  local special_characters = {"*", "`", "[", "]", "<", "!", "\\"}
+  self.add_special_character = function(c)
+    table.insert(special_characters, c)
+    self.syntax.SpecialChar = S(table.concat(special_characters, ""))
+  end
+  self.syntax.SpecialChar = S(table.concat(special_characters, ""))
+%    \end{macrocode}
+% \par
+% \begin{markdown}
+%
 % Apply syntax extensions.
 %
 % \end{markdown}
@@ -20199,6 +20220,10 @@
     extension.extend_reader(self)
   end
 
+  if options.underscores then
+    self.add_special_character("_")
+  end
+
   if not options.codeSpans then
     self.syntax.Code = parsers.fail
   end
@@ -20207,6 +20232,8 @@
     self.syntax.DisplayHtml = parsers.fail
     self.syntax.InlineHtml = parsers.fail
     self.syntax.HtmlEntity  = parsers.fail
+  else
+    self.add_special_character("&")
   end
 
   if options.preserveTabs then
@@ -20215,6 +20242,8 @@
 
   if not options.smartEllipses then
     self.syntax.Smart = parsers.fail
+  else
+    self.add_special_character(".")
   end
 
   if not options.relativeReferences then
@@ -20542,6 +20571,9 @@
       local Citations = TextCitations + ParenthesizedCitations
 
       syntax.Citations = Citations
+
+      self.add_special_character("@")
+      self.add_special_character("-")
     end
   }
 end
@@ -20584,15 +20616,15 @@
 % \end{markdown}
 %  \begin{macrocode}
     else
-      kpse = {lookup=function(filename, options) return filename end}
+      kpse = {lookup=function(filename, _) return filename end}
     end
     local base, prev, curr
     for _, filename in ipairs{kpse.lookup(language_map, { all=true })} do
       local file = io.open(filename, "r")
       if not file then goto continue end
-      json = file:read("*all"):gsub('("[^\n]-"):','[%1]=')
+      local json = file:read("*all"):gsub('("[^\n]-"):','[%1]=')
       curr = (function()
-        local _ENV={ json=json, load=load } -- run in sandbox
+        local _ENV={ json=json, load=load } -- luacheck: ignore _ENV
         return load("return "..json)()
       end)()
       if type(curr) == "table" then
@@ -20794,7 +20826,7 @@
 
       local dlchunk = Cs(parsers.line * (parsers.indentedline - parsers.blankline)^0)
 
-      local function definition_list_item(term, defs, tight)
+      local function definition_list_item(term, defs, _)
         return { term = self.parser_functions.parse_inlines(term),
                  definitions = defs }
       end
@@ -20859,7 +20891,7 @@
       local syntax = self.syntax
       local writer = self.writer
 
-      local function captures_geq_length(s,i,a,b)
+      local function captures_geq_length(_,i,a,b)
         return #a >= #b and i
       end
 
@@ -20884,10 +20916,10 @@
       local fencedline   = function(char)
         return             C(parsers.line - fencetail(char))
                          / function(s)
-                             i = 1
-                             remaining = fenceindent
+                             local i = 1
+                             local remaining = fenceindent
                              while true do
-                               c = s:sub(i, i)
+                               local c = s:sub(i, i)
                                if c == " " and remaining > 0 then
                                  remaining = remaining - 1
                                  i = i + 1
@@ -20921,6 +20953,7 @@
 
       syntax.FencedCode = FencedCode
 
+      local fencestart
       if blank_before_code_fence then
         fencestart = parsers.fail
       else
@@ -21016,6 +21049,8 @@
                     / writer.note
         syntax.InlineNote = InlineNote
       end
+
+      self.add_special_character("^")
     end
   }
 end
@@ -21031,7 +21066,7 @@
 %  \begin{macrocode}
 M.extensions.header_attributes = function()
   return {
-    extend_writer = function(self)
+    extend_writer = function()
     end, extend_reader = function(self)
       local parsers = self.parsers
       local syntax = self.syntax
@@ -21202,9 +21237,9 @@
 
       local JekyllData
                     = Cmt( C((parsers.line - P("---") - P("..."))^0)
-                         , function(s, i, text)
+                         , function(s, i, text) -- luacheck: ignore s i
                              local data
-                             local ran_ok, error = pcall(function()
+                             local ran_ok, _ = pcall(function()
                                local tinyyaml = require("markdown-tinyyaml")
                                data = tinyyaml.parse(text, {timestamps=false})
                              end)
@@ -21433,50 +21468,50 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
-  extensions = {}
+  local extensions = {}
 
   if options.citations then
-    citations_extension = M.extensions.citations(options.citationNbsps)
+    local citations_extension = M.extensions.citations(options.citationNbsps)
     table.insert(extensions, citations_extension)
   end
 
   if options.contentBlocks then
-    content_blocks_extension = M.extensions.content_blocks(
+    local content_blocks_extension = M.extensions.content_blocks(
       options.contentBlocksLanguageMap)
     table.insert(extensions, content_blocks_extension)
   end
 
   if options.definitionLists then
-    definition_lists_extension = M.extensions.definition_lists(
+    local definition_lists_extension = M.extensions.definition_lists(
       options.tightLists)
     table.insert(extensions, definition_lists_extension)
   end
 
   if options.fencedCode then
-    fenced_code_extension = M.extensions.fenced_code(
+    local fenced_code_extension = M.extensions.fenced_code(
       options.blankBeforeCodeFence)
     table.insert(extensions, fenced_code_extension)
   end
 
   if options.footnotes or options.inlineFootnotes then
-    footnotes_extension = M.extensions.footnotes(
+    local footnotes_extension = M.extensions.footnotes(
       options.footnotes, options.inlineFootnotes)
     table.insert(extensions, footnotes_extension)
   end
 
   if options.headerAttributes then
-    header_attributes_extension = M.extensions.header_attributes()
+    local header_attributes_extension = M.extensions.header_attributes()
     table.insert(extensions, header_attributes_extension)
   end
 
   if options.jekyllData then
-    jekyll_data_extension = M.extensions.jekyll_data(
+    local jekyll_data_extension = M.extensions.jekyll_data(
       options.expectJekyllData)
     table.insert(extensions, jekyll_data_extension)
   end
 
   if options.pipeTables then
-    pipe_tables_extension = M.extensions.pipe_tables(
+    local pipe_tables_extension = M.extensions.pipe_tables(
       options.tableCaptions)
     table.insert(extensions, pipe_tables_extension)
   end
@@ -22545,12 +22580,10 @@
         print(convert(input:gsub("\r\n?", "\n") .. "\n"))}%
 %    \end{macrocode}
 % \begin{markdown}
-% If we are finalizing the frozen cache, increment \Opt{frozenCacheCounter}.
+% In case we were finalizing the frozen cache, increment \Opt{frozenCacheCounter}.
 % \end{markdown}
 %  \begin{macrocode}
-      |markdownIfOption{finalizeCache}{%
-        |global|advance|markdownOptionFrozenCacheCounter by 1|relax
-      }%
+      |global|advance|markdownOptionFrozenCacheCounter by 1|relax
     }%
     |endgroup
   }%
@@ -22947,13 +22980,23 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
-\define at key{markdownOptions}{renderers}{%
-  \setkeys{markdownRenderers}{#1}%
-  \def\KV at prefix{KV at markdownOptions@}}%
-\define at key{markdownOptions}{rendererPrototypes}{%
-  \setkeys{markdownRendererPrototypes}{#1}%
-  \def\KV at prefix{KV at markdownOptions@}}%
-\define at key{markdownOptions}{code}{#1}%
+\ExplSyntaxOn
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    renderers .code:n = {
+      \keys_set:nn
+        { markdown/latex-options/renderers }
+        { #1 }
+    },
+    rendererPrototypes .code:n = {
+      \keys_set:nn
+        { markdown/latex-options/renderer-prototypes }
+        { #1 }
+    },
+    code .code:n = { #1 },
+  }
+\ExplSyntaxOff
 %    \end{macrocode}
 % \par
 % \begin{markdown}
@@ -23178,8 +23221,15 @@
 %
 % \end{markdown}
 %  \begin{macrocode}
+\ExplSyntaxOn
 \def\markdownLATEXStrongEmphasis#1{%
-  \IfSubStr\f at series{b}{\textnormal{#1}}{\textbf{#1}}}
+  \str_if_in:NnTF
+    \f at series
+    { b }
+    { \textnormal{#1} }
+    { \textbf{#1} }
+}
+\ExplSyntaxOff
 \markdownSetup{rendererPrototypes={strongEmphasis={%
   \protect\markdownLATEXStrongEmphasis{#1}}}}
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/tex/generic/markdown/markdown.tex	2022-07-29 21:00:05 UTC (rev 64000)
@@ -262,7 +262,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -424,8 +424,8 @@
   { boolean }
   { true }
 \ExplSyntaxOff
-\def\markdownLastModified{2022/06/27}%
-\def\markdownVersion{2.15.3-0-g7c8e03d}%
+\def\markdownLastModified{2022/07/29}%
+\def\markdownVersion{2.15.4-0-g4cbe4e3}%
 \let\markdownBegin\relax
 \let\markdownEnd\relax
 \let\markdownInput\relax
@@ -1539,7 +1539,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -2102,9 +2102,7 @@
         local input = assert(file:read("*a"))
         assert(file:close())
         print(convert(input:gsub("\r\n?", "\n") .. "\n"))}%
-      |markdownIfOption{finalizeCache}{%
-        |global|advance|markdownOptionFrozenCacheCounter by 1|relax
-      }%
+      |global|advance|markdownOptionFrozenCacheCounter by 1|relax
     }%
     |endgroup
   }%

Modified: trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/tex/latex/markdown/markdown.sty	2022-07-29 21:00:05 UTC (rev 64000)
@@ -42,8 +42,6 @@
 %% 
 %% The names of the source files used are shown above.
 %% 
-\RequirePackage{keyval}
-\RequirePackage{xstring}
 \RequirePackage{expl3}
 \newcommand\markdownInfo[1]{\PackageInfo{markdown}{#1}}%
 \newcommand\markdownWarning[1]{\PackageWarning{markdown}{#1}}%
@@ -51,8 +49,16 @@
 \input markdown/markdown
 \newenvironment{markdown}\relax\relax
 \newenvironment{markdown*}[1]\relax\relax
-\newcommand\markdownSetup[1]{%
-  \setkeys{markdownOptions}{#1}}%
+\ExplSyntaxOn
+\cs_new:Nn
+  \__markdown_setup:n
+  {
+    \keys_set:nn
+      { markdown/latex-options }
+      { #1 }
+  }
+\let\markdownSetup=\__markdown_setup:n
+\ExplSyntaxOff
 \newcommand\markdownSetupSnippet[2]{%
   \markdownIfSnippetExists{#1}%
     {%
@@ -93,30 +99,58 @@
 \newif\ifmarkdownLaTeXLoaded
   \markdownLaTeXLoadedfalse
 \AtEndOfPackage{\markdownLaTeXLoadedtrue}
-\define at key{markdownOptions}{theme}{%
-  \IfSubStr{#1}{/}{}{%
-    \markdownError
-      {Won't load theme with unqualified name #1}%
-      {Theme names must contain at least one forward slash}}%
-  \StrSubstitute{#1}{/}{_}[\markdownLaTeXThemePackageName]%
-  \edef\markdownLaTeXThemePackageName{%
-    markdowntheme\markdownLaTeXThemePackageName}%
-  \expandafter\markdownLaTeXThemeLoad\expandafter{%
-    \markdownLaTeXThemePackageName}{#1/}}%
-\@onlypreamble\KV at markdownOptions@theme
-\define at key{markdownOptions}{snippet}{%
-  \markdownIfSnippetExists{#1}%
-    {%
-      \expandafter\markdownSetup\expandafter{%
-        \the\csname markdownLaTeXSetupSnippet%
-        \markdownLaTeXThemeName#1\endcsname}%
-    }{%
-      \markdownError
-        {Can't invoke setup snippet #1}%
-        {The setup snippet is undefined}%
-    }%
-  }%
 \ExplSyntaxOn
+\tl_new:N \markdownLaTeXThemePackageName
+\cs_new:Nn
+  \__markdown_set_latex_theme:n
+  {
+    \str_if_in:NnF
+      { #1 }
+      { / }
+      {
+        \markdownError
+        { Won't load theme with unqualified name #1 }
+        { Theme names must contain at least one forward slash }
+      }
+    \tl_set:Nn \markdownLaTeXThemePackageName { #1 }
+    \str_replace_all:Nnn
+      \markdownLaTeXThemePackageName
+      { / }
+      { _ }
+    \edef\markdownLaTeXThemePackageName{
+      markdowntheme\markdownLaTeXThemePackageName}
+    \expandafter\markdownLaTeXThemeLoad\expandafter{
+      \markdownLaTeXThemePackageName}{#1/}
+  }
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    theme .code:n = { \__markdown_set_latex_theme:n { #1 } },
+  }
+\ExplSyntaxOff
+\ExplSyntaxOn
+\@onlypreamble
+  \__markdown_set_latex_theme:n
+\ExplSyntaxOff
+\ExplSyntaxOn
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    snippet .code:n = {
+      \markdownIfSnippetExists{#1}
+        {
+          \expandafter\markdownSetup\expandafter{
+            \the\csname markdownLaTeXSetupSnippet
+            \markdownLaTeXThemeName#1\endcsname}
+        }{
+          \markdownError
+            {Can't~invoke~setup~snippet~#1}
+            {The~setup~snippet~is~undefined}
+        }
+    }
+  }
+\ExplSyntaxOff
+\ExplSyntaxOn
 \cs_new:Nn \__markdown_latex_define_option_commands_and_keyvals:
   {
     \seq_map_inline:Nn
@@ -143,30 +177,25 @@
       { g__markdown_ #1 _option_types_prop }
       { #2 }
       \l_tmpa_tl
-    \str_if_eq:VVTF
+    \keys_define:nn
+      { markdown/latex-options }
+      {
+        #2 .code:n = {
+          \__markdown_set_option_value:nn
+            { #2 }
+            { ##1 }
+        },
+      }
+    \str_if_eq:VVT
       \l_tmpa_tl
       \c__markdown_option_type_boolean_tl
       {
-        \define at key
-          { markdownOptions }
-          { #2 }
-          [ true ]
+        \keys_define:nn
+          { markdown/latex-options }
           {
-            \__markdown_set_option_value:nn
-              { #2 }
-              { ##1 }
+            #2 .default:n = { true },
           }
       }
-      {
-        \define at key
-          { markdownOptions }
-          { #2 }
-          {
-            \__markdown_set_option_value:nn
-              { #2 }
-              { ##1 }
-          }
-      }
   }
 \__markdown_latex_define_option_commands_and_keyvals:
 \ExplSyntaxOff
@@ -197,7 +226,7 @@
   {
     \tl_set:Nn
       \l_tmpa_tl
-      { \str_upper_case:n { #1 } }
+      { \str_uppercase:n { #1 } }
     \tl_set:Nx
       #2
       {
@@ -208,15 +237,16 @@
   }
 \cs_new:Nn \__markdown_latex_define_renderer:nNn
   {
-    \define at key
-      { markdownRenderers }
-      { #1 }
+    \keys_define:nn
+      { markdown/latex-options/renderers }
       {
-        \cs_generate_from_arg_count:NNnn
-          #2
-          \cs_set:Npn
-          { #3 }
-          { ##1 }
+        #1 .code:n = {
+          \cs_generate_from_arg_count:NNnn
+            #2
+            \cs_set:Npn
+            { #3 }
+            { ##1 }
+        },
       }
   }
 \cs_generate_variant:Nn
@@ -246,15 +276,16 @@
   }
 \cs_new:Nn \__markdown_latex_define_renderer_prototype:nNn
   {
-    \define at key
-      { markdownRendererPrototypes }
-      { #1 }
+    \keys_define:nn
+      { markdown/latex-options/renderer-prototypes }
       {
-        \cs_generate_from_arg_count:NNnn
-          #2
-          \cs_set:Npn
-          { #3 }
-          { ##1 }
+        #1 .code:n = {
+          \cs_generate_from_arg_count:NNnn
+            #2
+            \cs_set:Npn
+            { #3 }
+            { ##1 }
+        },
       }
   }
 \cs_generate_variant:Nn
@@ -322,13 +353,23 @@
 \DeclareOption*{%
   \expandafter\markdownSetup\expandafter{\CurrentOption}}%
 \ProcessOptions\relax
-\define at key{markdownOptions}{renderers}{%
-  \setkeys{markdownRenderers}{#1}%
-  \def\KV at prefix{KV at markdownOptions@}}%
-\define at key{markdownOptions}{rendererPrototypes}{%
-  \setkeys{markdownRendererPrototypes}{#1}%
-  \def\KV at prefix{KV at markdownOptions@}}%
-\define at key{markdownOptions}{code}{#1}%
+\ExplSyntaxOn
+\keys_define:nn
+  { markdown/latex-options }
+  {
+    renderers .code:n = {
+      \keys_set:nn
+        { markdown/latex-options/renderers }
+        { #1 }
+    },
+    rendererPrototypes .code:n = {
+      \keys_set:nn
+        { markdown/latex-options/renderer-prototypes }
+        { #1 }
+    },
+    code .code:n = { #1 },
+  }
+\ExplSyntaxOff
 \markdownIfOption{plain}{\iffalse}{\iftrue}
 \markdownIfOption{tightLists}{
   \@ifclassloaded{beamer}{}{\RequirePackage{paralist}}%
@@ -462,8 +503,15 @@
     \fi},
   horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}},
   footnote = {\footnote{#1}}}}
+\ExplSyntaxOn
 \def\markdownLATEXStrongEmphasis#1{%
-  \IfSubStr\f at series{b}{\textnormal{#1}}{\textbf{#1}}}
+  \str_if_in:NnTF
+    \f at series
+    { b }
+    { \textnormal{#1} }
+    { \textbf{#1} }
+}
+\ExplSyntaxOff
 \markdownSetup{rendererPrototypes={strongEmphasis={%
   \protect\markdownLATEXStrongEmphasis{#1}}}}
 \@ifundefined{chapter}{%

Modified: trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua	2022-07-29 20:59:44 UTC (rev 63999)
+++ trunk/Master/texmf-dist/tex/luatex/markdown/markdown.lua	2022-07-29 21:00:05 UTC (rev 64000)
@@ -1,6 +1,6 @@
--- 
+--
 -- Copyright (C) 2009-2016 John MacFarlane, Hans Hagen
--- 
+--
 -- Permission is hereby granted, free of charge, to any person obtaining
 -- a copy of this software and associated documentation files (the
 -- "Software"), to deal in the Software without restriction, including
@@ -8,10 +8,10 @@
 -- distribute, sublicense, and/or sell copies of the Software, and to
 -- permit persons to whom the Software is furnished to do so, subject to
 -- the following conditions:
--- 
+--
 -- The above copyright notice and this permission notice shall be included
 -- in all copies or substantial portions of the Software.
--- 
+--
 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -19,31 +19,31 @@
 -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- 
+--
 -- Copyright (C) 2016-2022 Vít Novotný
--- 
+--
 -- This work may be distributed and/or modified under the
 -- conditions of the LaTeX Project Public License, either version 1.3
 -- of this license or (at your option) any later version.
 -- The latest version of this license is in
--- 
+--
 --     http://www.latex-project.org/lppl.txt
--- 
+--
 -- and version 1.3 or later is part of all distributions of LaTeX
 -- version 2005/12/01 or later.
--- 
+--
 -- This work has the LPPL maintenance status `maintained'.
 -- The Current Maintainer of this work is Vít Novotný.
--- 
+--
 -- Send bug reports, requests for additions and questions
 -- either to the GitHub issue tracker at
--- 
+--
 --     https://github.com/witiko/markdown/issues
--- 
+--
 -- or to the e-mail address <witiko at mail.muni.cz>.
--- 
+--
 -- MODIFICATION ADVICE:
--- 
+--
 -- If you want to customize this file, it is best to make a copy of
 -- the source file(s) from which it was produced. Use a different
 -- name for your copy(ies) and modify the copy(ies); this will ensure
@@ -51,14 +51,14 @@
 -- new release of the standard system. You should also ensure that
 -- your modified source file does not generate any modified file with
 -- the same name as a standard file.
--- 
+--
 -- You will also need to produce your own, suitably named, .ins file to
 -- control the generation of files from your source file; this file
 -- should contain your own preambles for the files it generates, not
 -- those in the standard .ins files.
--- 
+--
 local metadata = {
-    version   = "2.15.3-0-g7c8e03d",
+    version   = "2.15.4-0-g4cbe4e3",
     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",
@@ -69,10 +69,14 @@
 if not modules then modules = { } end
 modules['markdown'] = metadata
 local lpeg = require("lpeg")
-local ran_ok, unicode = pcall(require, "unicode")
-if not ran_ok then
-  unicode = {["utf8"]={char=utf8.char}}
-end
+local unicode
+(function()
+  local ran_ok
+  ran_ok, unicode = pcall(require, "unicode")
+  if not ran_ok then
+    unicode = {["utf8"]={char=utf8.char}}
+  end
+end)()
 local md5 = require("md5")
 local M = {metadata = metadata}
 local defaultOptions = {}
@@ -116,7 +120,6 @@
 defaultOptions.underscores = true
 local upper, gsub, format, length =
   string.upper, string.gsub, string.format, string.len
-local concat = table.concat
 local P, R, S, V, C, Cg, Cb, Cmt, Cc, Ct, B, Cs, any =
   lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cg, lpeg.Cb,
   lpeg.Cmt, lpeg.Cc, lpeg.Ct, lpeg.B, lpeg.Cs, lpeg.P(1)
@@ -130,7 +133,7 @@
   local name = util.pathname(dir, digest .. suffix)
   local file = io.open(name, "r")
   if file == nil then -- If no cache entry exists, then create a new one.
-    local file = assert(io.open(name, "w"),
+    file = assert(io.open(name, "w"),
       [[could not open file "]] .. name .. [[" for writing]])
     local result = string
     if transform ~= nil then
@@ -2713,9 +2716,7 @@
 parsers.nonspacechar           = parsers.any - parsers.spacing
 parsers.optionalspace          = parsers.spacechar^0
 
-parsers.specialchar            = S("*_`&[]<!\\. at -^")
-
-parsers.normalchar             = parsers.any - (parsers.specialchar
+parsers.normalchar             = parsers.any - (V("SpecialChar")
                                                 + parsers.spacing
                                                 + parsers.tightblocksep)
 parsers.eof                    = -parsers.any
@@ -2829,7 +2830,7 @@
 
 parsers.openticks   = Cg(parsers.backtick^1, "ticks")
 
-local function captures_equal_length(s,i,a,b)
+local function captures_equal_length(_,i,a,b)
   return #a == #b and i
 end
 
@@ -2844,7 +2845,7 @@
 
 parsers.inticks     = parsers.openticks * parsers.space^-1
                     * C(parsers.intickschar^0) * parsers.closeticks
-local function captures_geq_length(s,i,a,b)
+local function captures_geq_length(_,i,a,b)
   return #a >= #b and i
 end
 
@@ -2869,10 +2870,10 @@
 parsers.fencedline   = function(char)
   return               C(parsers.line - parsers.fencetail(char))
                      / function(s)
-                         i = 1
-                         remaining = fenceindent
+                         local i = 1
+                         local remaining = fenceindent
                          while true do
-                           c = s:sub(i, i)
+                           local c = s:sub(i, i)
                            if c == " " and remaining > 0 then
                              remaining = remaining - 1
                              i = i + 1
@@ -3113,7 +3114,7 @@
       gsub(util.rope_to_string(tag), "[ \n\r\t]+", " "))
   end
   local function iterlines(s, f)
-    rope = lpeg.match(Ct((parsers.line / f)^1), s)
+    local rope = lpeg.match(Ct((parsers.line / f)^1), s)
     return util.rope_to_string(rope)
   end
   if options.preserveTabs then
@@ -3137,7 +3138,7 @@
                   return line
               end
               line = util.expand_tabs_in_line(line)
-              prefix = lpeg.match(C(parsers.optionalspace), line)
+              local prefix = lpeg.match(C(parsers.optionalspace), line)
               local prefix_length = #prefix
               local is_shorter = min_prefix_length == nil
               is_shorter = is_shorter or prefix_length < min_prefix_length
@@ -3291,7 +3292,7 @@
   parsers.Str      = (parsers.normalchar * (parsers.normalchar + parsers.at)^0)
                    / writer.string
 
-  parsers.Symbol   = (parsers.specialchar - parsers.tightblocksep)
+  parsers.Symbol   = (V("SpecialChar") - parsers.tightblocksep)
                    / writer.string
 
   parsers.Ellipsis = P("...") / writer.ellipsis
@@ -3682,13 +3683,23 @@
       EscapedChar           = parsers.EscapedChar,
       Smart                 = parsers.Smart,
       Symbol                = parsers.Symbol,
+      SpecialChar           = parsers.fail,
     }
-
+  local special_characters = {"*", "`", "[", "]", "<", "!", "\\"}
+  self.add_special_character = function(c)
+    table.insert(special_characters, c)
+    self.syntax.SpecialChar = S(table.concat(special_characters, ""))
+  end
+  self.syntax.SpecialChar = S(table.concat(special_characters, ""))
   for _, extension in ipairs(extensions) do
     extension.extend_writer(writer)
     extension.extend_reader(self)
   end
 
+  if options.underscores then
+    self.add_special_character("_")
+  end
+
   if not options.codeSpans then
     self.syntax.Code = parsers.fail
   end
@@ -3697,6 +3708,8 @@
     self.syntax.DisplayHtml = parsers.fail
     self.syntax.InlineHtml = parsers.fail
     self.syntax.HtmlEntity  = parsers.fail
+  else
+    self.add_special_character("&")
   end
 
   if options.preserveTabs then
@@ -3705,6 +3718,8 @@
 
   if not options.smartEllipses then
     self.syntax.Smart = parsers.fail
+  else
+    self.add_special_character(".")
   end
 
   if not options.relativeReferences then
@@ -3920,6 +3935,9 @@
       local Citations = TextCitations + ParenthesizedCitations
 
       syntax.Citations = Citations
+
+      self.add_special_character("@")
+      self.add_special_character("-")
     end
   }
 end
@@ -3929,15 +3947,15 @@
     if ran_ok then
       kpse.set_program_name("luatex")
     else
-      kpse = {lookup=function(filename, options) return filename end}
+      kpse = {lookup=function(filename, _) return filename end}
     end
     local base, prev, curr
     for _, filename in ipairs{kpse.lookup(language_map, { all=true })} do
       local file = io.open(filename, "r")
       if not file then goto continue end
-      json = file:read("*all"):gsub('("[^\n]-"):','[%1]=')
+      local json = file:read("*all"):gsub('("[^\n]-"):','[%1]=')
       curr = (function()
-        local _ENV={ json=json, load=load } -- run in sandbox
+        local _ENV={ json=json, load=load } -- luacheck: ignore _ENV
         return load("return "..json)()
       end)()
       if type(curr) == "table" then
@@ -4104,7 +4122,7 @@
 
       local dlchunk = Cs(parsers.line * (parsers.indentedline - parsers.blankline)^0)
 
-      local function definition_list_item(term, defs, tight)
+      local function definition_list_item(term, defs, _)
         return { term = self.parser_functions.parse_inlines(term),
                  definitions = defs }
       end
@@ -4147,7 +4165,7 @@
       local syntax = self.syntax
       local writer = self.writer
 
-      local function captures_geq_length(s,i,a,b)
+      local function captures_geq_length(_,i,a,b)
         return #a >= #b and i
       end
 
@@ -4172,10 +4190,10 @@
       local fencedline   = function(char)
         return             C(parsers.line - fencetail(char))
                          / function(s)
-                             i = 1
-                             remaining = fenceindent
+                             local i = 1
+                             local remaining = fenceindent
                              while true do
-                               c = s:sub(i, i)
+                               local c = s:sub(i, i)
                                if c == " " and remaining > 0 then
                                  remaining = remaining - 1
                                  i = i + 1
@@ -4209,6 +4227,7 @@
 
       syntax.FencedCode = FencedCode
 
+      local fencestart
       if blank_before_code_fence then
         fencestart = parsers.fail
       else
@@ -4282,12 +4301,14 @@
                     / writer.note
         syntax.InlineNote = InlineNote
       end
+
+      self.add_special_character("^")
     end
   }
 end
 M.extensions.header_attributes = function()
   return {
-    extend_writer = function(self)
+    extend_writer = function()
     end, extend_reader = function(self)
       local parsers = self.parsers
       local syntax = self.syntax
@@ -4432,9 +4453,9 @@
 
       local JekyllData
                     = Cmt( C((parsers.line - P("---") - P("..."))^0)
-                         , function(s, i, text)
+                         , function(s, i, text) -- luacheck: ignore s i
                              local data
-                             local ran_ok, error = pcall(function()
+                             local ran_ok, _ = pcall(function()
                                local tinyyaml = require("markdown-tinyyaml")
                                data = tinyyaml.parse(text, {timestamps=false})
                              end)
@@ -4614,50 +4635,50 @@
   options = options or {}
   setmetatable(options, { __index = function (_, key)
     return defaultOptions[key] end })
-  extensions = {}
+  local extensions = {}
 
   if options.citations then
-    citations_extension = M.extensions.citations(options.citationNbsps)
+    local citations_extension = M.extensions.citations(options.citationNbsps)
     table.insert(extensions, citations_extension)
   end
 
   if options.contentBlocks then
-    content_blocks_extension = M.extensions.content_blocks(
+    local content_blocks_extension = M.extensions.content_blocks(
       options.contentBlocksLanguageMap)
     table.insert(extensions, content_blocks_extension)
   end
 
   if options.definitionLists then
-    definition_lists_extension = M.extensions.definition_lists(
+    local definition_lists_extension = M.extensions.definition_lists(
       options.tightLists)
     table.insert(extensions, definition_lists_extension)
   end
 
   if options.fencedCode then
-    fenced_code_extension = M.extensions.fenced_code(
+    local fenced_code_extension = M.extensions.fenced_code(
       options.blankBeforeCodeFence)
     table.insert(extensions, fenced_code_extension)
   end
 
   if options.footnotes or options.inlineFootnotes then
-    footnotes_extension = M.extensions.footnotes(
+    local footnotes_extension = M.extensions.footnotes(
       options.footnotes, options.inlineFootnotes)
     table.insert(extensions, footnotes_extension)
   end
 
   if options.headerAttributes then
-    header_attributes_extension = M.extensions.header_attributes()
+    local header_attributes_extension = M.extensions.header_attributes()
     table.insert(extensions, header_attributes_extension)
   end
 
   if options.jekyllData then
-    jekyll_data_extension = M.extensions.jekyll_data(
+    local jekyll_data_extension = M.extensions.jekyll_data(
       options.expectJekyllData)
     table.insert(extensions, jekyll_data_extension)
   end
 
   if options.pipeTables then
-    pipe_tables_extension = M.extensions.pipe_tables(
+    local pipe_tables_extension = M.extensions.pipe_tables(
       options.tableCaptions)
     table.insert(extensions, pipe_tables_extension)
   end



More information about the tex-live-commits mailing list.