summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-11-08 23:22:10 +0000
committerKarl Berry <karl@freefriends.org>2021-11-08 23:22:10 +0000
commit1acf622594ee5da07939ea1d0af013af8eff10aa (patch)
treef42c7724f05101ebd4ba978682a75a6e721d460c /Master/texmf-dist/tex
parent0aeb22a660c5212cd5597d3c6544bcbd3f81524d (diff)
penlight (9nov21)
git-svn-id: svn://tug.org/texlive/trunk@61004 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlight.sty19
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlightextras.lua16
2 files changed, 19 insertions, 16 deletions
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlight.sty b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
index 9b0baed08be..1f1fccc042b 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlight.sty
+++ b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
@@ -1,6 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-09-20
-%
+% 2021-11-07
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,21 +22,21 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlight}[2021-09-20]
+\ProvidesPackage{penlight}[2021-11-07]
-\RequirePackage{luapackageloader}
+\RequirePackage{luacode}
-\DeclareOption{pl}{\directlua{
+\DeclareOption{pl}{\luadirect{
pl = require('penlight')
__PENLIGHT__ = 'pl'
}}
-\DeclareOption{penlight}{\directlua{
+\DeclareOption{penlight}{\luadirect{
penlight = require('penlight')
__PENLIGHT__ = 'penlight'
}}
-\DeclareOption{stringx}{\directlua{_G[__PENLIGHT__].stringx.import()}}
-\DeclareOption{format}{\directlua{_G[__PENLIGHT__].text.format_operator()}}
-\DeclareOption{func}{\directlua{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}}
-\DeclareOption{extras}{\directlua{require('penlightextras')}}
+\DeclareOption{stringx}{\luadirect{_G[__PENLIGHT__].stringx.import()}}
+\DeclareOption{format}{\luadirect{_G[__PENLIGHT__].text.format_operator()}}
+\DeclareOption{func}{\luadirect{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}}
+\DeclareOption{extras}{\luadirect{require('penlightextras')}}
\ProcessOptions*\relax
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
index f612bd3370f..13d0ab5817c 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
+++ b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
@@ -2,17 +2,22 @@
local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
local bind = bind or pl.func.bind
+-- some bonus string operations, % text operator, and functional programmng
+pl.stringx.import()
+pl.text.format_operator()
+pl.utils.import('pl.func')
+
function help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note
local wrt = wrt or texio.write_nl
local wrt = wrt or print
s2 = s2 or ''
- wrt('\nvvvvv '..s2)
+ wrt('\nvvvvv '..s2..'\n')
if type(s1) == 'table' then
wrt(pl.pretty.write(s1))
else
wrt(tostring(s1))
end
- wrt('^^^^^\n')
+ wrt('\n^^^^^\n')
end
@@ -129,7 +134,7 @@ local function like(M1, v)
return pl.array2d.new(r,c,v)
end
-function from_table(t) -- turns a labelled table to a 2d, label-free array
+local function from_table(t) -- turns a labelled table to a 2d, label-free array
t_new = {}
for k, v in pairs(t) do
if type(v) == 'table' then
@@ -145,7 +150,7 @@ function from_table(t) -- turns a labelled table to a 2d, label-free array
return t_new
end
-function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
+local function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
EL = EL or false
if EL then EL = '\\\\' else EL = '' end
return pl.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL
@@ -221,10 +226,9 @@ function mod2(a) -- math modulo 2
end
function hasval(x) -- if something has value
- -- todo check for Lists, other penlight objects
if (x == nil) or (x == false) or (x == 0) or (x == '') then
return false
- elseif type(x) == 'table' then
+ elseif (type(x) ~= 'number') or (type(x) ~= 'string') then
if #x == 0 then
return false
else