1

A similar question and an answer can be found on How to get Unicode characters into HTML output but I post a new question because the recommendation regarding my question there is not working for me.

If a run make4ht -ul mwe-htjap where this file contains the following lines

    \documentclass{article}
    %%
    \usepackage{luatexja-fontspec}
    %% \usepackage{fontspec}
    \usepackage{polyglossia}
    \setmainlanguage{english}
    %%
    \begin{document}
The flight was 4½ hours with a 3 hour change.  
We landed in Honolulu.  It was 85° and after 
rearranging the luggage which took a little time, 
ナンシースエンソン quickly got heated up.

And now we are playing 囲碁
\end{document}

I get a lot of error messages, e.g.

    [STATUS]  make4ht: Conversion started
    [STATUS]  make4ht: Input file: mwe-htjap
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.
    [ERROR]   htlatex: Compilation errors in the htlatex run
    [ERROR]   htlatex: Filename Line    Message
    [ERROR]   htlatex: /usr/local/texlive/2022/texmf-dist/tex/luatex/luatexja/luatexja-core.sty 180  Package luatexja Error: DVI output is not supported in LuaTeX-ja.
----------------------------------------------------

(a lot more)...

----------------------------------------------------
--- error --- Can't find/open file  `[/usr/local/texlive/2022/texmf-dist/fonts/opentype/public/haranoaji/   HaranoAjiMincho-Regular.otf].tfm'
[FATAL]   make4ht-lib: Fatal error. Command tex4ht returned exit code 1

I am wondering about the last message, because running the file with lualatex gives no error but a correct PDFfile.

Do I need a htf-file?

Ulrich
  • 917

1 Answers1

1

LuaTeX-ja doesn't play well with TeX4ht, as we don't support OTF fonts (this is what causes the fatal error --- error --- Can't find/open file `[/usr/local/texlive/2022/texmf-dist/fonts/opentype/public/haranoaji/ HaranoAjiMincho-Regular.otf].tfm'). So we need to suppress packages that tries to load OTF fonts. I've already fixed that in TeX4ht sources, but before you get the update in TeX Live, you can use the following .4ht files.

First is usepackage.4ht:

% usepackage.4ht (2022-09-14-19:39), generated from tex4ht-4ht.tex
% Copyright 2003-2009 Eitan M. Gurari
% Copyright 2009-2022 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2022-09-14-19:39}

\def:temp{tex4ht}\ifx :temp@currname :warning{\string\usepackage{tex4ht} again?} \def:temp#1htex4ht.def,tex4ht.sty#2!?: {\def:temp{#2}} \expandafter:temp @filelist htex4ht.def,tex4ht.sty!?: % \ifx :temp\empty \else :warning{if \string\RequirePackage[tex4ht]{hyperref} or \string\usepackage[tex4ht]{hyperref} was used try instead, repectively, \string\RequirePackage{hyperref} or \string\usepackage{hyperref}} \fi

\fi \gdef\a:usepackage{\use:package ,!?: } \gdef\use:package#1,{% \if :#1:\def:temp##1!?: {}\else \def:temp{#1}\ifx @currname:temp \def:temp##1!*?: {\input usepackage.4ht }% \else \let:temp=\use:package \fi \fi :temp} \Configure{PackageHooks}{titlesec.sty}{titlesec-hooks.4ht} \Configure{PackageHooks}{biblatex-chicago.sty}{biblatex-chicago-hooks.4ht} \Configure{PackageHooks}{cleveref.sty}{cleveref-hooks.4ht} \Configure{PackageHooks}{xr.sty}{xr-hooks.4ht} \Configure{PackageHooks}{xr-hyper.sty}{xrhyper-hooks.4ht} \Configure{PackageHooks}{eso-pic.sty}{esopic-hooks.4ht} \Configure{PackageHooks}{showframe.sty}{showframe-hooks.4ht} \Configure{PackageHooks}{expl3.sty}{expl3-hooks.4ht} \Configure{PackageHooks}{savetrees.sty}{savetrees-hooks.4ht} \Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht} \Configure{PackageHooks}{newcomputermodern.sty}{newcomputermodern-hooks.4ht} \Configure{PackageHooks}{fontawesome5-utex-helper.sty}% {fontawesome5-utex-helper-hooks.4ht} \Configure{PackageHooks}{fontawesome5.sty}{fontawesome5-hooks.4ht} \Configure{PackageHooks}{biblatex.sty}{biblatex-hooks.4ht} \Configure{PackageHooks}{xeCJK.sty}{xecjk-hooks.4ht} \Configure{PackageHooks}{unicode-math.sty}{unicode-math-hooks.4ht} \Configure{PackageHooks}{ctex.sty}{ctex-hooks.4ht} \AddToHook{class/ctexart/before}{\input{ctexart-hooks.4ht}} \Configure{PackageHooks}{luatexja.sty}{luatexja-hooks.4ht} \Configure{PackageHooks}{luatexja-fontspec.sty}{luatexja-hooks.4ht} \Configure{PackageHooks}{polyglossia.sty}{polyglossia-hooks.4ht} \Configure{PackageHooks}{fontspec.sty}{fontspec-hooks.4ht} \Configure{PackageHooks}{tikz.sty}{tikz-hooks.4ht} \Configure{PackageHooks}{pdfbase.sty}{pdfbase-hooks.4ht} \Configure{PackageHooks}{pdfx.sty}{pdfx-hooks.4ht} \Configure{PackageHooks}{breakurl.sty}{breakurl-hooks.4ht} \Configure{PackageHooks}{hyperref.sty}{hyperref-hooks.4ht} \Configure{PackageHooks}{bookmark.sty}{bookmark-hooks.4ht} \Configure{PackageHooks}{caption.sty}{caption-hooks.4ht} \Configure{PackageHooks}{babel.sty}{babel-sty-hooks.4ht} \Configure{PackageHooks}{minted.sty}{minted-sty-hooks.4ht} \Configure{PackageHooks}{graphics.sty}{graphics-hooks.4ht} \Configure{PackageHooks}{graphbox.sty}{graphbox-hooks.4ht} \Configure{PackageHooks}{xcolor.sty}{xcolor-hooks.4ht} \Configure{PackageHooks}{imakeidx.sty}{imakeidx-hooks.4ht} \Configure{PackageHooks}{fancyhdr.sty}{fancyhdr-hooks.4ht} \Configure{PackageHooks}{exerquiz.sty}{exerquiz-hooks.4ht} \Configure{PackageHooks}{hyperxmp.sty}{hyperxmp-hooks.4ht} \Configure{PackageHooks}{datetime2.sty}{datetime2-hooks.4ht}

\endinput

It contains instructions for packages that need special treatment, especially if they need to be handled at the moment when they load. The \Configure{PackageHooks}{luatexja-fontspec.sty}{luatexja-hooks.4ht} command will load the luatexja-hooks.4ht file before the package is used. We can block the package from further processing thanks to this file. This is how luatexja-hooks.4ht can look:

% luatexja-hooks.4ht (2022-09-14-19:39), generated from tex4ht-4ht.tex
% Copyright 2022 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2022-09-14-19:39}

:dontusepackage{luatexja} :dontusepackage{luatexja-fontspec} \endinput

The \:dontusepackage blocks the given package from loading. We block both luatexja and luatexja-fontspec here, as both of them cause fatal error with TeX4ht.

With this change, you should get the correct result:

enter image description here

michal.h21
  • 50,697
  • @Jasper and Michal: It is working as mentioned. Great support. – Ulrich Sep 15 '22 at 06:44
  • @Ulrich I only corrected a formatting thing in michal.h21's answer. Credit should only go to them. – Jasper Habicht Sep 15 '22 at 08:58
  • Can I have a "private" usepackage.4ht storing things which are disturbing the process? E.g. I am using lucida-otf and I would like to make the same as you with luatexja with the Lucida font. What I did:
    \ifdefined\HCode      
    \usepackage{libertine}    
    \else     
    \usepackage{lucida-otf}     
    \unimathsetup{partial=upright}   
    \unimathsetup{math-style=ISO}    
    \fi 
    

    which is working. But are there other ways to solve this problem? And what is the meaning of HCode ?

    – Ulrich Sep 16 '22 at 15:20
  • I don`t understand why the code is not shown as code? In the .md file everything is ok. – Ulrich Sep 16 '22 at 15:22
  • It is better to report non-working packages, so I can fix them in the distribution. If you have your local version of usepackage.4ht, you would need to incorporate changes from the updates in TeX Live :/ – michal.h21 Sep 16 '22 at 15:51
  • OK, I understand. Then please add lucida-otf . see https://ctan.org/search?phrase=lucida-otf – Ulrich Sep 16 '22 at 19:39
  • @Ulrich I will. if you post new question, I can post the solution here. – michal.h21 Sep 16 '22 at 19:59