Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-26 Thread Nasser M. Abbasi

On 4/24/2022 4:01 PM, Michal Hoftich wrote:

Sorry, there was still an error in my previous email, the condition should be

if compilation_count >= max_compilations then return status end

instead of

if compilation_count => max_compilations then return status end

Best regards,
Michal


Thanks Michal.

I've used the updated build file with the corrections. Set
the max_compilation to 5 instead of 3.

Run the build and it used all 5 and no more. So it worked.

Each call to dvilualatex took about 3 hrs to complete.

The whole build, including making the PDF file took:
---
[INFO]make4ht: outdir:
[STATUS]  make4ht: Conversion finished
Tuesday 04/26/22  01:25:21 AM

real1422m3.030s
user1216m55.415s
sys 10m44.752s



-

Which is about 23.7 hrs. On Linux Ubuntu 20.04 running under
WSL 2.0 under windows 10 Linux subsystem. 128 GB RAM.

It is a large webpage with lots of tables. The PDF is 43,630 pages.

The good news is that now all  chapters in the table of content
show up and there are no lost sections in the last chapter TOC
as before and all links work and I see no ??? where links
point to in tables.

It must be that the earlier default "3" runs was the cause.

It was not enough runs, and needed 2 more to "fix" things? I do
not know. But this is the only thing that is really different
from last time I tried this. It looks like the larger the web
page, the more runs tex4ht needs.

Here is a link to the above page



Thanks again for your help.

--Nasser


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-24 Thread Michal Hoftich
Sorry, there was still an error in my previous email, the condition should be

if compilation_count >= max_compilations then return status end

instead of

if compilation_count => max_compilations then return status end

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-24 Thread Michal Hoftich
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


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-24 Thread Nasser M. Abbasi

On 4/24/2022 10:11 AM, Michal Hoftich wrote:


But when now I use the same command again, but do not
clear the folder and keep all intermediate files generated from earlier
command, it now calls dvilualatex one time only and not 2 times.

Just wanted to make sure this is all what is expected as I want
to use this in my main makefiles.


Yes, it is as expected.

Best regards,
Michal


Thanks for the clarification.

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.

Normally it needs only 3-4 calls.

I assume each call to dvilualatex  correspond to one call that make4ht
makes, which we are trying to optimize.

I see you had a check in the build file to protect against this.
But for some reason, this was not activated.  I only changed the
max from 3 to 5 in the code you posted.

But I saw 10 times, and it was going into the 11th when I killed the
build.  I have no  idea why. So I am back to using default, which
is 3 times.

Thank you,
--Nasser





Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-24 Thread Michal Hoftich
Hi Nasser,


>
> Just a clarification. I now trying using your build file above to optimize
> the number of times tex4ht is called.
>
> Do I need to also add
>
> \Preamble{xhtml}
> \typeout{(\jobname.4tc)}
> \begin{document}
> \EndPreamble
>
> to my .cfg? or is this above for use with the other method you showed
> which is using latexml?
>

No, you don't need it with the build file, as it doesn't use latexmk.
I've also fixed most issues regarding latexmk in TeX4ht sources and in
make4ht, so this line shouldn't be necessary anyway, if you use an
up-to-date system.

> So if I just want to use the above build file, is it enough to just
> load it using -e  build_file.mk4   where build_file.mk4 is what you
> show above or do I need to do something more to my .cfg?
>
> btw, when I try the above on a simple file, it calls
> tex4ht twice starting from clean folder. I assume this is normal?

>
> Is the above expected? why 2 times on this simple file?
>

Yes, because checksums of temporary files differ after the first
compilation, as they were empty at the beginning. They should use just
one compilation afterwards, unless auxilary  files change.

> But when now I use the same command again, but do not
> clear the folder and keep all intermediate files generated from earlier
> command, it now calls dvilualatex one time only and not 2 times.
>
> Just wanted to make sure this is all what is expected as I want
> to use this in my main makefiles.

Yes, it is as expected.

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-22 Thread Nasser M. Abbasi

On 4/19/2022 4:30 AM, Michal Hoftich wrote:

Hi Nasser



Thanks, but the issue is, how does one know if they
need to run it 1, 2 or 3 times? What code do I need to add
to the above to decide?
With lualatex, now this is what I do and it works (other option is to
use latexmk, but for some other reasons, I prefer to stick to makefiles
for now).



One possibility is to use the latexmk_build extension, like in:

   make4ht -f html5+latexmk_build sample.tex

Another option is to check temporary files for changes. Using some
hash function. Like in this build file:


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)
   end
   return status
end)

Make:myhtlatex {}
-

Best regards,
Michal


Hello Michal;

Just a clarification. I now trying using your build file above to optimize
the number of times tex4ht is called.

Do I need to also add

\Preamble{xhtml}
\typeout{(\jobname.4tc)}
\begin{document}
\EndPreamble

to my .cfg? or is this above for use with the other method you showed
which is using latexml?

So if I just want to use the above build file, is it enough to just
load it using -e  build_file.mk4   where build_file.mk4 is what you
show above or do I need to do something more to my .cfg?

btw, when I try the above on a simple file, it calls
tex4ht twice starting from clean folder. I assume this is normal?
i.e. from clean folder:

--
cat report.tex
\documentclass[11pt]{book}
\begin{document}

test
\end{document}
---

and now


make4ht  --shell-escape -ulm default -a debug
 -c nma_mathjax.cfg
 --build-file $TEXMFHOME/tex/latex/tex4ht_build_files/MAIN.mk4
  report.tex
  "mathjax,htm,fn-in,1,notoc*,p-width,charset=utf-8" "-cunihtf -utf8" "" 
"--interaction=batchmode"
---

Shows it calls dvilualatex twice

[INFO]htlatex: LaTeX call: dvilualatex --interaction=errorstopmode -jobname='report'  
--interaction=batchmode -shell-escape 
'\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\AddToHook{class/before}{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname
 
tex4ht\endcsname{#1,html}\def\HCode1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode
 nma_mathjax.cfg,mathjax,htm,fn-in,1,notoc*,p-width,charset=utf-8,charset=utf-8,html5.a.b.c.\input 
"\detokenize{report.tex}"'
This is LuaTeX, Version 1.15.0 (TeX Live 2022)
 system commands enabled.

[INFO]htlatex: LaTeX call: dvilualatex --interaction=errorstopmode 
-jobname='report'

--interaction=batchmode -shell-escape 
'\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\AddToHook{class/before}{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname
 
tex4ht\endcsname{#1,html}\def\HCode1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode
 nma_mathjax.cfg,mathjax,htm,fn-in,1,notoc*,p-width,charset=utf-8,charset=utf-8,html5.a.b.c.\input 
"\detokenize{report.tex}"'
This is LuaTeX, Version 1.15.0 (TeX Live 2022)
 system commands enabled.

.
[STATUS]  make4ht: Conversion finished

Is the above expected? why 2 times on this simple file?

But when now I use the same command again, but do not
clear the folder and keep all intermediate files generated from earlier
command, it now 

Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-22 Thread Michal Hoftich
Hi Nasser,

> Reason I am asking, is that it is easy to count/find the
> number of times needed to call lulatex. So I could use that number of
> times, to also call tex4ht on same file.

It is hard to say. For correct cross-references, two runs are usually
enough. But there are some cases regarding tables, where even more
runs than three are necessary - the same number as number of columns
is needed. But I don't remember  what feature it was, and I cannot
reproduce it now. But anyway, when you don't add new sections,
cross-refs, etc., one compilation is enough.

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-21 Thread Nasser M. Abbasi

I have follow up question:

is the number of times one has to compile the latex file using
lualatex related and will be same as number of times one has
to compile it to HTML using tex4ht?

I mean, if I find that on one file, I need to run lualatex 3 times
to get all references and labels sorted out, does this mean
the same number of times would be needed for tex4ht?

Or not necessarily so? and these are not releated and can be different?

Reason I am asking, is that it is easy to count/find the
number of times needed to call lulatex. So I could use that number of
times, to also call tex4ht on same file.

--Nasser

On 4/19/2022 11:07 PM, Wojciech Myszka wrote:

Dear Michal


In the meantime, you can use something like this config file:


and this solves the problem.

Best regards
Wojtek

wt., 19 kwi 2022 o 22:43 Michal Hoftich  napisał(a):


Hi Wojtek,



I have got the perfect results.

But after changing \section{test} into \section{Test test} and using

latexmk extension, after one latex run the main content in the HTML file is
updated, but the table of contents—is not. This is probably(?) caused by
fact that .toc file is not produced by tex4ht


And this is strange because the .4tc file is updated, but the .4ct not?

On the other hand, making major changes to the source file

(adding/removing another section) — rebuilds the document. The minor change
— (in section title) leaves the table of contents untouched.


It seems that latexmk does not recognize file .4tc as generated during

compilation. The hint in latexmk documentation for solving situation, that
latexmk won’t notice a dependency on a file, bar.baz say is to add (in the
source) \typeout{(bar.baz)}.

Ah, if latexmk needs the filename of .4tc file in the console, I can
add it to TeX4ht sources. In fact, I just did it now. In the meantime,
you can use something like this config file:

\Preamble{xhtml}
\typeout{(\jobname.4tc)}
\begin{document}
\EndPreamble

Best regards,
Michal








Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Michal Hoftich
Hi Wojtek,


> I have got the perfect results.
>
> But after changing \section{test} into \section{Test test} and using latexmk 
> extension, after one latex run the main content in the HTML file is updated, 
> but the table of contents—is not. This is probably(?) caused by fact that 
> .toc file is not produced by tex4ht
>
> And this is strange because the .4tc file is updated, but the .4ct not?
>
> On the other hand, making major changes to the source file (adding/removing 
> another section) — rebuilds the document. The minor change — (in section 
> title) leaves the table of contents untouched.
>
> It seems that latexmk does not recognize file .4tc as generated during 
> compilation. The hint in latexmk documentation for solving situation, that 
> latexmk won’t notice a dependency on a file, bar.baz say is to add (in the 
> source) \typeout{(bar.baz)}.

Ah, if latexmk needs the filename of .4tc file in the console, I can
add it to TeX4ht sources. In fact, I just did it now. In the meantime,
you can use something like this config file:

\Preamble{xhtml}
\typeout{(\jobname.4tc)}
\begin{document}
\EndPreamble

Best regards,
Michal



Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Wojciech Myszka
Hey Michal,

Thank you very much. It looks very promising. But…

There is some new(?) problem. Starting with test file:

\documentclass[]{article}
\begin{document}
\section{test}
test test
\tableofcontents
\end{document}

I have got the perfect results.

But after changing \section{test} into \section{Test test} and using
latexmk extension, after one latex run the main content in the HTML file is
updated, but the table of contents—is not. This is probably(?) caused by
fact that .toc file is not produced by tex4ht

And this is strange because the .4tc file is updated, but the .4ct not?

On the other hand, making major changes to the source file (adding/removing
another section) — rebuilds the document. The minor change — (in section
title) leaves the table of contents untouched.

It seems that latexmk does not recognize file .4tc as generated during
compilation. The hint in latexmk documentation for solving situation, that
latexmk won’t notice a dependency on a file, bar.baz say is to add (in the
source) \typeout{(bar.baz)}.

But this is strange—sometimes some minor changes cause rebuilding also a
table of contents.

Regards

Wojtek

wt., 19 kwi 2022 o 21:04 Michal Hoftich  napisał(a):

> Hi Wojtek,
>
> > The .tmp file is multipurpose.
> >
> > After the latex run the .tmp file contains \def \Jobname{a} but further
> processing by make4ht internal routines changes the content to
> >
> > /* css.sty */
>
> I've changed the latexmk extension to save contents of the .tmp file
> before tex4ht execution. It then restores it's content. It seems to
> solve the latexmk issues.
>
> Best regards,
> Michal
>


-- 
---(___C'>


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Michal Hoftich
Hi Wojtek,

> The .tmp file is multipurpose.
>
> After the latex run the .tmp file contains \def \Jobname{a} but further 
> processing by make4ht internal routines changes the content to
>
> /* css.sty */

I've changed the latexmk extension to save contents of the .tmp file
before tex4ht execution. It then restores it's content. It seems to
solve the latexmk issues.

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Wojciech Myszka
Hi Michal,

Mystery solved.

The .tmp file is multipurpose.

After the latex run the .tmp file contains \def \Jobname{a} but further
processing by make4ht internal routines changes the content to


/* css.sty */

Regards

Wojtek



wt., 19 kwi 2022 o 17:05 Michal Hoftich  napisał(a):

> Hi Wojtek.
>
> > Adding latexmk gives five runs of latex during the first run of a make4ht
>
> it seems that you are right, two additional LaTeX runs are used with
> the latexmk extension. I've fixed it in make4ht sources, it now
> removes all additional runs. I don't know why it detects changes in
> the .tmp file. It  would be best if latexmk could ignore it, but it
> seems that a latexmk config file is necessary for that.
>
> Best regards,
> Michal
>


-- 
---(___C'>


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Michal Hoftich
Hi Wojtek.

> Adding latexmk gives five runs of latex during the first run of a make4ht

it seems that you are right, two additional LaTeX runs are used with
the latexmk extension. I've fixed it in make4ht sources, it now
removes all additional runs. I don't know why it detects changes in
the .tmp file. It  would be best if latexmk could ignore it, but it
seems that a latexmk config file is necessary for that.

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Wojciech Myszka
Well‚

Even in the simplest possible case, when the input file is as simple as:

\documentclass{article}
\begin{document}
aaa
\end{document}

“standard” make4ht makes three runs of latex on an input file on each run.

Adding latexmk gives *five* runs of latex during the first run of a make4ht

Even not introducing any changes to input (in an ideal word no run of latex
is needed) we got *4 (four)* runs of latex. Looking into logs from latexmk
in the first run (“Changed files, or newly in use[…}”) we got for the run
number

   1. a.tex
   2. a.aux, a.tmp
   3. a.xref

During the second run, we got

   1. a.tmp
   2. a.tmp

This means that after each run of latex checksum for the file a.tmp changes.

 Best regards

Wojtek

wt., 19 kwi 2022 o 11:31 Michal Hoftich  napisał(a):

> Hi Nasser
>
> >
> > Thanks, but the issue is, how does one know if they
> > need to run it 1, 2 or 3 times? What code do I need to add
> > to the above to decide?
> > With lualatex, now this is what I do and it works (other option is to
> > use latexmk, but for some other reasons, I prefer to stick to makefiles
> > for now).
> >
>
> One possibility is to use the latexmk_build extension, like in:
>
>   make4ht -f html5+latexmk_build sample.tex
>
> Another option is to check temporary files for changes. Using some
> hash function. Like in this build file:
>
> 
> 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)
>   end
>   return status
> end)
>
> Make:myhtlatex {}
> -
>
> Best regards,
> Michal
>


-- 
---(___C'>


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Michal Hoftich
Hi Nasser

>
> Thanks, but the issue is, how does one know if they
> need to run it 1, 2 or 3 times? What code do I need to add
> to the above to decide?
> With lualatex, now this is what I do and it works (other option is to
> use latexmk, but for some other reasons, I prefer to stick to makefiles
> for now).
>

One possibility is to use the latexmk_build extension, like in:

  make4ht -f html5+latexmk_build sample.tex

Another option is to check temporary files for changes. Using some
hash function. Like in this build file:


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)
  end
  return status
end)

Make:myhtlatex {}
-

Best regards,
Michal


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-19 Thread Wojciech Myszka
It is somehow a theoretical (i cannot put it to work) possibility to use
latexmk with make4ht (described in the documentation:
https://github.com/michal-h21/make4ht#extensions).
Maybe this helps.

Best regards
Wojtek

wt., 19 kwi 2022 o 00:29 Nasser M. Abbasi  napisał(a):

> On 4/18/2022 5:21 PM, Michal Hoftich wrote:
>
> >You can of
> > course change that using a build file, where you can declare your own
> > modes and declare commands to be executed.
> >
> > The default is this:
> >
> > if mode=="draft" then
> >Make:htlatex{}
> > else
> >Make:htlatex{}
> >Make:htlatex{}
> >Make:htlatex{}
> > end
> >
>
> Thanks, but the issue is, how does one know if they
> need to run it 1, 2 or 3 times? What code do I need to add
> to the above to decide?
>
> With lualatex, now this is what I do and it works (other option is to
> use latexmk, but for some other reasons, I prefer to stick to makefiles
> for now).
>
> --
> lualatex  -halt-on-error -interaction=batchmode --shell-escape
> -file-line-error index.tex
>
> if  grep -E 'Rerun to get it removed|Temporary extra page added at the
> end|There were undefined references' index.log ; then
>  echo "Need to RUN one more time"
>  lualatex  -halt-on-error -interaction=batchmode --shell-escape
> -file-line-error index.tex
>  if  grep -E 'Rerun to get it removed|Temporary extra page added at
> the end|There were undefined references' index.log  ; then
>  echo "Need to RUN one more time"
>  lualatex  -halt-on-error -interaction=batchmode --shell-escape
> -file-line-error index.tex
>  fi
> fi
> ---
>
> The above checks after each run if it needs to run again. It does it only
> 3 times. No need for more.
>
> I do not know what to check for with tex4ht or how to do the above
> in the build lua file you show.
>
> How to decide?
>
> > Best regards,
> > Michal
>
> --Nasser
>


-- 
---(___C'>


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-18 Thread Nasser M. Abbasi

On 4/18/2022 5:21 PM, Michal Hoftich wrote:


You can of
course change that using a build file, where you can declare your own
modes and declare commands to be executed.

The default is this:

if mode=="draft" then
   Make:htlatex{}
else
   Make:htlatex{}
   Make:htlatex{}
   Make:htlatex{}
end



Thanks, but the issue is, how does one know if they
need to run it 1, 2 or 3 times? What code do I need to add
to the above to decide?

With lualatex, now this is what I do and it works (other option is to
use latexmk, but for some other reasons, I prefer to stick to makefiles
for now).

--
lualatex  -halt-on-error -interaction=batchmode --shell-escape -file-line-error 
index.tex

if  grep -E 'Rerun to get it removed|Temporary extra page added at the 
end|There were undefined references' index.log ; then
echo "Need to RUN one more time"
lualatex  -halt-on-error -interaction=batchmode --shell-escape 
-file-line-error index.tex
if  grep -E 'Rerun to get it removed|Temporary extra page added at the 
end|There were undefined references' index.log  ; then
echo "Need to RUN one more time"
lualatex  -halt-on-error -interaction=batchmode --shell-escape 
-file-line-error index.tex
fi
fi
---

The above checks after each run if it needs to run again. It does it only
3 times. No need for more.

I do not know what to check for with tex4ht or how to do the above
in the build lua file you show.

How to decide?


Best regards,
Michal


--Nasser


Re: [tex4ht] How to control/optimize the number of times make4ht runs dvilualatex?

2022-04-18 Thread Michal Hoftich
Hi Nasser,

> For tex4ht, it seems to always run 3 times. Even for the most
> simple files. Here is an example

Yes, make4ht runs latex three times, same as htlatex did.

>
> Running the command (all on one line)
>
> time make4ht -ulm default -a debug report.tex "mathjax,htm"

User the -ulm draft option to compile your file only once. If you
don'ŧ remove temporary files between make4ht, it should suffice.

> My question is: how does make4ht decide it needs to run 3 times
> each time? Is it possible to make it more optimal? How would the
> user control this from outside?

There is only one built-in mode, draft. If you use it, it will call
LaTeX once. In every other case, it calls it three times. You can of
course change that using a build file, where you can declare your own
modes and declare commands to be executed.

The default is this:

if mode=="draft" then
  Make:htlatex{}
else
  Make:htlatex{}
  Make:htlatex{}
  Make:htlatex{}
end

Best regards,
Michal