texlive[62720] branches/branch2021.final/Master/texmf-dist: penlight
commits+karl at tug.org
commits+karl at tug.org
Tue Mar 15 20:59:14 CET 2022
Revision: 62720
http://tug.org/svn/texlive?view=revision&revision=62720
Author: karl
Date: 2022-03-15 20:59:14 +0100 (Tue, 15 Mar 2022)
Log Message:
-----------
penlight (15mar22) (branch)
Modified Paths:
--------------
branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.tex
branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlight.sty
branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
Modified: branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
===================================================================
(Binary files differ)
Modified: branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.tex
===================================================================
--- branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.tex 2022-03-15 19:59:01 UTC (rev 62719)
+++ branches/branch2021.final/Master/texmf-dist/doc/luatex/penlight/penlight.tex 2022-03-15 19:59:14 UTC (rev 62720)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2022-03-03
+% 2022-03-15
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
Modified: branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlight.sty
===================================================================
--- branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlight.sty 2022-03-15 19:59:01 UTC (rev 62719)
+++ branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlight.sty 2022-03-15 19:59:14 UTC (rev 62720)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2022-03-03
+% 2022-03-15
% 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-03-03]
+\ProvidesPackage{penlight}[2022-03-15]
\RequirePackage{luacode}
@@ -52,3 +52,20 @@
tex.print('\\PackageError{penlight}{penlight or pl option must be passed to penlight as the first option}{}')
end
}
+
+
+
+\newcommand{\writePDFmetadata}{\luadirect{writePDFmetadata()}}
+
+\NewDocumentCommand{\writePDFmetadatakv}{ s m }{
+\IfBooleanTF{#1}{% if *, overwrite everything
+ \luadirect{
+ __PDFmetadata__ = luakeys.parse(\luastring{#2})
+ writePDFmetadata()
+ }}{
+ \luadirect{
+ __PDFmetadata__ = __PDFmetadata__ or {}
+ table.update(__PDFmetadata__, luakeys.parse(\luastring{#2})
+ writePDFmetadata()
+ }}
+}
Modified: branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
===================================================================
--- branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua 2022-03-15 19:59:01 UTC (rev 62719)
+++ branches/branch2021.final/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua 2022-03-15 19:59:14 UTC (rev 62720)
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje at gmail.com)
---% 2022-03-03
+--% 2022-03-15
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -171,11 +171,25 @@
--definition helpers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-function pl.tex.defcmd(cs, val) -- simple definitions
- val = val or ''
+function pl.tex.defmacro(cs, val) -- , will not work if val contains undefined tokens (so pre-define them if using..)
+ val = val or '' -- however this works for arbitrary command names (\@hello-123 etc allowed)
token.set_macro(cs, val, 'global')
end
+
+function pl.tex.defcmd(cs, val) -- fixes above issue, but only chars allowed in cs (and no @)
+ val = val or ''
+ tex.sprint('\\gdef\\'..cs..'{'..val..'}')
+end
+
+function pl.tex.defcmdAT(cs, val) -- allows @ in cs,
+ --however should only be used in preamble. I avoid \makeatother because I've ran into issues with cls and sty files using it.
+ val = val or ''
+ tex.sprint('\\makeatletter\\gdef\\'..cs..'{'..val..'}')
+end
+
+
+
function pl.tex.prvcmd(cs, val) -- provide command via lua
if token.is_defined(cs) then
-- do nothing if token is defined already --pkgwarn('penlight', 'Definition '..cs..' is being overwritten')
@@ -360,6 +374,9 @@
end
+function str_mt.__index.upfirst(str)
+ return str:gsub('%a', function(x) return x:upper() end, 1)
+end
@@ -608,7 +625,63 @@
+__PDFmetadata__ = {}
+pl.tex.add_xspace_intext = true
+
+function pl.tex.updatePDFtable(k, v, o)
+ k = k:upfirst()
+ if not pl.hasval(o) and __PDFmetadata__[k] ~= nil then
+ return
+ end
+ __PDFmetadata__[k] = v
+end
+
+pl.tex.writePDFmetadata = function(t) -- write PDF metadata to xmpdata file
+ t = t or __PDFmetadata__
+ local str = ''
+ for k, v in pairs(t) do
+ k = k:upfirst()
+ str = str..'\\'..k..'{'..v..'}'..'\n'
+ end
+ pl.utils.writefile(tex.jobname..'.xmpdata', str)
+end
+
+
+
+function pl.tex.clear_cmds_str(s)
+ return s:gsub('%s+', ' '):gsub('\\\\',' '):gsub('\\%a+',''):gsub('{',' '):gsub('}',' '):gsub('%s+',' '):strip()
+end
+
+function pl.tex.makePDFvarstr(s)
+ s = s:gsub('%s*\\sep%s+','\0'):gsub('%s*\\and%s+','\0') -- turn \and into \sep
+ s = pl.tex.clear_cmds_str(s)
+ s = s:gsub('\0','\\sep ')
+ pl.tex.help_wrt(s,'PDF var string')
+ return s
+end
+
+function pl.tex.makeInTextstr(s)
+ local s, c_and = s:gsub('%s*\\and%s+','\0')
+ s = pl.tex.clear_cmds_str(s)
+ if pl.tex.add_xspace_intext then
+ s = s..'\\xspace'
+ end
+ if c_and == 1 then
+ s = s:gsub('\0',' and ')
+ elseif c_and > 1 then
+ s = s:gsub('\0',', ', c_and - 1)
+ s = s:gsub('\0',', and ')
+ end
+ pl.tex.help_wrt(s,'in text var string')
+ return s
+end
+
+
+
+
+
+
if not __PL_NO_GLOBALS__ then
__PL_EXTRAS__ = 2
-- iterators
More information about the tex-live-commits
mailing list.