summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/make4ht/make4ht-lib.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-04-27 16:43:40 +0000
committerKarl Berry <karl@freefriends.org>2017-04-27 16:43:40 +0000
commita2a03aa6230e0fdc8d5a7922f2c0c23c05915fe1 (patch)
tree4e8dc79aacfc86534f6feb0f55794d16556ba61c /Master/texmf-dist/scripts/make4ht/make4ht-lib.lua
parentb22ccce5b0f563434ae23f9f1f9481829739aa89 (diff)
make4ht (27apr17)
git-svn-id: svn://tug.org/texlive/trunk@44079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/make4ht/make4ht-lib.lua')
-rwxr-xr-xMaster/texmf-dist/scripts/make4ht/make4ht-lib.lua30
1 files changed, 26 insertions, 4 deletions
diff --git a/Master/texmf-dist/scripts/make4ht/make4ht-lib.lua b/Master/texmf-dist/scripts/make4ht/make4ht-lib.lua
index 3b550b9995c..918343f20ca 100755
--- a/Master/texmf-dist/scripts/make4ht/make4ht-lib.lua
+++ b/Master/texmf-dist/scripts/make4ht/make4ht-lib.lua
@@ -116,9 +116,9 @@ Make.file_matches = function(self, files)
self.matches[k].params = v
end
-- Loop over files, run command on matched
- for _, file in pairs(files)do
+ for _, file in ipairs(files)do
statuses[file] = {}
- for _, s in pairs(self.matches) do
+ for _, s in ipairs(self.matches) do
local pattern= s.pattern
if file:match(pattern) then
local status, msg = self:run_command(file,s)
@@ -134,6 +134,27 @@ Make.file_matches = function(self, files)
return statuses
end
+-- add files from the mk4 file
+-- we must add them to the table generated from the lg file, so they can be processed later
+--
+Make.add_file = function(self, filename)
+ -- self.lgfile should be present, as it is created once the lg_file was parsed for the first time
+ local lg = self.lgfile or {}
+ local files = lg.files or {}
+ -- run filters on the file
+ local filtertable = {filename}
+ -- should we care about return status?
+ self:file_matches(filtertable)
+ -- break if the file is present already
+ -- start at the end, it it was added by a build file, the file will be likely at the end
+ for i = #files,1,-1 do
+ if files[i] == filename then return false, "File was already added" end
+ end
+ -- save the added file to the lg_file
+ table.insert(lg.files, filename)
+ self.lg = lg
+end
+
Make.run = function(self)
local return_codes = {}
local params = self.params or {}
@@ -174,12 +195,13 @@ Make.run = function(self)
end
local lgfile = params.input and params.input .. ".lg" or nil
if lgfile then
- local lg = mkutils.parse_lg(lgfile)
+ self.lgfile = self.lgfile or mkutils.parse_lg(lgfile)
+ local lg = self.lgfile
-- First convert images from lg files
self:image_convert(lg["images"])
-- Then run file matchers on lg files and converted images
local files = lg["files"]
- for _,v in pairs(lg["images"]) do
+ for _,v in ipairs(lg["images"]) do
local v = v.output
-- print(v)
table.insert(files,v)