3

sometimes I like to use -a warning with make4ht to reduce the amount of information printed.

The big problem is that it does not stop at first error. It keeps running.

When I change to -a debug it stops at the error.

How can one use -a warning but make it stop at the first error? Here is an example of a.tex which loads image ZZZ which does not exist. This is run using the command

make4ht -ulm default -a warning  a.tex "htm,mathjax"

Here is MWE

\documentclass[12pt]{book}
\usepackage{graphicx}
\begin{document} 
My document
\includegraphics[width=\textwidth]{ZZZ}
\end{document}

Notice now what happens when I use -a warning

>make4ht -ulm default -a warning  a.tex "htm,mathjax"
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.

Those are 3 passes it did. It did not stop at first error but kept going. Compare to what happens when using -a debug

make4ht -ulm default -a debug  a.tex "htm,mathjax"
[INFO]    mkparams: Output dir: 
[INFO]    mkparams: Compiler: dvilualatex
etc...
(./a.aux) (/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)

! LaTeX Error: File `ZZZ' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.15 \includegraphics[width=\textwidth]{ZZZ}
                                          
? 

And compilation stops and does not go to next phase. This is what I want. I just want the same with -a warning.

How to do that? In my builds, one tex4ht pass can take hrs. I do not want to wait many hrs only to find later that there was an error and I did not see it. I want my makefile to stop at the first error to save time.

ps. I did try all a options

debug, info, status, warning, error, fatal

And only -a debug stops at first error. fatal does not display anything. So I have no idea where it stops as nothing at all is printed on screen (maybe because there was no FATAL error?)

>make4ht -ulm default -a status  a.tex "htm,mathjax"
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: a.tex
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.
[STATUS]  make4ht: Conversion finished

And

>make4ht -ulm default -a error  a.tex "htm,mathjax"
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./a.tex  15   LaTeX Error: File `ZZZ' not found.

And

>make4ht -ulm default -a fatal  a.tex "htm,mathjax"
>

It will be great if there is an option that shows same level of output as -a warning but also stops on error just -a debug does

TL 2022

1
  • try out all -a options, and if none of them fits your need, make a feature request. You should know by now that the maintainer is quite nice and willing to adapt things. Commented Jun 26, 2023 at 7:51

1 Answer 1

2

This is by design. The -a debug option uses the default LaTeX behaviour, so it prints all terminal output, and also stops on errors, like LaTeX does by default. In all other make4ht log levels, LaTeX runs in the non stop mode and the terminal output is read by make4ht and then parsed for errors or warnings.

In theory, you could try to run something like this:

 $ make4ht -m warning -m draft sample.tex "" "" "" "-interaction=errorstopmode

It passes the -interaction=errorstopmode to the underlying LaTeX compiler. It stops on errors, but as the output is suppressed by make4ht, you don't see any error messages, the compilation just stops and waits for your input. So this isn't really useful.

What I think could be useful in your case, is to stop the compilation on the first error. TeX compiler has an option for that, -halt-on-error. You can use the following build file to use this option with make4ht:

Make:htlatex { latex_par="-halt-on-error"}

When you now compile your file with:

$ make4ht -a warning -e build.lua sample.tex

Now, make4ht will stop processing your file on the first error, which will result in faster compilation.

9
  • Thanks, but draft is not an option for me, as I want final document build. Problem with using debug mode is too much output and makes it hard to see where build is. I was trying to solve this by redirecting stdout only to /dev/null but for some reason, it is not working. Would you know why? Here is screen shot !Mathematica graphics I just typed make4ht -ulm default -a debug a.tex "htm,mathjax" 1> /dev/null but now I can not even ^C out of it. It is stuck.
    – Nasser
    Commented Jun 26, 2023 at 16:15
  • @Nasser and why do you want to stop on errors? I think the warning log level is good for you. Once you redirect the output, it will stuck on errors, but you will not see error messages. You should use x instead of Ctrl-C in that case
    – michal.h21
    Commented Jun 26, 2023 at 17:29
  • If I have a build that takes 10 hrs, I will not notice the error unless I am sitting looking at screen 100% of the time to notice. This is not practical solution. But with -a debug the makefile stops and so I can see right away the error on the screen anytime since it stopped scrolling. This way I do not waste time and get a build that is not complete and not know about it. I will just use -a debug and live with all the output because I need to stop the build when an error happens right away. but too much outpout also slows things. So this is not perfect solution.
    – Nasser
    Commented Jun 26, 2023 at 17:34
  • It will be great if there is an option that shows same level of output as -a warning but also stops on error just -a debug does.
    – Nasser
    Commented Jun 26, 2023 at 17:37
  • 1
    @Nasser I've edited my answer with an option how to stop the compilation on error.
    – michal.h21
    Commented Jun 28, 2023 at 9:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .