From 7b88c25271448cb717bea52abc52e2c8ec033dd9 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 17 Dec 2022 03:01:08 +0000 Subject: CTAN sync 202212170301 --- macros/luatex/generic/luakeys/README.md | 12 ++- macros/luatex/generic/luakeys/luakeys-debug.sty | 2 +- macros/luatex/generic/luakeys/luakeys-doc.pdf | Bin 286697 -> 395011 bytes macros/luatex/generic/luakeys/luakeys-doc.tex | 98 ++++++++++++++++++++++-- macros/luatex/generic/luakeys/luakeys.lua | 38 ++++++--- macros/luatex/generic/luakeys/luakeys.sty | 2 +- 6 files changed, 134 insertions(+), 18 deletions(-) (limited to 'macros/luatex') diff --git a/macros/luatex/generic/luakeys/README.md b/macros/luatex/generic/luakeys/README.md index bd30edb066..2779de92e8 100644 --- a/macros/luatex/generic/luakeys/README.md +++ b/macros/luatex/generic/luakeys/README.md @@ -97,6 +97,9 @@ local opts = { -- Key-value pair definitions. defs = { key = { default = 'value' } }, + -- Specify the strings that are recognized as boolean false values. + false_aliases = { 'false', 'FALSE', 'False' }, + -- lower, snake, upper format_keys = { 'snake' }, @@ -140,6 +143,8 @@ local opts = { end, }, + invert_flag = '!', + -- Configure the delimiter that separates list items from each other. list_separator = ',', @@ -156,6 +161,9 @@ local opts = { -- Configure the delimiter that marks the end of a string. quotation_end = '"', + -- Specify the strings that are recognized as boolean true values. + true_aliases = { 'true', 'TRUE', 'True' }, + -- { key = { 'value' } } -> { key = 'value' } unpack = false, } @@ -166,8 +174,8 @@ local result = luakeys.parse('one,two,three', opts) `luakeys` is developed using the [Lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) -extension in Visual Studio Code. This extension understands the [EmmyLua -annotations](https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations). +extension in Visual Studio Code. This extension understands the modified +[EmmyLua annotations](https://github.com/sumneko/lua-language-server/wiki/Annotations). The Lua source code documentation is generated with [LDoc](https://stevedonovan.github.io/ldoc/manual/doc.md.html). diff --git a/macros/luatex/generic/luakeys/luakeys-debug.sty b/macros/luatex/generic/luakeys/luakeys-debug.sty index c7748db068..6d60271dd8 100644 --- a/macros/luatex/generic/luakeys/luakeys-debug.sty +++ b/macros/luatex/generic/luakeys/luakeys-debug.sty @@ -17,6 +17,6 @@ % luakeys-debug.sty and luakeys-debug.tex. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luakeys-debug}[2022/11/21 0.9.0 Debug package for luakeys.] +\ProvidesPackage{luakeys-debug}[2022/12/16 0.10.0 Debug package for luakeys.] \input luakeys-debug.tex diff --git a/macros/luatex/generic/luakeys/luakeys-doc.pdf b/macros/luatex/generic/luakeys/luakeys-doc.pdf index e80b60f762..a44a16094e 100644 Binary files a/macros/luatex/generic/luakeys/luakeys-doc.pdf and b/macros/luatex/generic/luakeys/luakeys-doc.pdf differ diff --git a/macros/luatex/generic/luakeys/luakeys-doc.tex b/macros/luatex/generic/luakeys/luakeys-doc.tex index ea427a3c5e..83c708da94 100644 --- a/macros/luatex/generic/luakeys/luakeys-doc.tex +++ b/macros/luatex/generic/luakeys/luakeys-doc.tex @@ -11,6 +11,8 @@ \usepackage{multicol} \usepackage{luacode} \usepackage{syntax} +\usepackage{graphicx} + \usemintedstyle{friendly} \BeforeBeginEnvironment{minted}{\begin{mdframed}} \AfterEndEnvironment{minted}{\end{mdframed}} @@ -58,7 +60,7 @@ The default value of the option “\texttt{#1}” is: \href{https://github.com/Josef-Friedrich/luakeys} {github.com/Josef-Friedrich/luakeys}% } -\date{0.9.0 from 2022/11/21} +\date{0.10.0 from 2022/12/16} \maketitle @@ -357,7 +359,7 @@ The \lua{parse} function can be called with an options table. This options are supported: \catcode`_=12 \directlua{luakeys.print_names('opts')} -\InputLua[firstline=5,lastline=86]{opts/all-opts.lua} +\InputLua[firstline=5,lastline=94]{opts/all-opts.lua} \noindent The options can also be set globally using the exported table @@ -539,6 +541,32 @@ we can write ... % %% +\subsubsection{Option “\texttt{false_aliases}”} +\label{option:false-aliases} + +% Mit den den Optionen \lua{true_aliases} and \lua{false_aliases} können +% die Zeichenketten festgelegt werden, die vom Parser als Wahrheitswerte +% erkannt werden. +The \lua{true_aliases} and \lua{false_aliases} options can be used to +specify the strings that will be recognized as boolean values by the +parser. +% Standardmäßig sind folgende Zeichenketten konfiguriert +The following strings are configured by default. + +\InputLua[firstline=4,lastline=8]{opts/boolean-aliases.lua} + +\InputLua[firstline=14,lastline=18]{opts/boolean-aliases.lua} + +\InputLua[firstline=24,lastline=28]{opts/boolean-aliases.lua} + +% Siehe Abschnitt \label{option:true-aliases} für die entsprechende +% Option. +See section \ref{option:true-aliases} for the corresponding option. + +%% +% +%% + \subsubsection{Option “\texttt{format_keys}”} % Mit Hilfe der Option \lua{format_keys} können die Schlüssel formatiert @@ -570,8 +598,8 @@ table. \item[upper] -% Um alle Schlüssel in \emph{Grossbuchstaben} umzuwandeln, geben sie in der -% Optionentabelle \lua{upper} an. +% Um alle Schlüssel in \emph{Grossbuchstaben} umzuwandeln, geben sie in +% der Optionentabelle \lua{upper} an. To convert all keys to \emph{uppercase}, specify \lua{upper} in the options table. @@ -611,6 +639,45 @@ example can be found in section \ref{options-delimiter}. % %% +\subsubsection{Option “\texttt{invert_flag}”} + +% Wird ein nackter Schlüssel mit einem vorangestellten Ausrufezeichen versehen, so wird sein Standardwert invertiert. +If a naked key is prefixed with an exclamation mark, its default value +is inverted. +% Statt \lua{true} nimmt der Schlüssel jetzt den Wert \lua{falsch} an. +Instead of \lua{true} the key now takes the value \lua{false}. + +\InputLua[firstline=4,lastline=5]{opts/invert-flat.lua} + +\noindent +% Mit der Option \lua{invert_flag} kann dieses Invertierungszeichen +% geändert werden. +The \lua{invert_flag} option can be used to change this inversion +character. + +\InputLua[firstline=11,lastline=12]{opts/invert-flat.lua} + +\noindent +% Ist der Standardwert für nackte Schlüssel beispielweise auf \lua{false} +% gesetzt, so nehmen die mit dem Umkehrungszeichen versehenen nackten +% Schlüssel den Wert \lua{true} an. +For example, if the default value for naked keys is set to \lua{false}, +the naked keys prefixed with the invert flat take the value \lua{true}. + +\InputLua[firstline=18,lastline=19]{opts/invert-flat.lua} + +\noindent +% Setzen sie die Option \lua{invert_flag} auf \lua{false}, um diese +% automatische Wertumkehrung zu deaktivieren. +Set the \lua{invert_flag} option to \lua{false} to disable this +automatic boolean value inversion. + +\InputLua[firstline=25,lastline=26]{opts/invert-flat.lua} + +%% +% +%% + \subsubsection{Option “\texttt{hooks}”} % Die folgenden Hooks bzw. Callback-Funktionen ermöglichen es in den @@ -777,6 +844,15 @@ end of a string. The default value of this option is \texttt{'"'} % %% +\subsubsection{Option “\texttt{true_aliases}”} +\label{option:true-aliases} + +See section \ref{option:false-aliases}. + +%% +% +%% + \subsubsection{Option “\texttt{unpack}”} % Mit Hilfe der Option \lua{unpack} werden alle Tabellen, die nur aus @@ -1841,6 +1917,12 @@ An example of how to use the command in \LaTeX: \end{document} \end{minted} +\section{Activity diagramm of the parsing process} + +\begin{center} +\includegraphics[width=0.8\linewidth]{Activity-Diagramm.eps} +\end{center} + %----------------------------------------------------------------------- % %----------------------------------------------------------------------- @@ -1947,7 +2029,7 @@ An example of how to use the command in \LaTeX: “quotation_end”. * Extend the documentation about the option “format_keys”. } -\changes{0.9.0}{2022/11/21}{ +\changes{0.10.0}{2022/12/16}{ * The definition attibute “pick” accepts a new data type: “any”. * The attribute value “true” for the attribute “pick” is deprecated. * The attribute “pick” accepts now multiple data types specified in @@ -1955,6 +2037,12 @@ An example of how to use the command in \LaTeX: * Add a new function called “any(value)” in the “is” table that accepts any data type. } +\changes{0.10.0}{2022/12/16}{ +* Add support for an invert flat that flips the value of naked keys. +* Add new options to specify which strings are recognized as Boolean + values. +} + \pagebreak \PrintChanges \pagebreak diff --git a/macros/luatex/generic/luakeys/luakeys.lua b/macros/luatex/generic/luakeys/luakeys.lua index a220413390..333b357308 100644 --- a/macros/luatex/generic/luakeys/luakeys.lua +++ b/macros/luatex/generic/luakeys/luakeys.lua @@ -178,15 +178,18 @@ local namespace = { default = true, defaults = false, defs = false, + false_aliases = { 'false', 'FALSE', 'False' }, format_keys = false, group_begin = '{', group_end = '}', hooks = {}, + invert_flag = '!', list_separator = ',', naked_as_value = false, no_error = false, quotation_begin = '"', quotation_end = '"', + true_aliases = { 'true', 'TRUE', 'True' }, unpack = true, }, @@ -439,6 +442,18 @@ local function generate_parser(initial_rule, opts) return white_space ^ 0 * Pattern(match) * white_space ^ 0 end + local line_up_pattern = function(patterns) + local result + for _, pattern in ipairs(patterns) do + if result == nil then + result = Pattern(pattern) + else + result = result + Pattern(pattern) + end + end + return result + end + --- Convert a dimension to an normalized dimension string or an --- integer in the scaled points format. --- @@ -534,15 +549,9 @@ local function generate_parser(initial_rule, opts) Variable('boolean_false') * CaptureConstant(false) ), - boolean_true = - Pattern('true') + - Pattern('TRUE') + - Pattern('True'), + boolean_true = line_up_pattern(opts.true_aliases), - boolean_false = - Pattern('false') + - Pattern('FALSE') + - Pattern('False'), + boolean_false = line_up_pattern(opts.false_aliases), -- for is.dimension() dimension_only = Variable('dimension') * -1, @@ -1191,6 +1200,13 @@ local function parse(kv_string, opts) end return key, value end, + + apply_invert_flag = function(key, value) + if type(key) == 'string' and key:find(opts.invert_flag) then + return key:gsub(opts.invert_flag, ''), not value + end + return key, value + end, } if opts.unpack then @@ -1210,6 +1226,10 @@ local function parse(kv_string, opts) result = visit_tree(result, callbacks.format_key) end + if opts.invert_flag then + result = visit_tree(result, callbacks.apply_invert_flag) + end + return result end result = apply_opts(result, opts) @@ -1250,7 +1270,7 @@ local result_store = {} -- @section local export = { - version = { 0, 9, 0 }, + version = { 0, 10, 0 }, namespace = namespace, diff --git a/macros/luatex/generic/luakeys/luakeys.sty b/macros/luatex/generic/luakeys/luakeys.sty index 459a9157ae..c76025c114 100644 --- a/macros/luatex/generic/luakeys/luakeys.sty +++ b/macros/luatex/generic/luakeys/luakeys.sty @@ -17,5 +17,5 @@ % luakeys-debug.sty and luakeys-debug.tex. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luakeys}[2022/11/21 0.9.0 Parsing key-value options using Lua.] +\ProvidesPackage{luakeys}[2022/12/16 0.10.0 Parsing key-value options using Lua.] \directlua{luakeys = require('luakeys')} -- cgit v1.2.3