michal-h21 / make4ht

Build system for tex4ht
131 stars 15 forks source link

The `\mintinline` from minted doesn't work #141

Open gnull opened 6 months ago

gnull commented 6 months ago

The #100 says make4ht supports minted. Does it also support inline minted code? I get odd errors when I try to use it. Is there something I'm doing wrong?

I get errors with the following code:

\documentclass{article}
\usepackage{minted}
\begin{document}

Hello

The \mintinline[breaklines]{haskell}{undefined = fix id} where
\mintinline{haskell}{undefined :: a} is an example of ``bottom,'' $\bot$.

\end{document}

Here's the output of make4ht:

$ make4ht -l -sm draft -f html5 main.tex
[STATUS]  make4ht: Conversion started
[STATUS]  make4ht: Input file: main.tex
[WARNING] tocid: char-def module not found
[WARNING] tocid: cannot fix section id's
[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ./main.tex   7    File ended while scanning use of \FancyVerbGetVerb.
[ERROR]   htlatex: ./main.tex   8    File ended while scanning use of \FancyVerbGetVerb.
[ERROR]   htlatex: ./main.tex   10   LaTeX Error: \begin{Verbatim} on input line 1 ended by \end{document}.
[ERROR]   htlatex: ./_minted-main/E80853D786930D9B9D6B28074746889030DD53A90409CC6BC303037BEC7EE6D   3    Missing number, treated as zero.
[ERROR]   htlatex: ./_minted-main/9BF96440102F3816FEA6A538A54D78D82D73E504A4797ED0276D6719704366A   3    Missing number, treated as zero.
[STATUS]  make4ht: Conversion finished
michal-h21 commented 6 months ago

Thanks for the report. It seems that Minted changed the way how it handled the \mintinline command, so it stopped to works. The error seems to be caused by TeX4ht's config file for the Fancyverb package. Try this version of fancyvrb.4ht:

% fancyvrb.4ht (2024-01-04-16:42), generated from tex4ht-4ht.tex
% Copyright 1997-2009 Eitan M. Gurari
% Copyright 2009-2024 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 2024-01-04-16:42}

   \pend:def\FV@FormattingPrep{\let\fv:color\empty
  \ifx \color\:UnDef\else\Configure{color}{\xdef\fv:color}\fi
}
\append:def\FV@FormattingPrep{\a:fancyvrb%
   \ifx \FV@BeginListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \a:fancyvrbframe
\fi
\ifx \FV@LeftListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \b:fancyvrbframe
\fi
\ifx \FV@EndListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \c:fancyvrbframe
\fi
\ifx \FV@RightListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \d:fancyvrbframe
\fi
%
   \bgroup
  \ifx \fv:color\empty \else{%
     \let\HColor\fv:color \a:fancyvrbcolor%
  }\fi
  \ifx \FancyVerbFillColor\relax \else%
     \:fvcolor \b:fancyvrbcolor \FancyVerbFillColor!*?: %
  \fi
  \ifx \FancyVerbRuleColor\relax \else%
     \:fvcolor \c:fancyvrbcolor \FancyVerbRuleColor!*?: %
  \fi
\egroup
\let\FV@BeginListFrame\relax
\let\FV@LeftListFrame\relax
\let\FV@RightListFrame\relax
\let\FV@EndListFrame\relax
%
}
\def\FV@ListProcessLine#1{%
    \hbox{\c:fancyvrb \anc:lbl r{FancyVerbLine}\FV@LeftListNumber%
      \FV@LeftListFrame \e:fancyvrb \FancyVerbFormatLine{#1}\f:fancyvrb%
      \FV@RightListFrame \csname FV@RightListNumber\endcsname %
          \d:fancyvrb}}
\def\FV@ListProcessLine@iii#1{%
  \box\@tempboxa
  \setbox\@tempboxa=\FV@ListProcessLine{#1}%
  \let\FV@ProcessLine\FV@ListProcessLine@iv}
\def\FV@ListProcessLine@iv#1{%
  % we use \nobreak to really prevent unwanted line breaks
  % see https://github.com/michal-h21/make4ht/issues/104
  \box\@tempboxa\nobreak%
  \setbox\@tempboxa=\FV@ListProcessLine{#1}}%
\def\FV@ListProcessLastLine{%
  \ifx\FV@ProcessLine\FV@ListProcessLine@iv
    \box\@tempboxa
  \else
    \ifx\FV@ProcessLine\FV@ListProcessLine@iii
      \box\@tempboxa
    \else
      \ifx\FV@ProcessLine\FV@ListProcessLine@i
        \FV@Error{Empty verbatim environment}{}%
        \FV@ProcessLine{}%
      \fi
    \fi
  \fi}

\def\FV@EndList{\FV@ListProcessLastLine  \FV@EndListFrame%
  \IgnorePar\b:fancyvrb\par\@endparenv%
  \endgroup   \@endpetrue}
\def\FV@StepLineNo{%
  \FV@SetLineNo%
  \def\FV@StepLineNo{\SkipRefstepAnchor\refstepcounter{FancyVerbLine}}%
  \FV@StepLineNo}
\pend:defI\FVC@Verb{\bgroup\let\a:fancyvrb\empty\a:verb}
\append:defI\FVC@Verb{\b:verb\egroup}
\def\:tempa#1{\mbox{\FV@UseKeyValues%
   \let\a:fancyvrb\empty \FV@FormattingPrep%
   \a:verb #1\b:verb}}
\HLet\:tempa\FV@UseVerb
\def\:fvcolor#1{\def\a:color##1##2!*?: {%
   \Configure{SetHColor}#1{##1}}}%
\define@key{FV}{framerule}{%
  \@tempdima=#1\relax%
  \edef\FV@FrameRule{\number\@tempdima sp\relax}%
  {\Advance:\fancyvrbNo by 1   \tmp:dim=\FV@FrameRule%
   \edef\HSize{\the\tmp:dim}%
   \e:fancyvrbframe}}
\define@key{FV}{framesep}{%
  \@tempdima=#1\relax%
  \edef\FV@FrameSep{\number\@tempdima sp\relax}%
  {\Advance:\fancyvrbNo by 1    \tmp:dim=\FV@FrameSep%
   \edef\HSize{\the\tmp:dim}%
   \f:fancyvrbframe}}
\def\FV@BVerbatimBegin{%
  \ht:special{t4ht@(}\begingroup%
    \let\a:fancyvrb\empty\IgnorePar%
    \FV@UseKeyValues%
    \FV@BeginVBox%
    \let\FV@ProcessLine\FV@BProcessLine%
    \FV@FormattingPrep%
    \FV@ObeyTabsInit\a:BVerbatimInput\ht:special{t4ht@)}
}%
\def\FV@BVerbatimEnd{\b:BVerbatimInput\ht:special{t4ht@(}\FV@EndVBox\ht:special{t4ht@)}\endgroup}
\def\FV@BProcessLine#1{\hbox{\FancyVerbFormatLine%
   {\c:BVerbatimInput#1\d:BVerbatimInput}}}
\NewConfigure{BVerbatimInput}{4}
\def\V@@footnotetext{%
\leavevmode%
   \vbox\bgroup%
      \leftskip0pt {\ht:everypar{}\parindent0pt\leavevmode}%
      \protected@edef
  \@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
\anc:lbl f{footnote}%
%
      \a:footnotetext%
      \b:footnotetext%
      \csname a:footnotebody\endcsname%
      \bgroup%
          \reset@font\footnotesize%
          \bgroup %
             \aftergroup\V@@@footnotetext %
             \ignorespaces%
}
\def\V@@@footnotetext{%
      \egroup%
      \csname b:footnotebody\endcsname%
      \c:footnotetext%
   \ht:special{t4ht@[}\egroup\ht:special{t4ht@]}%
}

   \NewConfigure{fancyvrb}{6}
\NewConfigure{fancyvrbcolor}{3}
\NewConfigure{fancyvrbframe}{6}

\Hinput{fancyvrb}
\endinput
gnull commented 6 months ago

Could you give me a hint on how to connect this to my build? Where do I put this file to ensure it's used instead of the one I have on my system and what should the build command look like?

michal-h21 commented 6 months ago

You can put it to the directory with your document, but a better way is to just update your TeX distribution, if you use TeX Live. This change is already incorporated in the distributed version of TeX4ht.

marekkolman commented 3 months ago

@michal-h21 I had the same issue. The solution works! The issue still does seem to exist even in the latest package. I'm using fancyvrb.4ht (2024-01-10-14:05), generated from tex4ht-4ht.tex and with this file, I'm getting the error.

michal-h21 commented 3 months ago

There is another version of fancyvrb.4ht in TeX Live, because I had to fix another issue that appeared later than this one. It seems that the fix for the other issue broke \mintinline again. Here is a new version that should work in all cases:

% fancyvrb.4ht (2024-03-27-09:27), generated from tex4ht-4ht.tex
% Copyright 1997-2009 Eitan M. Gurari
% Copyright 2009-2024 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 2024-03-27-09:27}

   \pend:def\FV@FormattingPrep{\let\fv:color\empty
  \ifx \color\:UnDef\else\Configure{color}{\xdef\fv:color}\fi
}
\append:def\FV@FormattingPrep{\a:fancyvrb%
   \ifx \FV@BeginListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \a:fancyvrbframe
\fi
\ifx \FV@LeftListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \b:fancyvrbframe
\fi
\ifx \FV@EndListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \c:fancyvrbframe
\fi
\ifx \FV@RightListFrame\relax\else
   \tmp:dim=\FV@FrameRule \edef\HSize{\the\tmp:dim}%
   \d:fancyvrbframe
\fi
%
   \bgroup
  \ifx \fv:color\empty \else{%
     \let\HColor\fv:color \a:fancyvrbcolor%
  }\fi
  \ifx \FancyVerbFillColor\relax \else%
     \:fvcolor \b:fancyvrbcolor \FancyVerbFillColor!*?: %
  \fi
  \ifx \FancyVerbRuleColor\relax \else%
     \:fvcolor \c:fancyvrbcolor \FancyVerbRuleColor!*?: %
  \fi
\egroup
\let\FV@BeginListFrame\relax
\let\FV@LeftListFrame\relax
\let\FV@RightListFrame\relax
\let\FV@EndListFrame\relax
%
}
\def\FV@ListProcessLine#1{%
    \hbox{\c:fancyvrb \anc:lbl r{FancyVerbLine}\FV@LeftListNumber%
      \FV@LeftListFrame \e:fancyvrb \FancyVerbFormatLine{#1}\f:fancyvrb%
      \FV@RightListFrame \csname FV@RightListNumber\endcsname %
          \d:fancyvrb}}
\def\FV@ListProcessLine@iii#1{%
  \box\@tempboxa
  \setbox\@tempboxa=\FV@ListProcessLine{#1}%
  \let\FV@ProcessLine\FV@ListProcessLine@iv}
\def\FV@ListProcessLine@iv#1{%
  % we use \nobreak to really prevent unwanted line breaks
  % see https://github.com/michal-h21/make4ht/issues/104
  \box\@tempboxa\nobreak%
  \setbox\@tempboxa=\FV@ListProcessLine{#1}}%
\def\FV@ListProcessLastLine{%
  \ifx\FV@ProcessLine\FV@ListProcessLine@iv
    \box\@tempboxa
  \else
    \ifx\FV@ProcessLine\FV@ListProcessLine@iii
      \box\@tempboxa
    \else
      \ifx\FV@ProcessLine\FV@ListProcessLine@i
        \FV@Error{Empty verbatim environment}{}%
        \FV@ProcessLine{}%
      \fi
    \fi
  \fi}

\def\FV@EndList{\FV@ListProcessLastLine  \FV@EndListFrame%
  \IgnorePar\b:fancyvrb\par\@endparenv%
  \endgroup   \@endpetrue}
\def\FV@StepLineNo{%
  \FV@SetLineNo%
  \def\FV@StepLineNo{\SkipRefstepAnchor\refstepcounter{FancyVerbLine}}%
  \FV@StepLineNo}
\def\:tempa#1{\let\sa:fancyvrb\a:fancyvrb\let\a:fancyvrb\empty\a:verb\o:FVC@Verb:{#1}\global\let\a:fancyvrb\sa:fancyvrb\aftergroup\b:verb}
\HLet\FVC@Verb\:tempa
\def\:tempa#1{\mbox{\FV@UseKeyValues%
   \let\a:fancyvrb\empty \FV@FormattingPrep%
   \a:verb #1\b:verb}}
\HLet\:tempa\FV@UseVerb
\def\:fvcolor#1{\def\a:color##1##2!*?: {%
   \Configure{SetHColor}#1{##1}}}%
\define@key{FV}{framerule}{%
  \@tempdima=#1\relax%
  \edef\FV@FrameRule{\number\@tempdima sp\relax}%
  {\Advance:\fancyvrbNo by 1   \tmp:dim=\FV@FrameRule%
   \edef\HSize{\the\tmp:dim}%
   \e:fancyvrbframe}}
\define@key{FV}{framesep}{%
  \@tempdima=#1\relax%
  \edef\FV@FrameSep{\number\@tempdima sp\relax}%
  {\Advance:\fancyvrbNo by 1    \tmp:dim=\FV@FrameSep%
   \edef\HSize{\the\tmp:dim}%
   \f:fancyvrbframe}}
\def\FV@BVerbatimBegin{%
  \ht:special{t4ht@(}\begingroup%
    \let\a:fancyvrb\empty\IgnorePar%
    \FV@UseKeyValues%
    \FV@BeginVBox%
    \let\FV@ProcessLine\FV@BProcessLine%
    \FV@FormattingPrep%
    \FV@ObeyTabsInit\a:BVerbatimInput\ht:special{t4ht@)}
}%
\def\FV@BVerbatimEnd{\b:BVerbatimInput\ht:special{t4ht@(}\FV@EndVBox\ht:special{t4ht@)}\endgroup}
\def\FV@BProcessLine#1{\hbox{\FancyVerbFormatLine%
   {\c:BVerbatimInput#1\d:BVerbatimInput}}}
\NewConfigure{BVerbatimInput}{4}
\def\V@@footnotetext{%
\leavevmode%
   \vbox\bgroup%
      \leftskip0pt {\ht:everypar{}\parindent0pt\leavevmode}%
      \protected@edef
  \@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
\anc:lbl f{footnote}%
%
      \a:footnotetext%
      \b:footnotetext%
      \csname a:footnotebody\endcsname%
      \bgroup%
          \reset@font\footnotesize%
          \bgroup %
             \aftergroup\V@@@footnotetext %
             \ignorespaces%
}
\def\V@@@footnotetext{%
      \egroup%
      \csname b:footnotebody\endcsname%
      \c:footnotetext%
   \ht:special{t4ht@[}\egroup\ht:special{t4ht@]}%
}

   \NewConfigure{fancyvrb}{6}
\NewConfigure{fancyvrbcolor}{3}
\NewConfigure{fancyvrbframe}{6}

\Hinput{fancyvrb}
\endinput