summaryrefslogtreecommitdiff
path: root/macros/luatex/generic
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-03-16 03:01:05 +0000
committerNorbert Preining <norbert@preining.info>2022-03-16 03:01:05 +0000
commit725ce6a3e602c7516d471df841ea433b8c5bcd9d (patch)
tree6cc54f5bd90984b9b63976a0386ae2681a08b7cb /macros/luatex/generic
parentd6f947fa36ed3b76d36a8dfad4e9247319b4d622 (diff)
CTAN sync 202203160301
Diffstat (limited to 'macros/luatex/generic')
-rw-r--r--macros/luatex/generic/penlight/penlight.pdfbin38311 -> 38589 bytes
-rw-r--r--macros/luatex/generic/penlight/penlight.sty21
-rw-r--r--macros/luatex/generic/penlight/penlight.tex2
-rw-r--r--macros/luatex/generic/penlight/penlightextras.lua79
4 files changed, 96 insertions, 6 deletions
diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf
index 33f3457df2..3fcd22c54e 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 936cb6dce7..a73948af29 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-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/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex
index 2096c10b68..d70fc258f3 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-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/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua
index 192c86c923..e021567c13 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-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