tex4ht - Bugs: bug #486, Strange error with minted

Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #486: Strange error with minted

 Submitted by: Michal Hoftich Submitted on: Wed Oct 7 21:04:37 2020 Category: None Priority: 5 - Normal Severity: 5 - Normal Status: None Privacy: Public Assigned to: None Open/Closed: Closed

Sat Oct 17 11:14:09 2020, comment #4:

Ok, so I've introduced a new configuration for early package patches. As testing for file existence is too slow, it will need to be declared in usepackage.4ht. So it isn't as flexible as the way I tried with the <packgename>-sty-hooks.4ht file, but it is faster and easier to write than the old way.

To introduce the early package hooks, you can now write the following code in tex4ht-4ht.tex:

\Configure{PackageHooks}{packagename.sty}{packagename-hooks.4ht}

>>>

\<packagename-hooks.4ht\><<<

Michal Hoftich <michal_h21>
Fri Oct 16 18:47:30 2020, comment #3:

Yes, but TeX4ht tries to include "\jobname.4ht, which comes from "\jobname.w18" that is added to \@filelist by Catchfile. TeX4ht tries to process the \@filelist and to load corresponding .4ht file for each file that is specified in it. And here it happens that it removes .w18" from the filename and tries to load "\jobname.4ht, which results in the error.

I've found where to insert the fix. It is in tex4ht-cond4ht.tex. It contains the code that process the files in \@filelist and that loads the .4ht files for them. This code is reused in .4ht files for output formats (html4.4ht, tei.4ht, ...), so it is necessary to remove all .4ht files using "make clean" to force their rebuild.

I've also found that the new code for package fixes that I introduced earlier slows down the package processing significantly, due the check for file existence. I will need to fix this as well.

Michal Hoftich <michal_h21>
Thu Oct 15 01:32:04 2020, comment #2:

The unbalanced quote message is not coming fromtex4ht. As far as I can tell, it comes from l3file.dtx (texmf-dist/source/latex/l3kernel), around line 2486 (at the moment):

\cs_new:Npn \__kernel_file_name_strip_quotes:nnn #1#2#3
{
\int_if_even:nT {#2}
{
\__kernel_msg_expandable_error:nnn
{ kernel } { unbalanced-quote-in-filename } {#1}

l3kernel is included in the LaTeX(2e).fmt files now.

By the way, even if LaTeX didn't check, the binaries would report the error (web2c/lib/texmfmp.c, function normalize_quotes). Quotes have to be balanced in filenames for security reasons, otherwise the quoting of special characters (so filenames like "|rm -rf /" don't actually run anything) might get defeated.

Karl Berry <karl>
Thu Oct 8 16:32:32 2020, comment #1:

I've found that the issue was caused by the Catchfile package. It added quoted file to the list of used files. I've added fix for that.

In the process, I've added a new mechanism for early package redefinitions. Instead of usepackage.4ht, it is possible to create file <packagename>-sty-hooks.4ht. It looks like this for the Catchfile package:

% catchfile-sty-hook.4ht, generated from tex4ht-4ht.tex

\def\CatchFile@CheckFileExists#1{%
\IfFileExists{#1}{%
\expandafter\CatchFile@DefFile\@filef@und\@nil
\begingroup\expandafter\expandafter\expandafter\endgroup
\else
\fi
}{%
\let\CatchFile@File\relax
}%
}%
}

It uses the new LaTeX hook mechanism to insert code after the package is processed.

Michal Hoftich <michal_h21>
Wed Oct 7 21:04:37 2020, original submission:

I've got a strange error after recent LaTeX update. TeX4ht produces errors when the Minted package is used:

\documentclass{article}
\usepackage{minted}
\begin{document}
hello world
\end{document}

You can compile this document using:

make4ht -sm draft filename.tex

It produces the following errors:

[ERROR] htlatex: ./tex4ht.sty 4603 Undefined control sequence.
[ERROR] htlatex: ./tex4ht.sty 4603 Undefined control sequence.
[ERROR] htlatex: ./tex4ht.sty 4603 Undefined control sequence.
[ERROR] htlatex: /usr/local/texlive/2020/texmf-dist/tex/latex/xcolor/xcolor.sty 1455 Missing number, treated as zero.
[ERROR] htlatex: /usr/local/texlive/2020/texmf-dist/tex/latex/xcolor/xcolor.sty 1455 LaTeX Error: Missing \begin{document} in `'.

When I compile it in the debug mode, I get some more info:

<argument> LaTeX3 error:
Unbalanced quotes in file name '"filename.4ht'.

I guess that it is somehow related to the LaTeX kernel update :(

Michal Hoftich <michal_h21>

No files currently attached

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -unavailable- added by karl (Posted a comment)
• -unavailable- added by michal_h21 (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only logged-in users can vote.

Please enter the title of George Orwell's famous dystopian book (it's a date):