bugtex4ht - 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 <michal_h21>
Submitted on:  Thu 08 Oct 2020 12:04:37 AM EEST  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Sat 17 Oct 2020 02:14:09 PM EEST, 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:

\<add to usepackage\><<<
\Configure{PackageHooks}{packagename.sty}{packagename-hooks.4ht}

>>>


\<packagename-hooks.4ht\><<<
% code that fixes the package loading

>>> \AddFile{9}{packagename-hooks}

Michal Hoftich <michal_h21>
Project Member
Fri 16 Oct 2020 09:47:30 PM EEST, 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>
Project Member
Thu 15 Oct 2020 04:32:04 AM EEST, 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>
Project Administrator
Thu 08 Oct 2020 07:32:32 PM EEST, 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
% ... more copyright lines

\AddToHook{package/after/catchfile}{
\def\CatchFile@CheckFileExists#1{%
\IfFileExists{#1}{%
\expandafter\CatchFile@DefFile\@filef@und\@nil
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @addtofilelist\endcsname\relax
\else
\@addtofilelist{#1}
\fi
}{%
\let\CatchFile@File\relax
}%
}%
}

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

Michal Hoftich <michal_h21>
Project Member
Thu 08 Oct 2020 12:04:37 AM EEST, 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>
Project Member

 

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?
    If so, you can click here to add your encouragement to it.
    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):

     

     

    1 latest change follows.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 08 Oct 2020 07:32:32 PM EESTmichal_h21Open/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray