michal-h21 / tex4ebook

Converter from LaTeX to ebook formats (epub, mobi). Using tex4ht and texlua scripts.
317 stars 33 forks source link

sagemath and tex4ebook #108

Open apaeffgen opened 1 year ago

apaeffgen commented 1 year ago

I tried successfully to convert a tex-file with sagemath included. Unfortunately i had to change the ending from tex to txt. The Testfile is attached below. I am new to tex4ebook, so i do not know, what is going on behind, but i experience the following glitches.

  1. Comiling with tex4ebook test.tex produces errors
  2. tex4ebook -x test.tex in the first step works
  3. Afterwords sage has to be envoked. That works
  4. tex4ebook -x test.tex produces an error in the second step
  5. tex4ebook test.tex afterwords works. When the process produced all necessary pictures the -x option works as well without any error. Hopefully someone can reproduce the problem and show some inside why this happens and how to avoid it? See the original testfile and the shortend error-log

test.txt ErrorLog.txt

apaeffgen commented 1 year ago

In the first steps i ended up with a cut epub-file.

Now i can not reproduce the error myself again. Now it works in all steps without the -x flawlessly. Are there some caches? Or what could be the reason?

The errors had been warnings about the domfilter and cut of the epub file i half, leaving the whole file unusable.

[WARNING] domfilter: DOM parsing of testch5.xhtml failed: [WARNING] domfilter: ...ive/2022/texmf-dist/tex/luatex/luaxml/luaxml-mod-xml.lua:175: Unbalanced Tag (/mtext) [char=12730]

michal-h21 commented 1 year ago

You certainly don't need the -x option, this is necessary only if you use commands that require XeTeX. I think your document should work even with the default PDFTeX driver, or with the -l option. Anyway, I've found that the issue with MathML is caused by the \TeX command used in math text. The following configuration file should fix that:

\Preamble{xhtml}
\catcode`\:=11
\def\TeX{\ifmathml
   \ifmtext  TeX\else\HCode{<\a:mathml mtext
      \mml:class="TeX">TeX</\a:mathml mtext>}\fi\else \mml:TeX\fi}
\catcode`\:=12
\begin{document}
\EndPreamble

Compile using:

 $ tex4ebook -c config.cfg test.tex