[tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?
Michal Hoftich
michal.h21 at gmail.com
Sun Apr 24 21:41:46 CEST 2022
Hi Nasser
>
> Unfortunately, I had to remove this build file after trying
> it on my actual large latex file.
>
> This is what happened. After waiting for almost 30 hrs, and counted
> tex4ht calling dvilualatex 10 times ! I decided it went into
> an infinite loop for some reason. It takes 2-2.5 hrs for one
> call.
You are right, I had two bugs in the script! First is that the
compilation_count variable wasn't updated, so it is always 1, second
is that it compiles one time more than necessary even when I fixed
that issue. Try this version:
-----------------------------
local htlatex = require "make4ht-htlatex"
local function get_checksum(main_file, extensions)
-- make checksum for temporary files
local checksum = ""
local extensions = extensions or {"aux", "4tc", "xref"}
for _, ext in ipairs(extensions) do
local f = io.open(main_file .. "." .. ext, "r")
if f then
local content = f:read("*all")
f:close()
-- make checksum of the file and previous checksum
-- this way, we will detect change in any file
checksum = md5.sumhexa(checksum .. content)
end
end
return checksum
end
Make:add("myhtlatex", function(par)
-- get checksum of temp files before compilation
local checksum = get_checksum(par.input)
local status = htlatex.htlatex(par)
-- stop processing on error
if status ~= 0 then return status end
-- get checksum after compilation
local newchecksum = get_checksum(par.input)
-- this is needed to prevent possible infinite loops
local compilation_count = 1
local max_compilations = 3 -- <- change as you want
while checksum ~= newchecksum do
--
if compilation_count => max_compilations then return status end
status = htlatex.htlatex(par)
-- stop processing on error
if status ~= 0 then return status end
checksum = newchecksum
-- get checksum after compilation
newchecksum = get_checksum(par.input)
compilation_count = compilation_count + 1
end
return status
end)
Make:myhtlatex {}
------------
Best regards,
Michal
More information about the tex4ht
mailing list.