summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-03-15 19:59:14 +0000
committerKarl Berry <karl@freefriends.org>2022-03-15 19:59:14 +0000
commitd6c3498c828a48b0a3b5a33afe6e2cd4a8e1d271 (patch)
tree106305791404bb62d2f8387fbef26b54301f4aff
parent5f7d0d6c9c581dd584154903b848da6ab55f359d (diff)
penlight (15mar22) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2021.final@62720 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/penlight/penlight.pdfbin38311 -> 38589 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/penlight/penlight.tex2
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlight.sty21
-rw-r--r--Master/texmf-dist/tex/luatex/penlight/penlightextras.lua79
4 files changed, 96 insertions, 6 deletions
diff --git a/Master/texmf-dist/doc/luatex/penlight/penlight.pdf b/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
index 33f3457df2a..3fcd22c54e5 100644
--- a/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
+++ b/Master/texmf-dist/doc/luatex/penlight/penlight.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/penlight/penlight.tex b/Master/texmf-dist/doc/luatex/penlight/penlight.tex
index 2096c10b682..d70fc258f3e 100644
--- a/Master/texmf-dist/doc/luatex/penlight/penlight.tex
+++ b/Master/texmf-dist/doc/luatex/penlight/penlight.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@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
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlight.sty b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
index 936cb6dce72..a73948af294 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlight.sty
+++ b/Master/texmf-dist/tex/luatex/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@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 @@ if __PENLIGHT__ == nil then
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()
+ }}
+}
diff --git a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
index 192c86c9231..e021567c139 100644
--- a/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
+++ b/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@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 @@ end
--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 @@ function str_mt.__index.totable(str)
end
+function str_mt.__index.upfirst(str)
+ return str:gsub('%a', function(x) return x:upper() end, 1)
+end
@@ -608,6 +625,62 @@ end
+__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