summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/latex/contrib/iexec/iexec.dtx90
-rw-r--r--macros/latex/contrib/iexec/iexec.pdfbin324986 -> 326148 bytes
-rw-r--r--macros/latex/contrib/pangram/README.md15
-rw-r--r--macros/latex/contrib/pangram/pangram.dtx430
-rw-r--r--macros/latex/contrib/pangram/pangram.ins91
-rw-r--r--macros/latex/contrib/pangram/pangram.pdfbin0 -> 100389 bytes
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.lua29
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.pdfbin105162 -> 110213 bytes
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.sty23
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.tex28
-rw-r--r--macros/luatex/generic/penlight/penlight.lua202
-rw-r--r--macros/luatex/generic/penlight/penlight.pdfbin42045 -> 59406 bytes
-rw-r--r--macros/luatex/generic/penlight/penlight.sty18
-rw-r--r--macros/luatex/generic/penlight/penlight.tex100
-rw-r--r--macros/luatex/generic/penlight/penlightextras.lua55
15 files changed, 928 insertions, 153 deletions
diff --git a/macros/latex/contrib/iexec/iexec.dtx b/macros/latex/contrib/iexec/iexec.dtx
index bdcb5609c9..30f44bdbf9 100644
--- a/macros/latex/contrib/iexec/iexec.dtx
+++ b/macros/latex/contrib/iexec/iexec.dtx
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{iexec}
%<*package>
-[2022-10-21 0.10.1 Inputable Shell Executions]
+[2022-10-22 0.11.0 Inputable Shell Executions]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -93,15 +93,16 @@
% \end{document}
% \end{docshot}
-% \DescribeMacro{\iexec} The only command provided by this package is |\iexec| \oarg{options} \marg{cmd}.
+% \DescribeMacro{\iexec} The only command provided by this package is
+% |\iexec| \oarg{options} \marg{cmd}.
% Its only mandatory argument \meta{cmd} is the command to be executed
-% through the terminal shell (bash, or whatever is set as the default one
-% on your user console).
+% through the terminal shell (|bash|, or whatever is set as the default one
+% in your console).
% You have to run |pdflatex| (or just |latex|)
% with the |--shell-escape| flag
-% in order to let |shellesc| (the package we use)
-% to execute your shell command.
+% in order to let \href{https://ctan.org/pkg/shellesc}{shellesc}
+% execute your shell command.
% \section{Options}
@@ -150,6 +151,19 @@ Today is \iexec[stderr=my.txt]{broken-command}.
%</verb>
%\fi
+% \DescribeMacro{exit}
+% The exit code of the command it saved into a file. You can change the name of it
+% using |exit| option:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+Today is \iexec[exit=code.txt]{./broken-command.sh}.
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
% \DescribeMacro{trace}
% The file specified will be deleted right after its usage. If you don't
% want this to happen, use |trace| package option: all files will remain
@@ -246,14 +260,17 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
% \end{macrocode}
% Then, we prepare to parse the options of |\iexec| command:
-% \changes{v0.10.0}{2022/10/19}{The option "ignore" suppresses the checking of "iexec.ret" value.}
-% \changes{v0.7.0}{2022/09/25}{The option "append" was introduced --- if it's turned on, stdout will be appended to the file, instead of rewriting it (this is how it was before).}
-% \changes{v0.7.0}{2022/09/25}{The option "log" was introduced, to turn on log/debug messages in TeX log (they were all visible always, which was sometimes annoying. Also, this option enables printing of the entire content of stdout to the log too (this may be pretty convenient for debugging).}
+% \changes{0.10.0}{2022/10/19}{The option "ignore" suppresses the checking of "iexec.ret" value.}
+% \changes{0.7.0}{2022/09/25}{The option "append" was introduced --- if it's turned on, stdout will be appended to the file, instead of rewriting it (this is how it was before).}
+% \changes{0.7.0}{2022/09/25}{The option "log" was introduced, to turn on log/debug messages in TeX log (they were all visible always, which was sometimes annoying. Also, this option enables printing of the entire content of stdout to the log too (this may be pretty convenient for debugging).}
+% \changes{0.11.0}{2022/10/22}{The option "exit" allows to change the name of the file with exit code.}
% \begin{macrocode}
\RequirePackage{pgfkeys}
\makeatletter\pgfkeys{
/iexec/.is family,
/iexec,
+ exit/.store in = \iexec@exit,
+ exit/.default = iexec.ret,
stdout/.store in = \iexec@stdout,
stdout/.default = iexec.tmp,
stderr/.store in = \iexec@stderr,
@@ -263,7 +280,7 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
null/.store in = \iexec@null,
quiet/.store in = \iexec@quiet,
ignore/.store in = \iexec@ignore,
- stdout
+ stdout,exit
}\makeatother
% \end{macrocode}
@@ -290,10 +307,10 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
% \begin{macro}{\iexec}
% Then, we define |\iexec| command.
% It is implemented with the help of |\ShellEscape| from |shellesc| package:
-% \changes{v0.10.0}{2022/10/19}{The file "iexec.ret" is reused for all scripts.}
+% \changes{0.10.0}{2022/10/19}{The file "iexec.ret" is reused for all scripts.}
% \begin{macrocode}
\makeatletter
-\newread\iexec@retfile
+\newread\iexec@exitfile
\newcommand\iexec[2][]{%
\begingroup%
\pgfqkeys{/iexec}{#1}%
@@ -323,15 +340,16 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
\let\}\@charrb%
% \end{macrocode}
% Then, we execute it:
-% \changes{v0.10.0}{2022/10/19}{The ability to track exit code was added. Now, the code is saved into "iexec.ret" file, which is then read and checked for zero value.}
-% \changes{v0.8.0}{2022/10/05}{The option "null" was introduced, allowing redirection of stdout to "/dev/null". Doesn't work on Windows, though.}
-% \changes{v0.9.0}{2022/10/15}{The option "stderr" was introduced, allowing redirection of stderr to a file. Without this option specified, stderr will go to stdout.}
+% \changes{0.10.0}{2022/10/19}{The ability to track exit code was added. Now, the code is saved into "iexec.ret" file, which is then read and checked for zero value.}
+% \changes{0.8.0}{2022/10/05}{The option "null" was introduced, allowing redirection of stdout to "/dev/null". Doesn't work on Windows, though.}
+% \changes{0.9.0}{2022/10/15}{The option "stderr" was introduced, allowing redirection of stderr to a file. Without this option specified, stderr will go to stdout.}
+% \changes{0.11.0}{2022/10/22}{The file with exit code now contains just numbers, without end of line.}
% \begin{macrocode}
\def\iexec@cmd{(#2)
\ifdefined\iexec@append>\fi>
\ifdefined\iexec@null/dev/null\else\iexec@stdout\fi
- \space\ifdefined\iexec@stderr2>\iexec@stderr\else2>&1\fi
- \ifdefined\iexec@ignore\else; echo $? >iexec.ret\fi}
+ \space\ifdefined\iexec@stderr2>\iexec@stderr\else2>&1\fi;
+ /bin/echo -n $? >\iexec@exit}
\ShellEscape{\iexec@cmd}%
% \end{macrocode}
% Then, a message is printed to TeX log:
@@ -350,14 +368,20 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
\message{<EOF>^^J}%
\fi\fi%
% \end{macrocode}
-% Then, we check exit code:
+% Then, we check exit code, unless there is |ignore| option:
% \begin{macrocode}
- \ifdefined\iexec@log\else%
- \immediate\openin\iexec@retfile=iexec.ret%
- \read\iexec@retfile to \iexec@ret%
- \immediate\closein\iexec@retfile%
- \ifnum\iexec@ret=0\else%
- \PackageError{iexec}{Exit code is \iexec@ret}{}%
+ \immediate\openin\iexec@exitfile=\iexec@exit%
+ \read\iexec@exitfile to \iexec@code%
+ \immediate\closein\iexec@exitfile%
+ \ifnum\iexec@code=0\else%
+ \ifdefined\iexec@ignore%
+ \ifdefined\iexec@log%
+ \message{iexec: Execution failure ignored,
+ the exit code was \iexec@code^^J}%
+ \fi%
+ \else%
+ \PackageError{iexec}{Execution failure,
+ the exit code was \iexec@code}{}%
\fi%
\fi%
% \end{macrocode}
@@ -368,13 +392,13 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
\ifdefined\iexec@log%
\message{iexec: Due to 'quiet' option we didn't read
the content of '\iexec@stdout'
- \ifdefined\pdffilesize(\pdffilesize{\iexec@stdout}
+ \ifdefined\pdffilesize (\pdffilesize{\iexec@stdout}
bytes)\fi^^J}%
\fi%
\else%
\ifdefined\iexec@log%
- \message{iexec: We include the content of
- '\iexec@stdout'\ifdefined\pdffilesize(\pdffilesize
+ \message{iexec: We are going to include the content of
+ '\iexec@stdout'\ifdefined\pdffilesize (\pdffilesize
{\iexec@stdout} bytes)\fi...^^J}%
\fi%
\input{\iexec@stdout}%
@@ -388,19 +412,25 @@ This file won't be deleted: \iexec[stdout=me.txt]{whoami}.
\ifiexec@trace%
\ifdefined\iexec@log%
\message{iexec: Due to package option 'trace',
- the file '\iexec@stdout' was not deleted^^J}%
+ the files '\iexec@stdout' and `\iexec@exit` were
+ not deleted^^J}%
\fi%
\else%
\ifdefined\iexec@traceit%
\ifdefined\iexec@log%
- \message{iexec: Due to 'trace' option,
- the file '\iexec@stdout' was not deleted^^J}%
+ \message{iexec: Due to 'trace' package option,
+ the files '\iexec@stdout' and '\iexec@exit'
+ were not deleted^^J}%
\fi%
\else%
\ShellEscape{rm \iexec@stdout}%
\ifdefined\iexec@log%
\message{iexec: The file '\iexec@stdout' was deleted^^J}%
\fi%
+ \ShellEscape{rm \iexec@exit}%
+ \ifdefined\iexec@log%
+ \message{iexec: The file '\iexec@exit' was deleted^^J}%
+ \fi%
\fi%
\fi\fi%
\endgroup
diff --git a/macros/latex/contrib/iexec/iexec.pdf b/macros/latex/contrib/iexec/iexec.pdf
index 96f30b1582..e4633ab765 100644
--- a/macros/latex/contrib/iexec/iexec.pdf
+++ b/macros/latex/contrib/iexec/iexec.pdf
Binary files differ
diff --git a/macros/latex/contrib/pangram/README.md b/macros/latex/contrib/pangram/README.md
new file mode 100644
index 0000000000..c68863edef
--- /dev/null
+++ b/macros/latex/contrib/pangram/README.md
@@ -0,0 +1,15 @@
+# The `pangram` Package
+
+The `pangram` package aims to provide an easy way for testing fonts.
+
+See `pangram.pdf` for more. Happy TeXing!
+
+## License
+
+This work may be distributed and/or modified under the conditions of
+the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
+either version 1.3c of this license or (at your option) any later version.
+
+------
+
+Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>.
diff --git a/macros/latex/contrib/pangram/pangram.dtx b/macros/latex/contrib/pangram/pangram.dtx
new file mode 100644
index 0000000000..8c33d97955
--- /dev/null
+++ b/macros/latex/contrib/pangram/pangram.dtx
@@ -0,0 +1,430 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3c 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 Zhang Tingxuan.
+%
+% This work consists of the files pangram.dtx,
+% and the derived files pangram.ins,
+% pangram.sty,
+% pangram.pdf,
+% and README.md.
+%
+%<*internal>
+\iffalse
+%</internal>
+%
+%<*readme>
+# The `pangram` Package
+
+The `pangram` package aims to provide an easy way for testing fonts.
+
+See `pangram.pdf` for more. Happy TeXing!
+
+## License
+
+This work may be distributed and/or modified under the conditions of
+the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
+either version 1.3c of this license or (at your option) any later version.
+
+------
+
+Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>.
+%</readme>
+%
+%<*internal>
+\fi
+\begingroup
+ \def\NameOfLaTeXe{LaTeX2e}
+\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
+\csname fi\endcsname
+%</internal>
+%
+%<*install>
+\input docstrip.tex
+\keepsilent
+
+\preamble
+
+ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c 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 Zhang Tingxuan.
+
+ This work consists of the files pangram.dtx,
+ and the derived files pangram.ins,
+ pangram.sty,
+ pangram.pdf,
+ and README.md.
+
+\endpreamble
+
+\generate{
+ \usedir{tex/latex/pangram}
+ \file{\jobname.sty} {\from{\jobname.dtx}{package}}
+%</install>
+%<*internal>
+ \usedir{source/latex/pangram}
+ \file{\jobname.ins} {\from{\jobname.dtx}{install}}
+%</internal>
+%<*install>
+ \usedir{doc/latex/pangram}
+ \nopreamble\nopostamble
+ \file{README.md} {\from{\jobname.dtx}{readme}}
+}
+
+\obeyspaces
+\Msg{****************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the *}
+\Msg{* following file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* pangram.sty *}
+\Msg{* *}
+\Msg{* The recommended directory is *}
+\Msg{* TDS:tex/latex/pangram *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file *}
+\Msg{* pangram.dtx through XeLaTeX/LuaLaTeX. *}
+\Msg{* XeLaTeX and LuaLaTeX are recommended if you *}
+\Msg{* hope the PDF file to be smaller. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{****************************************************}
+
+\endbatchfile
+%</install>
+%
+%<*internal>
+\fi
+%</internal>
+%
+%<*driver>
+\ProvidesFile{pangram.dtx}[2022/10/9 (c) Copyright 2022 by Zhang Tingxuan]
+\documentclass{ltxdoc}
+
+\usepackage[letterpaper,left=5cm,right=4cm,top=4cm,bottom=4cm,
+ includeheadfoot]{geometry}
+
+\usepackage{xcolor}
+\definecolor{titlecolor}{RGB}{0,12,160}
+\usepackage{doc}
+\usepackage{fancyvrb}
+\fvset{xleftmargin=2.5em,fontsize=\small,gobble=2}
+\MakeShortVerb|
+
+\usepackage{hologo}
+\def\XeTeX{\hologo{XeTeX}}
+\def\LuaTeX{\hologo{LuaTeX}}
+
+\def\pkg{\textsf}
+\def\opt{\texttt}
+
+\title{\leavevmode\hbox to 0pt{\hss\huge The quick brown fox jumps over the lazy dog\hss}\\
+ --- The \pkg{pangram} package}
+\author{Zhang Tingxuan}
+\long\date{2022/10/9\quad Version 0.0b\thanks{\url{https://github.com/AlphaZTX/pangram}
+If you want to maintain this package, just contact me through GitHub issues or pull a
+request.}}
+
+\usepackage{hyperref}
+\hypersetup{
+ pdftitle = {The pangram Package},
+ pdfauthor = {Zhang Tingxuan},
+ pdfcreator = {XeLaTeX/LuaLaTeX},
+ linkcolor = black,
+ urlcolor = titlecolor!80!black,
+}
+\def\pkg{\textsf}
+
+\makeatletter
+\renewcommand\section{\@startsection{section}{1}{\z@}%
+ {-2.5ex plus -1ex minus -.2ex}%
+ {1ex plus .2ex}%
+ {\normalfont\Large\bfseries\color{titlecolor}}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-2ex plus -1ex minus -.2ex}%
+ {.5ex plus .2ex}%
+ {\normalfont\normalsize\bfseries\color{titlecolor}}}
+\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
+ {.8ex plus .4ex minus .2ex}%
+ {-1em}%
+ {\normalfont\normalsize\bfseries\color{titlecolor}}}
+\makeatother
+\usepackage{fontspec}
+\setmainfont{Latin Modern Roman}
+\setsansfont{Latin Modern Sans}
+\setmonofont{Latin Modern Mono}
+\usepackage{ragged2e}
+\usepackage{pangram}
+
+\linespread{1.05}
+\parskip12pt plus 3pt minus 2pt
+\parindent2.5em
+\RaggedRight
+
+\begin{document}
+ \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+%
+% \maketitle
+%
+% \begin{abstract}
+% Pangram is a phrase or sentence containing all letters in an alphabet,
+% usually used for testing fonts. One famous pangram is ``The quick brown
+% fox jumps over the lazy dog''. This package provide a (somewhat) simple
+% way for font designers or users to test fonts.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
+% \pangram[
+% sizes = { 5pt, 6pt, 7pt, 8pt, 9pt,
+% 10pt, 11pt, 12pt, 14pt, 16pt,
+% 18pt, 20pt, 22pt, 24pt, 30pt,
+% 36pt, 40pt, 44pt, 48pt, 64pt,
+% 72pt, 96pt},
+% linegap = 0pt plus 1fil,
+% tagfont = \ttfamily\footnotesize\color{gray},
+% font = \fontspec{Latin Modern Roman},
+% after = \thispagestyle{empty},
+% ]
+% \restoregeometry
+%
+% \section{How to use this package}
+% To load the package, just write
+% \begin{Verbatim}
+% \usepackage{pangram}
+% \end{Verbatim}
+% in preamble.
+%
+% Then in your document, write
+% \begin{Verbatim}
+% \pangram
+% \end{Verbatim}
+% to get the result like the previous page.
+%
+% Please notice that \cs{pangram} will stay in a seperate page.
+%
+% \section{Options}
+% The \cs{pangram} command can receive an optional key-val list
+% specifying the details of the pangram page. Here are the keys:
+% \begin{itemize}
+% \item \opt{textclass} stands for the pangram text in pangram page.
+% The default value is \opt{default}, yields ``The quick brown fox
+% jumps over the lazy dog. 0123456789''. \opt{uppercase} and \opt{glass}
+% are also available, which yields ``THE QUICK BROWN FOX JUMPS OVER THE
+% LAZY DOG. 0123456789'' and ``I can eat glass and it doesn't hurt me.''
+% (although the latter one cannot be regarded as pangram).
+%
+% \item \opt{sizes} for the sizes shown in \cs{pangram}. Default value is
+% \texttt{\{5pt, 7pt, 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 16pt, 18pt, 20pt,
+% 22pt, 24pt, 36pt, 48pt, 60pt, 72pt\}}.
+%
+% \item \opt{linegap} is the line skip between two lines in \cs{pangram}.
+% Default value is \opt{5pt plus 3pt minus 2pt}.
+%
+% \item \opt{tagskip} is the skip between the tag and the pangram text.
+% Default value is \opt{5pt}.
+%
+% \item \opt{tagfont} sets the font of tag. Default value is
+% |\ttfamily\footnotesize|.
+%
+% \item \opt{font} sets the font of pangram text. Default value is empty.
+%
+% \item \opt{before} stands for the content before pangram text in pangram page.
+% Default value is empty.
+%
+% \item \opt{after} stands for the content after pangram text in pangram page.
+% Default value is empty.
+% \end{itemize}
+% If you want to set the keys globally, use \cs{PangramSetup} in your preamble,
+% the argument of \cs{PangramSetup} is the same as the one of \cs{pangram}.
+%
+% Attention! If any of the value to the keys contains an ``\opt{=}'' symbol,
+% the value should be put into a group. For example,
+% \begin{Verbatim}
+% \pangram[ font={\fontspec{Latin Modern Roman}[Mapping=tex-text]} ]
+% \end{Verbatim}
+%
+% \section{New pangram text classes}
+% Besides the three pre-defined pangram text classes, you can define your own
+% pangram text classes through \cs{NewPangramClass}:
+%
+% \cs{NewPangramClass}\marg{text class}\marg{text}
+%
+% \section{A complicated example}
+% Set the package globally (used in preamble):
+% \begin{Verbatim}
+% \PangramSetup{
+% sizes={9bp,10bp,12bp,20bp,36bp,44bp,48bp,64bp},
+% tagfont=\color{gray}\ttfamily\footnotesize,
+% }
+% \NewPangramClass{abc}{abcdefghijklmnopqrstuvwxyz}
+% \end{Verbatim}
+%
+% Get the result locally (Needs \pkg{fontspec} package and any package provides
+% \cs{color} command):
+% \begin{Verbatim}
+% \pangram[font=\fontspec{Latin Modern Roman}]
+% \pangram[textclass=glass,
+% font={\fontspec{Latin Modern Sans}[Mapping=tex-text]}]
+% \pangram[textclass=abc,font=\fontspec{Latin Modern Mono}]
+% \end{Verbatim}
+% The text class \opt{abc} here is defined in the previous paragraph.
+%
+% \section{The source code}
+% \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}[2022/06/01]
+\ProvidesPackage{pangram}[2022/10/09 Pangram, a tool for testing fonts]
+% \end{macrocode}
+% Use a \opt{clist} to restore the sizes for \cs{pangram},
+% and an integer for its index (here we use \opt{index} instead
+% of \opt{int}).
+% \begin{macrocode}
+\ExplSyntaxOn
+\clist_new:N \l_pangram_sizes_clist
+\int_new:N \l_pangram_size_index
+\clist_set:Nn \l_pangram_sizes_clist
+ {
+ 5pt, 7pt, 8pt, 9pt, 10pt, 11pt,
+ 12pt, 14pt, 16pt, 18pt, 20pt, 22pt,
+ 24pt, 36pt, 48pt, 60pt, 72pt
+ }
+% \end{macrocode}
+% Three pre-defined text classes (token lists) for \cs{pangram}.
+% \begin{macrocode}
+\tl_const:Nn \c_pangram_text_default_tl
+ { The~quick~brown~fox~jumps~over~the~lazy~dog. ~ 0123456789 }
+\tl_const:Nn \c_pangram_text_uppercase_tl
+ { THE~QUICK~BROWN~FOX~JUMPS~OVER~THE~LAZY~DOG. ~ 0123456789 }
+\tl_const:Nn \c_pangram_text_glass_tl
+ { I~can~eat~glass~and~it~doesn't~hurt~me. }
+% \end{macrocode}
+% \DescribeMacro{\NewPangramClass}
+% Use way equivalent to \cs{csname}\dots\cs{endcsname} to define
+% new text classes.
+% \begin{macrocode}
+\NewDocumentCommand \NewPangramClass { m m }
+ {
+ \exp_after:wN \tl_const:Nn \cs:w c_pangram_text_#1_tl \cs_end: { #2 }
+ }
+% \end{macrocode}
+% Inner function for \opt{sizes} option. Here use the \pkg{xparse}'s new
+% \cs{IfBlankTF} mechanism to judge if the sizes should be reset.
+% \begin{macrocode}
+\NewDocumentCommand \pangram_resetsizes:n { m }
+ {
+ \IfBlankF {#1} { \clist_set:Nn \l_pangram_sizes_clist { #1 } }
+ }
+% \end{macrocode}
+% The keys.
+% \begin{macrocode}
+\keys_define:nn { pangram }
+ {
+ textclass.tl_set:N = \l_pangram_textclass_tl ,
+ textclass.default:n = default ,
+ textclass.initial:n = default ,
+ sizes.code:n = \pangram_resetsizes:n { #1 } ,
+ linegap.skip_set:N = \l_pangram_linegap_skip ,
+ linegap.default:n = 5pt plus 3pt minus 2pt ,
+ linegap.initial:n = 5pt plus 3pt minus 2pt ,
+ tagskip.skip_set:N = \l_pangram_tagskip_skip ,
+ tagskip.default:n = 5pt ,
+ tagskip.initial:n = 5pt ,
+ tagfont.tl_set:N = \l_pangram_tagfont_tl ,
+ tagfont.default:n = \ttfamily \footnotesize ,
+ tagfont.initial:n = \ttfamily \footnotesize ,
+ font.tl_set:N = \l_pangram_font_tl ,
+ before.tl_set:N = \l_pangram_before_tl ,
+ after.tl_set:N = \l_pangram_after_tl ,
+ }
+% \end{macrocode}
+% \DescribeMacro{\PangramSetup}
+% Set up the package in preamble.
+% \begin{macrocode}
+\NewDocumentCommand \PangramSetup { m }
+ { \keys_set:nn { pangram } { #1 } }
+% \end{macrocode}
+% \DescribeMacro{\pangram}
+% The function itself.
+% \begin{macrocode}
+\NewDocumentCommand \pangram { +O{} }
+ {
+ \group_begin:
+ \keys_set:nn { pangram } { #1 }
+ \clearpage
+ \skip_set:Nn \parskip { \c_zero_dim }
+% \end{macrocode}
+% Use a loop to get all of the entries in the sizes \opt{clist}.
+% \begin{macrocode}
+ \int_set:Nn \l_pangram_size_index { 0 }
+ \tl_use:N \l_pangram_before_tl
+ \int_do_while:nNnn
+ { \l_pangram_size_index } < { \clist_count:N \l_pangram_sizes_clist }
+ {
+ \mode_leave_vertical:
+ \int_incr:N \l_pangram_size_index % index++;
+ \hbox_to_zero:n
+ {
+ \hss
+ \tl_use:N \l_pangram_tagfont_tl
+ \clist_item:Nn \l_pangram_sizes_clist { \l_pangram_size_index }
+ \skip_horizontal:N \l_pangram_tagskip_skip
+ }
+ \hbox_to_zero:n
+ {
+ \tl_use:N \l_pangram_font_tl
+ \fontsize
+ { \clist_item:Nn \l_pangram_sizes_clist { \l_pangram_size_index } }
+ { \c_zero_dim } % \z@
+ \selectfont
+ \tl_use:c { c_pangram_text_ \tl_use:N \l_pangram_textclass_tl _tl }
+ \hss
+ }
+ \int_compare:nNnT
+ { \l_pangram_size_index } = { \clist_count:N \l_pangram_sizes_clist }
+ { \skip_set:Nn \l_pangram_linegap_skip {0pt} }
+ \par
+ \skip_vertical:N \l_pangram_linegap_skip
+ }
+% \end{macrocode}
+% The loop ends here.
+% \begin{macrocode}
+ \tl_use:N \l_pangram_after_tl
+ \clearpage
+ \group_end:
+ }
+\ExplSyntaxOff
+%</package>
+% \end{macrocode}
+\endinput \ No newline at end of file
diff --git a/macros/latex/contrib/pangram/pangram.ins b/macros/latex/contrib/pangram/pangram.ins
new file mode 100644
index 0000000000..1c300da357
--- /dev/null
+++ b/macros/latex/contrib/pangram/pangram.ins
@@ -0,0 +1,91 @@
+%%
+%% This is file `pangram.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% pangram.dtx (with options: `install')
+%%
+%% Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c 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 Zhang Tingxuan.
+%%
+%% This work consists of the files pangram.dtx,
+%% and the derived files pangram.ins,
+%% pangram.sty,
+%% pangram.pdf,
+%% and README.md.
+%%
+\input docstrip.tex
+\keepsilent
+
+\preamble
+
+ Copyright (C) 2022 by Zhang Tingxuan <alphaztx@163.com>
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c 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 Zhang Tingxuan.
+
+ This work consists of the files pangram.dtx,
+ and the derived files pangram.ins,
+ pangram.sty,
+ pangram.pdf,
+ and README.md.
+
+\endpreamble
+
+\generate{
+ \usedir{tex/latex/pangram}
+ \file{\jobname.sty} {\from{\jobname.dtx}{package}}
+ \usedir{doc/latex/pangram}
+ \nopreamble\nopostamble
+ \file{README.md} {\from{\jobname.dtx}{readme}}
+}
+
+\obeyspaces
+\Msg{****************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the *}
+\Msg{* following file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* pangram.sty *}
+\Msg{* *}
+\Msg{* The recommended directory is *}
+\Msg{* TDS:tex/latex/pangram *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file *}
+\Msg{* pangram.dtx through XeLaTeX/LuaLaTeX. *}
+\Msg{* XeLaTeX and LuaLaTeX are recommended if you *}
+\Msg{* hope the PDF file to be smaller. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{****************************************************}
+
+\endbatchfile
+\endinput
+%%
+%% End of file `pangram.ins'.
diff --git a/macros/latex/contrib/pangram/pangram.pdf b/macros/latex/contrib/pangram/pangram.pdf
new file mode 100644
index 0000000000..008be5a8f8
--- /dev/null
+++ b/macros/latex/contrib/pangram/pangram.pdf
Binary files differ
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.lua b/macros/luatex/generic/lutabulartools/lutabulartools.lua
index 361530bc97..24c8d5598e 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.lua
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2022-10-15
+--% 2022-10-22
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,8 @@
local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
if (__PL_EXTRAS__ == nil) or (__PENLIGHT__ == nil) then
- tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasnoglobals) option must be loaded before this package}{}')
+ tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}')
+ tex.print('\\stop')
end
local ltt = {}
@@ -111,7 +112,7 @@ function ltt.MagicCell(s0,spec,mcspec,pre,content)
ltt.debugtalk(pl.List{v, h, r, c, mcspec}:join'; ','v, h, r, c, mcspec')
--help_wrt(_CurTabColAbv,'current column')
- if s0 == _xTrue or (pl.List(ltt.SI_cols):contains(ltt.col) -- special columns for SI
+ if s0 == pl.tex._xTrue or (pl.List(ltt.SI_cols):contains(ltt.col) -- special columns for SI
and c == '') then -- multicolumn cannot have {} around it
STR = STR .. '{' -- multirow and makcell must have {} around it S column is used
pl.tex.add_bkt_cnt()
@@ -266,8 +267,6 @@ function ltt.make1cmidrule(s, r, c, cmd) -- s=square r=round c=curly
end
c = ltt.get_midrule_col(t[1])..'-'..ltt.get_midrule_col(t[2])
cmd = cmd..'{'..c..'}'
- --help_wrt(cmd)
-
ltt.debugtalk(cmd,'make1cmidrule')
tex.print(cmd)
end
@@ -303,28 +302,34 @@ function ltt.mrX.set_midruleX(new_sett, def)
end
new_sett = luakeys.parse(new_sett)
ltt.mrX.settings = T.union(curr_sett, new_sett)
- ltt.debugtalk{ltt.mrX.settings, 'new settings'}
+ ltt.debugtalk(ltt.mrX.settings, 'new midruleX settings')
ltt.mrX.cntr = curr_sett.cntr
end
function ltt.mrX.midruleX(n)
n = n or '' -- todo placeholder for noalign ?
local s = ltt.mrX.settings
+ local rule = s.rule
if pl.hasval(s.reset) and ltt.mrX.add_label_and_check_page_change() then ltt.mrX.cntr = s.resetnum end
ltt.mrX.cntr = ltt.mrX.cntr + 1
if ltt.mrX.cntr == s.step then
- ltt.debugtalk{s.rule, 'apply midruleX'}
- tex.sprint('\\'..s.rule)
+ if not rule:startswith('\\') then rule = '\\'..rule end -- todo consider allowing \gmidrule syntax, possible issue with expansion
+ ltt.debugtalk(rule, 'apply midruleX')
+ tex.sprint(rule)
ltt.mrX.cntr = 0
end
end
function ltt.mrX.add_label_and_check_page_change()
- ltt.mrX.pgcntr = ltt.mrX.pgcntr + 1
+ ltt.mrX.pgcntr = ltt.mrX.pgcntr + 1
tex.print('\\noalign{\\label{ltt@tabular@row@'..ltt.mrX.pgcntr..'}}')
- local _, pgcurr = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr)
- local _, pgprev = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr-1)
- if pgcurr ~= pgprev then
+ local rcurr = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr)
+ local rprev = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr-1)
+ --local rcurrc, _, _ = pl.tex.get_ref_info_all_cref('ltt@tabular@row@'..ltt.mrX.pgcntr)
+ ltt.debugtalk('curr: '..rcurr[2]..' prev: '..rprev[2]..' row: '..ltt.mrX.pgcntr, 'check midruleX page change')
+ ltt.debugtalk(rcurr, 'miduleX current reference info for row: '..ltt.mrX.pgcntr)
+ --ltt.debugtalk(rcurrc, 'miduleX current cleveref cref info')
+ if rcurr[2] ~= rprev[2] then -- pg no is second element
return true
end
return false
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.pdf b/macros/luatex/generic/lutabulartools/lutabulartools.pdf
index 789cf01125..5d6e7f62d0 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.pdf
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.pdf
Binary files differ
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.sty b/macros/luatex/generic/lutabulartools/lutabulartools.sty
index 5a501a8346..f1dea60c5a 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.sty
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-10-15
+% 2022-10-22
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,7 +23,7 @@
% OR OTHER DEALINGS IN THE SOFTWARE.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lutabulartools}[2022-10-15]
+\ProvidesPackage{lutabulartools}[2022-10-22]
\RequirePackage{booktabs}
\RequirePackage{multirow}
@@ -53,7 +53,10 @@
\def\midruleX{\aftergroup\aftergroup\aftergroup\midruleX@aux}
\def\midruleX@aux{\luadirect{lutabt.mrX.midruleX('')}} % todo argument for vadjust or noalign??
-\NewDocumentCommand{\setmidruleX}{s m}{\luadirect{lutabt.mrX.set_midruleX(\luastring{#2}, \luastring{#1})}}
+\NewDocumentCommand{\setmidruleX}{s O{N} m}{%
+ \MakeluastringCommands[N]{#2}%
+ \luadirect{lutabt.mrX.set_midruleX(\plluastringA{#3}, \luastring{#1})}%
+}
\NewDocumentCommand{\midruleXreset}{O{0}}{\luadirect{lutabt.mrX.cntr = tonumber(\luastring{#1})}}
\NewCommandCopy\resetmidruleX\midruleXreset
@@ -141,14 +144,14 @@
\let\oldtabular\tabular
-\RenewExpandableDocumentCommand{\tabular}{ O{c} m }{%
+\RenewExpandableDocumentCommand{\tabular}{ O{l} m }{%
\luadirect{lutabt.set_col_spec(\luastringN{#2})}%
\oldtabular[#1]{\ltt@ltrim#2\ltt@rtrim}%
}
\expandafter\let\expandafter\oldtabulars\csname tabular*\endcsname
\expandafter\let\expandafter\endoldtabulars\csname endtabular*\endcsname
-\RenewDocumentEnvironment{tabular*}{ m O{c} m }{%
+\RenewDocumentEnvironment{tabular*}{ m O{l} m }{%
\luadirect{lutabt.set_col_spec(\luastringN{#3})}%
\begin{oldtabulars}{#1}[#2]{\ltt@ltrim#3\ltt@rtrim}%
}{%
@@ -156,6 +159,12 @@
}
%%% NOTE tabularx uses tabular*, NO NEED TO CHANGE TABULARX!
+\let\oldlongtable\longtable
+\RenewExpandableDocumentCommand{\longtable}{ O{l} m }{%
+ \luadirect{lutabt.set_col_spec(\luastringN{#2})}%
+ \oldlongtable[#1]{\ltt@ltrim#2\ltt@rtrim}%
+}
+
%s0,spec,mcspec,pre,content
% Magic Cell
@@ -184,6 +193,10 @@
lutabt.SI_cols[\string##lutabt.SI_cols+1] = '#1'
}}
+\NewDocumentCommand{\forcecolspec}{ m }{\luadirect{
+ lutabt.col_spec = (\luastring{#1}):totable()
+}}
+
\ProcessOptions
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.tex b/macros/luatex/generic/lutabulartools/lutabulartools.tex
index ecc35df511..97802fce07 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.tex
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-10-15
+% 2022-10-22
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -62,9 +62,12 @@
\newcommand{\tMC}{\cmd{\\MC}}
+\usepackage{caption}
+
+\usepackage{ltxtable}
\usepackage{longtable}
-\usepackage[pl,extrasnoglobals]{penlight}
+\usepackage[pl,extras]{penlight}
\RequirePackage{lutabulartools}
@@ -78,6 +81,7 @@
\usepackage{hyperref}
+
\begin{document}
% todo: can improve naming... set col spec to a table instead of a string
@@ -85,10 +89,9 @@
\maketitle
-lutabulartools is a package that contains a few useful macros to help with tables.
-Most functions require LuaLaTeX.
+lutabulartools is a package that contains a few useful Lua\LaTeX-based macros to help with tables.
This package redefines the {\ttfamily tabular} and {\ttfamily tabular*} environments.
-The following packages are loaded:
+The following packages are loaded if not already, so if you have specific settings for these packages, load this package after:
\texttt{
{booktabs},
{multirow},
@@ -186,7 +189,6 @@ To add a column that should be surrounded by brackets for \cmd{siunitx} purposes
S is included by default.
-\newpage
\subsection{Examples}
@@ -350,11 +352,14 @@ Concering \cmd{longtable}s: If \cmd{reset} is set to \cmd{true},
resets the row counter to \cmd{resetnum}, to ensure you have the same X number of rows after the header of each page of a \cmd{longtable}.\\
The starred version of first reverts the settings to default, then loads your inputted settings, which the non-starred
version only overwrites the settings specified. \cmd{\setmidruleX*{}} will restore to default.
+Use optional parameter \cmd{\setmidruleX*[o|n|f]{}}
+to control expansion of the key-val settings (\cmd{[n]} for not expanded is default).
Before you want counting to begin, you should
apply \cmd{\resetmidruleX} to avoid header rows being counted.
Use \cmd{\noalign{\resetmiduleX}} if you need place a rule on the same line the reset takes place, or in a cell before \cmd{\\}.
Note that \cmd{\resetmidruleX} resets the row counter to 0, and is in effect, a short-cut for \cmd{\setmidruleX{}} or \cmd{\setmidruleX{cntr=0}}
+
%
%\begin{tabular}{l@{\luadirect{tex.print('\\midrule')}}}
% Hello \\
@@ -395,7 +400,7 @@ Num & . & . & . \\
Here's an example with long table. Notice the gray rules reliably appear 3 rows after each header.
\begin{verbatim}
-\setmidruleX{reset=true,resetnum=0}
+\setmidruleX{reset=true,resetnum=0,rule="\gcmidrules{1r,2-}"}
\def\tblhead{\toprule No & Name & Place & other\\\midrule}
\def\tblcontinued{\MC[+l]{Continued...}\\}
\def\tblcontinues\MC[+r]{...Continues}\\}
@@ -421,13 +426,13 @@ Here's an example with long table. Notice the gray rules reliably appear 3 rows
14 & & & \\
15 & & & \\\newpage
16 & & & \\
-17 & & & \\\resetmidruleX
-18 & & & \\
+17 & & & \\
+18 & & & \\\resetmidruleX
19 & & & \\
\end{longtable}
\end{verbatim}
-\setmidruleX{reset=true,resetnum=0}
+\setmidruleX{reset=true,resetnum=0,rule="\gcmidrules{1r,2-}"}
\def\tblhead{\toprule No & Name & Place & other\\\midrule}
\def\tblcontinued{\MC[+l]{Continued...}\\}
\def\tblcontinues{\MC[+r]{...Continues}\\}
@@ -459,4 +464,7 @@ Here's an example with long table. Notice the gray rules reliably appear 3 rows
\end{longtable}
+\LTXtable{\linewidth}{ltxexample}
+
+
\end{document}
diff --git a/macros/luatex/generic/penlight/penlight.lua b/macros/luatex/generic/penlight/penlight.lua
index 4b2436be1b..6ffcaf49b7 100644
--- a/macros/luatex/generic/penlight/penlight.lua
+++ b/macros/luatex/generic/penlight/penlight.lua
@@ -133,10 +133,11 @@ function _M.parse(text_or_filename, is_file, use_basic)
end
if is_file then
- local text_or_filename, err = utils.readfile(text_or_filename)
- if not text_or_filename then
+ local text, err = utils.readfile(text_or_filename)
+ if not text then
return nil, err
end
+ text_or_filename = text
end
local doc, err = parser(text_or_filename)
@@ -1219,12 +1220,24 @@ end
--
-- Note: the path is prefixed, so it is searched first when requiring modules.
-- @string base optional base directory (absolute, or relative path).
+-- @bool nofollow always use the invocation's directory, even if the invoked file is a symlink
-- @treturn string the current script's path with a trailing slash
-function app.require_here (base)
- local p = path.dirname(app.script_name())
+function app.require_here (base, nofollow)
+ local p = app.script_name()
if not path.isabs(p) then
p = path.join(path.currentdir(),p)
end
+ if not nofollow then
+ local t = path.link_attrib(p)
+ if t and t.mode == 'link' then
+ t = t.target
+ if not path.isabs(t) then
+ t = path.join(path.dirname(p), t)
+ end
+ p = t
+ end
+ end
+ p = path.normpath(path.dirname(p))
if p:sub(-1,-1) ~= path.sep then
p = p..path.sep
end
@@ -2583,9 +2596,9 @@ end
-- This functions mimics the `warn` function added in Lua 5.4.
-- @function warn
-- @param ... any arguments
-if not warn then -- luacheck: ignore
+if not rawget(_G, "warn") then
local enabled = false
- local function warn(arg1, ...) -- luacheck: ignore
+ local function warn(arg1, ...)
if type(arg1) == "string" and arg1:sub(1, 1) == "@" then
-- control message
if arg1 == "@on" then
@@ -2957,7 +2970,7 @@ end
local config = {}
---- like io.lines(), but allows for lines to be continued with '\'.
+--- like `io.lines`, but allows for lines to be continued with '`\`'.
-- @param file a file-like object (anything where read() returns the next line) or a filename.
-- Defaults to stardard input.
-- @return an iterator over the lines, or nil
@@ -5993,7 +6006,8 @@ function lapp.process_options_string(str,args)
elseif check '$<{name} $' then -- is it <parameter_name>?
-- so <input file...> becomes input_file ...
optparm,rest = res.name:match '([^%.]+)(.*)'
- optparm = optparm:gsub('%A','_')
+ -- follow lua legal variable names
+ optparm = optparm:sub(1,1):gsub('%A','_') .. optparm:sub(2):gsub('%W', '_')
varargs = rest == '...'
append(parmlist,optparm)
end
@@ -6002,6 +6016,7 @@ function lapp.process_options_string(str,args)
line = res.rest
res = {}
local optional
+ local defval_str
-- do we have ([optional] [<type>] [default <val>])?
if match('$({def} $',line,res) or match('$({def}',line,res) then
local typespec = strip(res.def)
@@ -6044,6 +6059,7 @@ function lapp.process_options_string(str,args)
-- optional 'default value' clause. Type is inferred as
-- 'string' or 'number' if there's no explicit type
if default or match('default $r{rest}',typespec,res) then
+ defval_str = res.rest
defval,vtype = process_default(res.rest,vtype)
end
else -- must be a plain flag, no extra parameter required
@@ -6053,6 +6069,7 @@ function lapp.process_options_string(str,args)
local ps = {
type = vtype,
defval = defval,
+ defval_str = defval_str,
required = defval == nil and not optional,
comment = res.rest or optparm,
constraint = constraint,
@@ -6182,6 +6199,9 @@ function lapp.process_options_string(str,args)
if not ps.used then
if ps.required then lapp.error("missing required parameter: "..parm) end
set_result(ps,parm,ps.defval)
+ if builtin_types[ps.type] == "file" then
+ set_result(ps, parm .. "_name", ps.defval_str)
+ end
end
end
return results
@@ -8279,9 +8299,6 @@ end
-- @string P A file path
function path.isdir(P)
assert_string(1,P)
- if P:match("\\$") then
- P = P:sub(1,-2)
- end
return attrib(P,'mode') == 'directory'
end
@@ -9227,10 +9244,11 @@ function pretty.write (tbl,space,not_clever)
end
end
table.sort(ordered_keys, function (a, b)
- if type(a) == type(b) and type(a) == 'string' then
- return a < b
+ if type(a) == type(b) then
+ return tostring(a) < tostring(b)
+ else
+ return type(a) < type(b)
end
- return type(a) == 'boolean' or (type(b) ~= 'boolean' and type(a) == 'table')
end)
local function write_entry (key, val)
local tkey = type(key)
@@ -12327,7 +12345,7 @@ local function keys_op(i,v) return i end
--- return all the keys of a table in arbitrary order.
-- @within Extraction
--- @tab t A table
+-- @tab t A list-like table where the values are the keys of the input table
function tablex.keys(t)
assert_arg_iterable(1,t)
return makelist(tablex.pairmap(keys_op,t))
@@ -12337,7 +12355,7 @@ local function values_op(i,v) return v end
--- return all the values of the table in arbitrary order
-- @within Extraction
--- @tab t A table
+-- @tab t A list-like table where the values are the values of the input table
function tablex.values(t)
assert_arg_iterable(1,t)
return makelist(tablex.pairmap(values_op,t))
@@ -13425,6 +13443,8 @@ local concat = table.concat
local _unpack = table.unpack -- always injected by 'compat'
local find = string.find
local sub = string.sub
+local next = next
+local floor = math.floor
local is_windows = compat.is_windows
local err_mode = 'default'
@@ -13433,7 +13453,7 @@ local operators
local _function_factories = {}
-local utils = { _VERSION = "1.12.0" }
+local utils = { _VERSION = "1.13.1" }
for k, v in pairs(compat) do utils[k] = v end
--- Some standard patterns
@@ -13635,6 +13655,47 @@ end
+--- an iterator over all non-integer keys (inverse of `ipairs`).
+-- It will skip any key that is an integer number, so negative indices or an
+-- array with holes will not return those either (so it returns slightly less than
+-- 'the inverse of `ipairs`').
+--
+-- This uses `pairs` under the hood, so any value that is iterable using `pairs`
+-- will work with this function.
+-- @tparam table t the table to iterate over
+-- @treturn key
+-- @treturn value
+-- @usage
+-- local t = {
+-- "hello",
+-- "world",
+-- hello = "hallo",
+-- world = "Welt",
+-- }
+--
+-- for k, v in utils.kpairs(t) do
+-- print("German: ", v)
+-- end
+--
+-- -- output;
+-- -- German: hallo
+-- -- German: Welt
+function utils.kpairs(t)
+ local index
+ return function()
+ local value
+ while true do
+ index, value = next(t, index)
+ if type(index) ~= "number" or floor(index) ~= index then
+ break
+ end
+ end
+ return index, value
+ end
+end
+
+
+
--- Error handling
-- @section Error-handling
@@ -13661,17 +13722,20 @@ function utils.assert_arg (n,val,tp,verify,msg,lev)
return val
end
---- creates an Enum table.
+--- creates an Enum or constants lookup table for improved error handling.
-- This helps prevent magic strings in code by throwing errors for accessing
--- non-existing values.
---
--- Calling on the object does the same, but returns a soft error; `nil + err`.
---
--- The values are equal to the keys. The enum object is
--- read-only.
--- @param ... strings that make up the enumeration.
--- @return Enum object
--- @usage -- accessing at runtime
+-- non-existing values, and/or converting strings/identifiers to other values.
+--
+-- Calling on the object does the same, but returns a soft error; `nil + err`, if
+-- the call is succesful (the key exists), it will return the value.
+--
+-- When calling with varargs or an array the values will be equal to the keys.
+-- The enum object is read-only.
+-- @tparam table|vararg ... the input for the Enum. If varargs or an array then the
+-- values in the Enum will be equal to the names (must be strings), if a hash-table
+-- then values remain (any type), and the keys must be strings.
+-- @return Enum object (read-only table/object)
+-- @usage -- Enum access at runtime
-- local obj = {}
-- obj.MOVEMENT = utils.enum("FORWARD", "REVERSE", "LEFT", "RIGHT")
--
@@ -13683,21 +13747,81 @@ end
-- -- "'REVERES' is not a valid value (expected one of: 'FORWARD', 'REVERSE', 'LEFT', 'RIGHT')"
--
-- end
--- @usage -- validating user-input
--- local parameter = "...some user provided option..."
--- local ok, err = obj.MOVEMENT(parameter) -- calling on the object
--- if not ok then
--- print("bad 'parameter', " .. err)
+-- @usage -- standardized error codes
+-- local obj = {
+-- ERR = utils.enum {
+-- NOT_FOUND = "the item was not found",
+-- OUT_OF_BOUNDS = "the index is outside the allowed range"
+-- },
+--
+-- some_method = function(self)
+-- return self.ERR.OUT_OF_BOUNDS
+-- end,
+-- }
+--
+-- local result, err = obj:some_method()
+-- if not result then
+-- if err == obj.ERR.NOT_FOUND then
+-- -- check on error code, not magic strings
+--
+-- else
+-- -- return the error description, contained in the constant
+-- return nil, "error: "..err -- "error: the index is outside the allowed range"
+-- end
+-- end
+-- @usage -- validating/converting user-input
+-- local color = "purple"
+-- local ansi_colors = utils.enum {
+-- black = 30,
+-- red = 31,
+-- green = 32,
+-- }
+-- local color_code, err = ansi_colors(color) -- calling on the object, returns the value from the enum
+-- if not color_code then
+-- print("bad 'color', " .. err)
+-- -- "bad 'color', 'purple' is not a valid value (expected one of: 'black', 'red', 'green')"
-- os.exit(1)
-- end
function utils.enum(...)
- local lst = utils.pack(...)
- utils.assert_arg(1, lst[1], "string") -- at least 1 string
-
+ local first = select(1, ...)
local enum = {}
- for i, value in ipairs(lst) do
- utils.assert_arg(i, value, "string")
- enum[value] = value
+ local lst
+
+ if type(first) ~= "table" then
+ -- vararg with strings
+ lst = utils.pack(...)
+ for i, value in utils.npairs(lst) do
+ utils.assert_arg(i, value, "string")
+ enum[value] = value
+ end
+
+ else
+ -- table/array with values
+ utils.assert_arg(1, first, "table")
+ lst = {}
+ -- first add array part
+ for i, value in ipairs(first) do
+ if type(value) ~= "string" then
+ error(("expected 'string' but got '%s' at index %d"):format(type(value), i), 2)
+ end
+ lst[i] = value
+ enum[value] = value
+ end
+ -- add key-ed part
+ for key, value in utils.kpairs(first) do
+ if type(key) ~= "string" then
+ error(("expected key to be 'string' but got '%s'"):format(type(key)), 2)
+ end
+ if enum[key] then
+ error(("duplicate entry in array and hash part: '%s'"):format(key), 2)
+ end
+ enum[key] = value
+ lst[#lst+1] = key
+ end
+ end
+
+ if not lst[1] then
+ error("expected at least 1 entry", 2)
end
local valid = "(expected one of: '" .. concat(lst, "', '") .. "')"
@@ -13711,7 +13835,7 @@ function utils.enum(...)
__call = function(self, key)
if type(key) == "string" then
local v = rawget(self, key)
- if v then
+ if v ~= nil then
return v
end
end
diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf
index b0b89352b2..586bfa8dbf 100644
--- a/macros/luatex/generic/penlight/penlight.pdf
+++ b/macros/luatex/generic/penlight/penlight.pdf
Binary files differ
diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty
index d796f1e1c8..5af886786e 100644
--- a/macros/luatex/generic/penlight/penlight.sty
+++ b/macros/luatex/generic/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-10-15
+% 2022-10-22
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +22,7 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlight}[2022-10-15]
+\ProvidesPackage{penlight}[2022-10-22]
\RequirePackage{luacode}
@@ -43,8 +43,8 @@
\DeclareOption{format}{\luadirect{_G[__PENLIGHT__].stringx.format_operator()}}
\DeclareOption{func}{\luadirect{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}}
\DeclareOption{extras}{\luadirect{require'penlightextras'}}
-\DeclareOption{extrasnoglobals}{\luadirect{
- __PL_NO_GLOBALS__ = true
+\DeclareOption{extrasglobals}{\luadirect{
+ __PL_GLOBALS__ = true
require'penlightextras'
}}
@@ -58,23 +58,23 @@ end
-\newcommand{\writePDFmetadata}{\luadirect{writePDFmetadata()}}
+\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}}
\NewDocumentCommand{\writePDFmetadatakv}{ s m }{
\IfBooleanTF{#1}{% if *, overwrite everything
\luadirect{
__PDFmetadata__ = luakeys.parse(\luastring{#2})
- writePDFmetadata()
+ _G[__PENLIGHT__].tex.writePDFmetadata()
}}{
\luadirect{
__PDFmetadata__ = __PDFmetadata__ or {}
- table.update(__PDFmetadata__, luakeys.parse(\luastring{#2}))
- writePDFmetadata()
+ _G[__PENLIGHT__].tablex.update(__PDFmetadata__, luakeys.parse(\luastring{#2}))
+ _G[__PENLIGHT__].tex.writePDFmetadata()
}}
}
-\def\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}}
+\def\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}} % expand luastring twice
\let\luastringF\luastring % fully expanded luastring
% allow control over expansion of arguments to a latex function
diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex
index 869fda37ed..f3ee02f2ec 100644
--- a/macros/luatex/generic/penlight/penlight.tex
+++ b/macros/luatex/generic/penlight/penlight.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-10-15
+% 2022-10-22
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,6 +29,7 @@
\newcommand{\cmd}[1]{\texttt{\detokenize{#1}}}
\newcommand{\qcmd}[1]{``\cmd{#1}''}
\usepackage{url}
+\usepackage{xcolor}
\usepackage{showexpl}
\lstset{explpreset={justification=\raggedright,pos=r,wide=true}}
\setlength\ResultBoxRule{0mm}
@@ -57,11 +58,14 @@
\subtitle{Lua libraries for use in LuaLaTeX}
\begin{document}
+
+%{\Huge todo add split to text example with ltxexample\\reference the exact version of penlight used in this library. consider no globals by default\\ COVERT existing examples to extras globals, document hyperref}
+
\maketitle
- The official documentation for the Lua library can be found here:\\
+ Documentation for the Lua library this includes can be found here:\\
\mbox{\url{https://lunarmodules.github.io/Penlight}}
- \\
+ \\ This package uses version \cmd{1.13.1}
\subsection*{Required Package Option}
The first option sent to this package MUST be one of: \\
@@ -80,7 +84,7 @@ penlight = require'penlight'
-- below is optional
__SKIP_TEX__ = true --only required if you want to use
--penlightextras without a LaTeX run
--- __PL_NO_GLOBALS__ = true -- optional, skip global definitions
+__PL_GLOBALS__ = true -- optional, include global definitions
__SKIP_LUAKEYS__ = true -- luakeys is laoded in penlightextras be default, you may skip it with this
require'penlightextras'
\end{verbatim}
@@ -101,8 +105,8 @@ require'penlightextras'
\texttt{func} & allows placehold expressions eg. \texttt{\_1+1} to be used \\
& this will be ran in pre-amble: \texttt{penlight.utils.import('pl.func')}\\
& \url{https://lunarmodules.github.io/Penlight/libraries/pl.func}\\
- \texttt{\llap{extras}noglobals} & does the above three (\cmd{func,stringx,format}); adds some additional functions to \cmd{penlight} module; and adds the \cmd{pl.tex} sub-module.\\
- \texttt{extras} & does the above \texttt{extrasnoglobals} but makes many of the functions global variables.
+ \texttt{extras} & does the above three (\cmd{func,stringx,format}); adds some additional functions to \cmd{penlight} module; and adds the \cmd{pl.tex} sub-module.\\
+ \texttt{extrasglobals} & does the above \texttt{extras} but makes many of the functions global variables as well.
\end{tabular}
@@ -114,7 +118,12 @@ If \cmd{extras} is used, the following Lua globals will be defined:\\
\subsubsection*{Misc stuff}
\llcmd{__SKIP_TEX__} If using package with \cmd{texlua}, set this global before loading \cmd{penlight}\\
-\llcmd{__PL_NO_}\cmd{GLOBALS__} If using package with \cmd{texlua} and you don't want to set some globals (described in next sections), set this global before to \cmd{true} loading \cmd{penlight}\\
+The gloals flags below are taken care of in the package options:\\
+\llcmd{__PL_}\cmd{GLOBALS__} If using package with \cmd{texlua} and you don't want to set some globals (described in next sections), set this global before to \cmd{true} loading \cmd{penlight}\\
+\cmd{__SKIP_LUAKEYS__}\\
+\cmd{__PL_NO_HYPERREF__}\\
+\cmd{__PL_EXTRAS__} false, 1 or 2\\
+
\llcmd{hasval(x)} Python-like boolean testing\\
\llcmd{COMP'xyz'()} Python-like comprehensions:\\\url{https://lunarmodules.github.io/Penlight/libraries/pl.comprehension.html}\\
\llcmd{math.mod(n,d)}, \cmd{math.mod2(n)} math modulous\\
@@ -124,11 +133,11 @@ If \cmd{extras} is used, the following Lua globals will be defined:\\
\llcmd{pl.}\cmd{Char(n)} return letter corresponding to 1=A, 2=B, etc.\\
\llcmd{kpairs(t), }\cmd{npairs(t)} iterate over keys only, or include nil value from table ipairs\\
-{\Large todo document all string helper functions}
+
+%{\Large todo document all string helper functions}
\llcmd{pl.utils.}\cmd{filterfiles}\cmd{(dir,filt,rec)} Get files from dir and apply glob-like filters. Set rec to \cmd{true} to include sub directories\\
-\pagebreak
\subsubsection*{\cmd{pl.tex.} module is added}
\llcmd{add_bkt}\cmd{_cnt(n), }\cmd{close_bkt_cnt(n), reset_bkt_cnt} functions to keep track of adding curly brackets as strings. \cmd{add} will return \cmd{n} (default 1) \{'s and increment a counter. \cmd{close} will return \cmd{n} \}'s (default will close all brackets) and decrement.\\
@@ -153,9 +162,45 @@ If \cmd{extras} is used, the following Lua globals will be defined:\\
\llcmd{deccmd}\cmd{(cs, dft, overwrite)} declare a command. If \cmd{dft} (default) is \cmd{nil}, \cmd{cs} is set
to a package warning saying \cmd{'cs' was declared and used in document, but never set}. If \cmd{overwrite}
is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, it will throw error like \cmd{newcmd}.\\
+\llcmd{get_ref_info(l)}accesses the \cmd{\r@label} and returns a table\\
+
+
+
+
+\subsection*{Macro helpers}
+\cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)}
+based on the letters that \cmd{spec} is set to (or \cmd{def} if nothing is provided)
+This is useful if you want to write a command with flexibility on argument expansion.
+The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want
+no, once, twice, or full expansion.
+
+% BELOW IS FOR TROUBLESHOOTING ABOVE
+%\def\NOTexp{\ONEexp}
+%\def\ONEexp{\TWOexp}
+%\def\TWOexp{\TREexp}
+%\def\TREexp{Fully expanded}
+%
+%\NewDocumentCommand{\luastringExpTest}{m m}{
+% \MakeluastringCommands{#1}
+% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
+% \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')}
+% \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')}
+% \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')}
+% \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')}
+% \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
+%}
+%
+%\luastringExpTest{ n o t f }{\NOTexp}
+
+
+
+
+\subsection*{Split stuff}
+Splitting text (or a cmd) into oxford comma format via:
+\cmd{\splitToComma[expansion level]{text}{text to split on}}:
+
+\begin{LTXexample}
-\subsection{Split stuff}
-splitToComma:
-\splitToComma{ j doe }{\and}-\\
-\splitToComma{ j doe \and s else }{\and}-\\
-\splitToComma{ j doe \and s else \and a per }{\and}-\\
@@ -163,44 +208,23 @@ splitToComma:
\def\authors{j doe \and s else \and a per \and f guy}
\splitToComma[o]{\authors}{\and}
+\end{LTXexample}
+The expansion level is up to two characters, \cmd{n|o|t|f}, to control teh expasion of each argument.
+\begin{LTXexample}
spliToItems:
\begin{itemize}
\splitToItems{kale\and john}{\and}
\splitToItems{kale -john -someone else}{-}
\end{itemize}
+\end{LTXexample}
-\subsection{Macro helpers}
-\cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)}
-based on the letters that \cmd{spec} is set to (or \cmd{def} if nothing is provided)
-This is useful if you want to write a command with flexibility on argument expansion.
-The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want
-no, once, twice, or full expansion.
-
-
-\def\NOTexp{\ONEexp}
-\def\ONEexp{\TWOexp}
-\def\TWOexp{\TREexp}
-\def\TREexp{Fully expanded}
-
-\NewDocumentCommand{\luastringExpTest}{m m}{
- \MakeluastringCommands{#1}
- \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
- \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')}
- \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')}
- \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')}
- \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')}
- \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
-}
-
-\luastringExpTest{ n o t f }{\NOTexp}
\subsubsection*{global extras}
-If \cmd{extras} is used and NOT \cmd{extrasnoglobals}, then some globals are set.\\
-All \cmd{pl.tex} modules are added.\\
+If \cmd{extrasglobals} is used and NOT \cmd{extras}, many globals are set.\\
+All \cmd{pl.tex} modules are made global.\\
\cmd{hasval}, \cmd{COMP}, \cmd{kpairs}, \cmd{npairs} are globals.\\
-\cmd{pl.tablex} functions are added to the \cmd{table} table.\\
\section*{}
Disclaimer: I am not the author of the Lua Penlight library.
diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua
index 9ce0903f1c..a6a5c1ff0a 100644
--- a/macros/luatex/generic/penlight/penlightextras.lua
+++ b/macros/luatex/generic/penlight/penlightextras.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2022-10-15
+--% 2022-10-22
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,16 +22,17 @@
--% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
--% OR OTHER DEALINGS IN THE SOFTWARE.
-__SKIP_TEX__ = __SKIP_TEX__ or false --if declared true before here, it will use regular print functions
+__PL_SKIP_TEX__ = __PL_SKIP_TEX__ or false --if declared true before here, it will use regular print functions
-- (for troubleshooting with texlua instead of actual use in lua latex)
-__SKIP_LUAKEYS__ = __SKIP_LUAKEYS__ or false
-__PL_NO_GLOBALS__ = __PL_NO_GLOBALS__ or false
+__PL_SKIP_LUAKEYS__ = __PL_SKIP_LUAKEYS__ or false
+__PL_GLOBALS__ = __PL_GLOBALS__ or false
__PL_EXTRAS__ = 1
+__PL_NO_HYPERREF__ = __PL_NO_HYPERREF__ or false
-- requires penlight
local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
-if not __SKIP_LUAKEYS__ then
+if not __PL_SKIP_LUAKEYS__ then
luakeys = require'luakeys'
end
@@ -74,7 +75,7 @@ pl.tex._xNoValue = '-NoValue-'
--Generic LuaLaTeX utilities for print commands or environments
-if not __SKIP_TEX__ then
+if not __PL_SKIP_TEX__ then
local function check_special_chars(s) -- todo extend to toher special chars?
if type(s) == 'string' then
if string.find(s, '[\n\r\t\0]') then
@@ -142,6 +143,7 @@ function pl.tex.help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1
end
wrt2('\n^^^^^\n')
end
+pl.help_wrt = pl.tex.help_wrt
function pl.tex.prt_array2d(t)
for _, r in ipairs(t) do
@@ -292,15 +294,37 @@ end
+
+
function pl.tex.get_ref_info(l)
+ local n = 5
+ if __PL_NO_HYPERREF__ then
+ local n = 2
+ end
local r = token.get_macro('r@'..l)
+ local t = {}
if r == nil then
- return 0, 0
+ t = pl.tablex.new(n, 0) -- make all 0s
+ r = '-not found-'
+ else
+ t = {r:match(("(%b{})"):rep(n))}
+ t = pl.tablex.map(string.trimfl, t)
end
- local sec, page = r:match("{([^}]*)}{([^}]*)}")
- return sec, page
+ t[#t+1] = r -- add the og return of label
+ pl.help_wrt(t, 'ref info')
+ return t
end
+-- todo add regex pattern for cref info
+--function pl.tex.get_ref_info_all_cref(l)
+-- local r = token.get_macro('r@'..l..'@cref')
+-- if r == nil then
+-- return r, 0, 0
+-- end
+-- local sec, page = r:match("{([^}]*)}{([^}]*)}")
+-- return r, sec, page
+--end
+
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -420,6 +444,10 @@ function str_mt.__index.delspace(str)
return str:gsub('%s','')
end
+function str_mt.__index.trimfl(str)
+ return str:sub(2,-2)
+end
+
-- -- -- -- function stuff
@@ -750,7 +778,7 @@ end
-if not __PL_NO_GLOBALS__ then
+if _PL_GLOBALS__ then
__PL_EXTRAS__ = 2
-- iterators
kpairs = pl.utils.kpairs
@@ -767,6 +795,13 @@ if not __PL_NO_GLOBALS__ then
end
end
table.join = table.concat -- alias
+ -- todo should tablex have all table functions
+
+ pl.tablex.concat = table.concat
+ pl.tablex.insert = table.insert
+ pl.tablex.maxn = table.maxn
+ pl.tablex.remove = table.remove
+ pl.tablex.sort = table.sort
hasval = pl.hasval
COMP = pl.COMP