summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/luatex/addtoluatexpath/README.md10
-rw-r--r--Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty22
2 files changed, 27 insertions, 5 deletions
diff --git a/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md b/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md
index eedfdf2fc80..da97dfa4a30 100644
--- a/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md
+++ b/Master/texmf-dist/doc/luatex/addtoluatexpath/README.md
@@ -2,7 +2,7 @@
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.
+You may want this package, for example, if a `.cls` or `.sty` file is located on 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,
@@ -13,6 +13,12 @@ You may want this package, for example, if a `.cls` or `.sty` file is located a
* 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}`
+* The lua functions below are globally defined:
+* `atlp_main(paths_str)` is the main function that runs
+* `atlp_paths = {}` is a table containing all paths added by this package
+* `atlp_find_file(file_str)` is a function that returns the full path of a file, it searches through all paths that were input to this package and returns the first valid. If no paths are found, an error is issed
+
+
## Note
This package appends to the `package.path` Lua variable and the `\input@path` command (it first uses `\providecommand` to intialize it).
@@ -33,7 +39,7 @@ However, if `\graphicspath{}` is used after paths are added by this package, gra
## License
-Copyright (C) 2023 Kale Ewasiuk
+Copyright (C) 2023-2024 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/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty b/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty
index cea0cc1eb29..140a3ac2088 100644
--- a/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty
+++ b/Master/texmf-dist/tex/luatex/addtoluatexpath/addtoluatexpath.sty
@@ -1,11 +1,26 @@
-\ProvidesPackage{addtoluatexpath}[2023-08-04]
+\ProvidesPackage{addtoluatexpath}[2024-03-14]
\RequirePackage{luacode}
\providecommand{\input@path}{} % initialize input@path if not defined yet
\begin{luacode*}
-
+
+ atlp_paths = {"."} -- global table containing paths added by this package
+
+ function atlp_find_file(f) -- find a path in list of atlp_paths
+ for i, k in pairs(atlp_paths) do
+ local fp = kpse.find_file(k ..'/'.. f)
+ if (fp) then
+ return fp
+ end
+ end -- if nothing returned, issue a package error
+ texio.write_nl('addtoluatexpath searched for file: '..f)
+ texio.write_nl('addtoluatexpath searched paths were: '..token.get_macro('input@path'))
+ tex.sprint('\\PackageError{addtoluatexpath}{a file was not found}{}')
+ tex.sprint('\\stop')
+ end
+
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
@@ -19,9 +34,10 @@
end
for __, p in ipairs(atlp_tbl) do
- if p:find('*') == nil then -- add paths without *, continue loop after
+ if p:find('*') == nil then -- add paths without *, and continue the 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
+ atlp_paths[#atlp_paths + 1] = p -- append the added path to global list
goto continue
end