summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-08-05 20:05:51 +0000
committerKarl Berry <karl@freefriends.org>2023-08-05 20:05:51 +0000
commit7c03b44ea77e3d2229670b903684e67db2f2edb0 (patch)
tree5efb74e664bb55e67e594a255e3999fb6284fa91
parent4ed81db47f3adbc7ed05df9fb4a3b91478c8d4b1 (diff)
addtoluatexpath (5aug23)
git-svn-id: svn://tug.org/texlive/trunk@67821 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/addtoluatexpath/README.md57
-rw-r--r--Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty52
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check3
-rw-r--r--Master/tlpkg/tlpsrc/addtoluatexpath.tlpsrc0
-rw-r--r--Master/tlpkg/tlpsrc/collection-luatex.tlpsrc1
5 files changed, 112 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md b/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md
new file mode 100644
index 00000000000..eedfdf2fc80
--- /dev/null
+++ b/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md
@@ -0,0 +1,57 @@
+# addtoluatexpath
+
+
+The `addtoluatexpath` package provides a convenient way to add input and Lua package paths in your document.
+You may want this package, for example, if a `.cls` or `.sty` file is located a network or cloud storage drive.
+
+## Usage
+* You can either pass the comma-separated paths via package options like `\RequirePackage[path1,path2]{addtoluatexpath}` in pre-amble,
+ or by using the macro `\addtoluatexpath{path1,path2}` after the package has been loaded.
+* If you wish to include first-level sub-directories as well as a path, inlcude a `/*` at the end of the path.
+ eg. `\RequirePackage[C:/Users/me/Desktop/*]{addtoluatexpath}` adds your Desktop and all folders in the desktop to path.
+* If you wish to include all nested sub-directories of all levels, include a `/**` at the end of the path.
+* If you want to add to Lua path (`package.path`) only, include `notex=true` in the argument.
+* If you want to add to tex input path only, include `nolua=true` in the argument.
+ eg. `\RequirePackage[nolua=true, C:/Users/me/Desktop/*, /**]{addtoluatexpath}`
+
+## Note
+This package appends to the `package.path` Lua variable and the `\input@path` command (it first uses `\providecommand` to intialize it).
+Lua files in the added paths can then added via `require'fileinpath1'`; however `loadfile` and `dofile` still require the full path.
+`graphicx` internally uses `\input@path` as a default list of the paths;
+therefore, paths specified by this package will also include graphics if the `graphicx` package is loaded after paths are set.
+However, if `\graphicspath{}` is used after paths are added by this package, graphics search paths will not use `\input@path`, omitting the paths you added with this package.
+
+## Dependencies
+`luacode`, `luakeys`, `penlight` (only if using `*` in paths)
+
+## Repo & Contact
+
+* <https://github.com/kalekje/addtoluatexpath>
+
+* [kalekje@gmail.com](mailto:kalekje@gmail.com)
+
+
+## License
+
+Copyright (C) 2023 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.
+
diff --git a/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty b/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty
new file mode 100644
index 00000000000..cea0cc1eb29
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty
@@ -0,0 +1,52 @@
+\ProvidesPackage{addtoluatexpath}[2023-08-04]
+
+\RequirePackage{luacode}
+
+\providecommand{\input@path}{} % initialize input@path if not defined yet
+
+\begin{luacode*}
+
+ function atlp_main(atlp_raw) -- add to path from raw string
+
+ local atlp_tbl = require'luakeys'().parse(atlp_raw, {naked_as_value=true}) -- paths as table
+
+ local atlp_no_lua = atlp_tbl['nolua'] or false -- check and set nolua=true
+ local atlp_no_tex = atlp_tbl['notex'] or false -- check and set notex=true
+
+ if atlp_raw:find('*') ~= nil then -- if *, must use penlight to expand subdirectories
+ penlight = require'penlight'
+ atlp_tbl = penlight.List(atlp_tbl) -- convert to pl.List for easy manipulation
+ end
+
+ for __, p in ipairs(atlp_tbl) do
+ if p:find('*') == nil then -- add paths without *, continue loop after
+ if not atlp_no_lua then package.path = package.path .. ';'..p..'/?.lua;' end
+ if not atlp_no_tex then token.set_macro('input@path', token.get_macro('input@path')..'{'..p..'/}', 'global') end
+ goto continue
+ end
+
+ local p, c = p:gsub('*','') -- if * added, include subdirectories
+ local atlp_subdirs = penlight.List(penlight.dir.getdirectories(p))
+ -- troubleshooting --texio.write_nl(penlight.pretty.write(atlp_subdirs))
+ if c == 2 then
+ atlp_subdirs = atlp_subdirs:map(function(s) return s ..'/**' end) -- add ** to subdirs for recursive inclusion
+ end
+ atlp_tbl:append(p) -- make sure p (current path without *) is still added!
+ atlp_tbl:extend(atlp_subdirs) -- extend path to include additional subdirs; the for loop is lengthened
+
+ ::continue::
+ end
+
+ -- -- troubleshooting: show all paths
+ --texio.write_nl('Lua Paths >>> \n'..package.path:gsub(';','\n'))
+ --texio.write_nl('TeX Paths >>> \n'..token.get_macro('input@path'):gsub('}{','\n'))
+
+ end
+
+ atlp_main(token.get_macro('@raw@opt@addtoluatexpath.sty'))
+
+\end{luacode*}
+
+\NewDocumentCommand{\addtoluatexpath}{m}{\luadirect{atlp_main(\luastring{#1})}} % a command
+
+\AtEndOfPackage{\let\@unprocessedoptions\relax}
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index e9f94a2ce1a..014f0f7c281 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -26,7 +26,8 @@ my @TLP_working = qw(
academicons accanthis accents accessibility accfonts accsupp achemso
acmart acmconf acro acronym acroterm
active-conf actuarialangle actuarialsymbol
- addfont addliga addlines adfathesis adforn adhocfilelist adigraph
+ addfont addliga addlines addtoluatexpath
+ adfathesis adforn adhocfilelist adigraph
adjmulticol adfsymbols adjustbox adobemapping
adrconv adtrees advdate
ae aeguill aesupp afparticle afthesis
diff --git a/Master/tlpkg/tlpsrc/addtoluatexpath.tlpsrc b/Master/tlpkg/tlpsrc/addtoluatexpath.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/addtoluatexpath.tlpsrc
diff --git a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
index a85adbd51cf..f9a732575de 100644
--- a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
@@ -8,6 +8,7 @@ longdesc The LuaTeX engine itself (and plain formats) are in collection-basic.
depend collection-basic
#
depend addliga
+depend addtoluatexpath
depend auto-pst-pdf-lua
depend barracuda
depend bezierplot