Make4ht and fontspec: lualatex not recognized

fontspecmake4ht

I added \usepackage{fontspec} to my .tex file and the magic comment % !TeX program = lualatex in the preamble of my document.

Since I did so, I can no longer convert my document to HTML from a .bat script using make4ht. I receive the error message:

htlatex: ? 45 Fatal Package fontspec Error: The fontspec package requires either XeTeX or LuaLaTeX

I read the question after changing to \usepackage{fontspec} now make4ht do not compile my Latex file in lualatex mode and I still don't understand the problem. The answer to this question (from michal.h21) states that:

Fontspec support have been just added to tex4ht, you can get it after TL update. Both XeLaTeX and LuaLaTeX are supported, although the implementation is different for both engines.

Why does make4ht not recognize the use of LuaLaTex despite the magic comment?

Best Answer

The comment is just that, a comment. It has no special status to tex. Some editors read comments in that form but the syntax varies from editor to editor.

make4ht has a commandline option to tell it to use luatex: make4ht -l

make4ht also supports these comments, but not by default. You can try

make4ht -f html5+detect_engine filename.tex. 
Related Question