From 575ab7d0e7534edd510bbc89a2ef4b04582af591 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 4 Mar 2022 03:01:04 +0000 Subject: CTAN sync 202203040301 --- macros/luatex/generic/penlight/README.md | 4 +- macros/luatex/generic/penlight/penlight.pdf | Bin 38237 -> 38311 bytes macros/luatex/generic/penlight/penlight.sty | 22 ++++--- macros/luatex/generic/penlight/penlight.tex | 4 +- macros/luatex/generic/penlight/penlightextras.lua | 75 +++++++++++++++++++--- 5 files changed, 84 insertions(+), 21 deletions(-) (limited to 'macros/luatex/generic/penlight') diff --git a/macros/luatex/generic/penlight/README.md b/macros/luatex/generic/penlight/README.md index 818fb7d4ea..ca66c41b74 100644 --- a/macros/luatex/generic/penlight/README.md +++ b/macros/luatex/generic/penlight/README.md @@ -1,11 +1,11 @@ # penlight -- Lua libraries for use in LuaLaTeX -This LuaLaTeX package provides a thin-wrapper to use the [penlight](https://github.com/lunarmodules/Penlight) Lua libraries with LuaLaTeX. +This LuaLaTeX package provides a wrapper to use the [penlight](https://github.com/lunarmodules/Penlight) Lua libraries with LuaLaTeX, with some extra functionality added. # License -Copyright (C) 2021 Kale Ewasiuk +Copyright (C) 2021-2022 Kale Ewasiuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf index a8e166a1ae..33f3457df2 100644 Binary files a/macros/luatex/generic/penlight/penlight.pdf and b/macros/luatex/generic/penlight/penlight.pdf differ diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty index b9f5a9490a..936cb6dce7 100644 --- a/macros/luatex/generic/penlight/penlight.sty +++ b/macros/luatex/generic/penlight/penlight.sty @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-02-27 -% Copyright (C) 2021 Kale Ewasiuk +% 2022-03-03 +% Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE % OR OTHER DEALINGS IN THE SOFTWARE. -\ProvidesPackage{penlight}[2022-02-27] +\ProvidesPackage{penlight}[2022-03-03] \RequirePackage{luacode} @@ -32,17 +32,23 @@ }} \DeclareOption{penlight}{\luadirect{ penlight = require('penlight') - __PENLIGHT__ = 'penlight' + __PENLIGHT__ = 'penlight' }} \DeclareOption{stringx}{\luadirect{_G[__PENLIGHT__].stringx.import()}} \DeclareOption{format}{\luadirect{_G[__PENLIGHT__].stringx.format_operator()}} \DeclareOption{func}{\luadirect{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}} -\DeclareOption{extras}{\luadirect{require('penlightextras')}} -\DeclareOption{extrasnoglobals}{ +\DeclareOption{extras}{\luadirect{require'penlightextras'}} +\DeclareOption{extrasnoglobals}{\luadirect{ __PL_NO_GLOBALS__ = true - \luadirect{require('penlightextras') - }} + require'penlightextras' +}} \ProcessOptions*\relax + +\luadirect{ +if __PENLIGHT__ == nil then + tex.print('\\PackageError{penlight}{penlight or pl option must be passed to penlight as the first option}{}') +end +} diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex index 176dc4e557..2096c10b68 100644 --- a/macros/luatex/generic/penlight/penlight.tex +++ b/macros/luatex/generic/penlight/penlight.tex @@ -1,6 +1,6 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-02-27 -% Copyright (C) 2021 Kale Ewasiuk +% 2022-03-03 +% Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua index 0cdec03763..192c86c923 100644 --- a/macros/luatex/generic/penlight/penlightextras.lua +++ b/macros/luatex/generic/penlight/penlightextras.lua @@ -1,8 +1,31 @@ +--% Kale Ewasiuk (kalekje@gmail.com) +--% 2022-03-03 +--% Copyright (C) 2021-2022 Kale Ewasiuk +--% +--% 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 without limitation the rights +--% to use, copy, modify, merge, publish, 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. IN NO EVENT +--% SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +--% ANY 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. __SKIP_TEX__ = __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) - __PL_NO_GLOBALS__ = __PL_NO_GLOBALS__ or false +__PL_EXTRAS__ = 1 -- requires penlight local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl @@ -10,8 +33,8 @@ local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl -- some bonus string operations, % text operator, and functional programming pl.stringx.import() -pl.text.format_operator() -pl.utils.import('pl.func') -- allow placeholder expressions _1 +1 etc. +pl.stringx.format_operator() +pl.utils.import'pl.func' -- allow placeholder expressions _1 +1 etc. pl.COMP = require'pl.comprehension'.new() -- for comprehensions @@ -561,15 +584,48 @@ end +-- https://tex.stackexchange.com/questions/38150/in-lualatex-how-do-i-pass-the-content-of-an-environment-to-lua-verbatim +pl.tex.recordedbuf = "" +function pl.tex.readbuf(buf) + i,j = string.find(buf, '\\end{%w+}') + if i==nil then -- if not ending an environment + pl.tex.recordedbuf = pl.tex.recordedbuf .. buf .. "\n" + return "" + else + return nil + end +end + +function pl.tex.startrecording() + pl.tex.recordedbuf = "" + luatexbase.add_to_callback('process_input_buffer', pl.tex.readbuf, 'readbuf') +end + +function pl.tex.stoprecording() + luatexbase.remove_from_callback('process_input_buffer', 'readbuf') + pl.tex.recordedbuf = pl.tex.recordedbuf:gsub("\\end{%w+}\n","") +end + + + + if not __PL_NO_GLOBALS__ then + __PL_EXTRAS__ = 2 -- iterators kpairs = pl.utils.kpairs npairs = pl.utils.npairs --enum = utils.enum for k,v in pairs(pl.tablex) do -- extend the table table to contain tablex functions - _G['table'][k] = v + if k == 'sort' then + table.sortk = v + elseif k == 'move' then + table.xmove = v + else + _G['table'][k] = v + end end + table.join = table.concat -- alias hasval = pl.hasval COMP = pl.COMP @@ -589,6 +645,12 @@ if not __PL_NO_GLOBALS__ then _G[k] = v end +end + + + + + --_xTrue = pl.tex._xTrue --_xFalse = pl.tex._xFalse --_xNoValue = pl.tex._xNoValue @@ -619,11 +681,6 @@ if not __PL_NO_GLOBALS__ then --add_bkt_cnt = pl.tex.add_bkt_cnt --close_bkt_cnt = pl.tex.close_bkt_cnt -end - - - - -- graveyard -- cgit v1.2.3