bugtex4ht - Bugs: bug #617, The fancyvrb LaTeX package...

 
 
Show feedback again

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

bug #617: The fancyvrb LaTeX package produces blank lines with the `\VerbatimInput` command

Submitted by:  Vít Starý Novotný <witiko>
Submitted on:  Mon Dec 11 16:36:17 2023  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

(Jump to the original submission Jump to the original submission)

Thu Jan 11 09:36:29 2024, comment #16:

Ah, so the mystery is solved :)

Thanks.

Michal Hoftich <michal_h21>
Project Member
Wed Jan 10 16:01:23 2024, comment #15:

That's because the syntax `\begin{markdown}[...] \end{markdown}` is new in Markdown 3. In Markdown 1 and 2, you would use the old example files that use `\begin{markdown}{...} \end{markdown}` instead.

Vít Starý Novotný <witiko>
Wed Jan 10 14:32:10 2024, comment #14:

Something needs to be wrong on my side. I've noticed, that even the hybrid option doesn't work with the markdown environment. Both with make4ht and LuaLaTeX. But, if I use the \markdownSetup command to make these options global, they work.

So the following example works, but not if I remove the \markdownSetup command:

%%%%%%%%%%%%%%%%%%%
\documentclass{book}
\usepackage{lmodern}
\usepackage{booktabs}
% Load the Markdown package and set its options.
\usepackage[
]{markdown}
\markdownSetup{
hybrid,html
}
\begin{document}

\begin{markdown}[hybrid]
hello \TeX, what's goind on?
\end{markdown}

\begin{markdown}[html,hybrid]
Here is some <b>HTML code</b> mixed with Markdown. In \TeX, the HTML code
will be silently ignored, whereas in \TeX 4ht, the HTML code will be passed
through to the output:

<table border="1">
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
\end{markdown}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%

Michal Hoftich <michal_h21>
Project Member
Wed Jan 10 12:28:12 2024, comment #13:

> I guess this version doesn't support inline HTML?


It does. I tried to reproduce your issue as follows:

$ # fetch the examples as they were in Markdown 2.23.0
$ git clone https://github.com/Witiko/markdown.git
$ cd markdown
$ git checkout 2.23.0
$ # typeset `latex-pdftex.pdf` with Markdown 2.23.0 from the current TeX Live
$ docker run -v "$PWD"/examples:/workdir -w /workdir --rm texlive/texlive:latest make latex-pdftex.pdf
$ grep 'markdown renderer' markdown/examples/latex-pdftex.log
Package: markdown 2023-04-27 v2.23.0-0-g0b22f91 markdown renderer

The last two paragraph in my document `latex-pdftex.pdf` that I typeset with Markdown 2.23.0 look the same as in the screenshot from my previous post using Markdown 3.3.0. In other words, I can't reproduce your issue.

Vít Starý Novotný <witiko>
Wed Jan 10 12:00:42 2024, comment #12:

I used the default installation of the Markdown package in my TeX Live, it says "Package: markdown 2023-04-27 v2.23.0-0-g0b22f91 markdown renderer", so it seems pretty old, but probably correct, as it is the same as the latest release on CTAN. I guess this version doesn't support inline HTML?

I've missed that the example is meant for PDFLaTeX, so I used LuaLaTeX, which led to the missing accented characters. They are here when I switch engines.

Michal Hoftich <michal_h21>
Project Member
Wed Jan 10 10:55:05 2024, comment #11:

Thank you for the bug report. Sadly, I can't reproduce your issue with the current version Markdown package. Here is what I did:

$ git clone https://github.com/Witiko/markdown.git
$ docker run -v "$PWD"/markdown/examples:/workdir -w /workdir --rm witiko/markdown make latex-pdftex.pdf
$ grep 'markdown renderer' markdown/examples/latex-pdftex.log
Package: markdown 2024-01-06 v3.3.0-20-g412f09b7 markdown renderer

See the attached screenshot that shows the last two paragraphs in my document `latex-pdftex.pdf`. Unlike your screenshot, my screenshot contains all the characters "ěščřžýáíé" and neither the verbatim text `\TeX` nor verbatim HTML tags. How did you create the document from your screenshot?

(file #532)

Vít Starý Novotný <witiko>
Wed Jan 10 10:29:29 2024, comment #10:

Yes, exactly. I see HTML tags in both PDF and HTML outputs.

(file #530, file #531)

Michal Hoftich <michal_h21>
Project Member
Wed Jan 10 09:44:11 2024, comment #9:

Do you mean the following snippet?

```
\begin{markdown}[html, hybrid]
Here is some <b>HTML code</b> mixed with Markdown. In \TeX, the HTML code
will be silently ignored, whereas in \TeX 4ht, the HTML code will be passed
through to the output:

<table border="1">
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
\end{markdown}
```

I don't see it inserted verbatim. Instead, I see a table, see the attached screenshot.

(file #529)

Vít Starý Novotný <witiko>
Wed Jan 10 08:58:32 2024, comment #8:

BTW is it OK that the last code snippet in the TeX file, which contains HTML tags, is inserted verbatim in the output? I thought that HTML tags should be passed to the HTML output without escaping.

Michal Hoftich <michal_h21>
Project Member
Wed Jan 10 08:44:10 2024, comment #7:

Yeah, it seems fine. I will update the TeX4ht sources then.

Michal Hoftich <michal_h21>
Project Member
Tue Jan 9 22:16:05 2024, comment #6:

Thanks. Your newly uploaded file fancyvrb.4ht seems to work fine, see also the attached screenshot of the output for the example document of the Markdown package.

(file #528)

Vít Starý Novotný <witiko>
Tue Jan 9 21:30:05 2024, comment #5:

Thanks for the report. I think this was caused by a fix for another issue: https://github.com/michal-h21/make4ht/issues/141

I've made a version of `\FVC@Verb` macro which works both with your example and with the code from the Minted issue. The reason why we need to disable \a:fancyvrb is that it causes discarding of all output that follows. This happens because we need to get rid of some spurious characters and spaces that would otherwise cause blank lines in HTML. So all of this is a bit hacky.

See the newly uploaded fancyvrb.4ht file. If it works fine, I will update TeX4ht sources.

(file #527)

Michal Hoftich <michal_h21>
Project Member
Tue Jan 9 20:13:24 2024, comment #4:

With the Docker image `texlive/texlive:latest` from the last Sunday, I am seeing the following errors [1] during the compilation of the example document for make4ht [2]:

$ make4ht --shell-escape latex-tex4ht.tex fn-in
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: latex-tex4ht.tex
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: /usr/local/texlive/2023/texmf-dist/tex/generic/tex4ht/fancyvrb.4ht 97 Illegal parameter number in definition of \FVC@Verb.
[ERROR] htlatex: /usr/local/texlive/2023/texmf-dist/tex/generic/tex4ht/fancyvrb.4ht 98 Illegal parameter number in definition of \FVC@Verb.
[ERROR] htlatex: /usr/local/texlive/2023/texmf-dist/tex/generic/tex4ht/fancyvrb.4ht 98 Illegal parameter number in definition of \FVC@Verb.

[1]: https://github.com/Witiko/markdown/actions/runs/7459249826/job/20294884745
[2]: https://github.com/Witiko/markdown/blob/main/examples/latex-pdftex.tex

I have not yet had the time to investigate the cause but it seems possibly related to the fix from this ticket.

Vít Starý Novotný <witiko>
Tue Dec 12 16:19:41 2023, comment #3:

Hi Vítek,

thanks for the confirmation. I've added this code to TeX4ht sources, so it should be available in TeX Live soon.

Michal Hoftich <michal_h21>
Project Member
Tue Dec 12 10:22:09 2023, comment #2:

Hi Michal,

thanks for the speedy response. Your workaround works for me.

Adding your config into a file `example.cfg` and running the commands `make4ht -c example.cfg example-01.tex` and `make4ht -c example.cfg example-02.tex` produces two HTML files with the following diff:

```
7,8c7,8
< <link href='example-01.css' rel='stylesheet' type='text/css' />
< <meta content='example-01.tex' name='src' />
---

> <link href='example-02.css' rel='stylesheet' type='text/css' />
> <meta content='example-02.tex' name='src' />

```

In other words, both the `Verbatim` LaTeX environment and the `\VerbatimInput` LaTeX command produce the same HTML output and it is the correct one:

```
<pre class='fancyvrb' id='fancyvrb1'><a id='x1-3r1'></a><span class='cmtt-10'>foo</span>
<a id='x1-5r2'></a><span class='cmtt-10'>bar</span>
<a id='x1-7r3'></a><span class='cmtt-10'>baz</span></pre>
```

From where I stand, your workaround seems as a good candidate for adding to the TeX4ht sources.

Vít Starý Novotný <witiko>
Mon Dec 11 21:48:03 2023, comment #1:

Hi Vítek,

thanks for the report. I am pretty sure that \VerbatimInput worked in the past, as I used it occasionally. I cannot find the place where spurious newlines come from, so we need to use a work around - insert special TeX4ht instructions to ignore characters and space. You can try this configuration file:

\Preamble{xhtml}
\catcode`\:=11
\Configure{fancyvrb}
{\IgnorePar \EndP \gHAdvance\fancyvrbNo by 1
\gHAssign\fancyvrb:cnt0
\HCode{<pre class="fancyvrb" id="fancyvrb\fancyvrbNo">}\ht:special{t4ht@[}}
{x\EndP\ht:special{t4ht@]}\HCode{</pre>}}
{\ht:special{t4ht@]}\gHAdvance\fancyvrb:cnt by 1
\ifnum \fancyvrb:cnt>1
\HCode{\Hnewline}\fi} {}
{}{\ht:special{t4ht@[}}
\catcode`\:=12
\begin{document}
\EndPreamble

It seems to work for both Verbatim environment and \VerbatimInput. If it works for you too, I will update TeX4ht sources.

Michal Hoftich <michal_h21>
Project Member
Mon Dec 11 16:36:17 2023, original submission:

I am having an issue with undesirable double-spacing with the `fancyvrb` LaTeX package and the TeX4ht typesetting system. Below, I outline the steps to reproduce the problem and show the expected and actual outcome.

### Steps to reproduce

I create the following LaTeX document in a file named `example-01.tex`:

```
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{hyperref}
\begin{document}
\begin{Verbatim}
foo
bar
baz
\end{Verbatim}
\end{document}
```

I also create the following LaTeX document in a file named `example-02.tex`:

```
\documentclass{article}
\begin{filecontents}[overwrite, nosearch, noheader]{example.foo}
foo
bar
baz
\end{filecontents}
\usepackage{fancyvrb}
\usepackage{hyperref}
\begin{document}
\VerbatimInput{example.foo}
\end{document}
```

Then, I typeset both documents in TeX4ht using the `make4ht example-01.tex` and `make4ht example-02.tex` commands.

### Expected outcome

Identical HTML documents in files `example-01.html` and `example-02.html` are produced and contain a code block with three lines of code.

### Actual outcome

Whereas the HTML document `example-01.html` contains a code block with three lines of code, the code block in the HTML document `example-02.html` contains an extra blank line after every line of code from the original LaTeX document and totals six lines of code.

To show the difference between the two documents, here is the output of the unix command `diff example-01.html example-02.html`:

```
7,8c7,8
< <link href='example-01.css' rel='stylesheet' type='text/css' />
< <meta content='example-01.tex' name='src' />
---

> <link href='example-02.css' rel='stylesheet' type='text/css' />
> <meta content='example-02.tex' name='src' />

10,12c10,16
< <pre class='fancyvrb' id='fancyvrb1'><a id='x1-3r1'></a><span class='cmtt-10'>foo</span>
< <a id='x1-5r2'></a><span class='cmtt-10'>bar</span>
< <a id='x1-7r3'></a><span class='cmtt-10'>baz</span></pre>
---

> <pre class='fancyvrb' id='fancyvrb1'>
> <a id='x1-3r1'></a><span class='cmtt-10'>foo</span>
>
> <a id='x1-5r2'></a><span class='cmtt-10'>bar</span>
>
> <a id='x1-7r3'></a><span class='cmtt-10'>baz</span>
> </pre>

```

### Discussion

It seems that the issue stems from the lack of support for the `\VerbatimInput` command in TeX4ht. However, the `\VerbatimCommand` is used to input verbatim text in the LaTeX definitions of the Markdown package for TeX and cannot be easily substituted with the `Verbatim` environment. A fix or a workaround would be appreciated.

Vít Starý Novotný <witiko>

 

Attached Files
file #532:  scrot.png added by witiko (38kB - image/png)
file #530:  markdown-html.png added by michal_h21 (37kB - image/png)
file #531:  markdown-pdf.png added by michal_h21 (74kB - image/png)
file #529:  scrot.png added by witiko (19kB - image/png)
file #528:  scrot.png added by witiko (134kB - image/png)
file #527:  fancyvrb.4ht added by michal_h21 (5kB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by michal_h21 (Posted a comment)
  • -unavailable- added by witiko (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):

     

     

    6 latest changes follow.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed Jan 10 10:55:05 2024witikoAttached File-=>Added scrot.png, #532
    Wed Jan 10 10:29:29 2024michal_h21Attached File-=>Added markdown-html.png, #530
      Attached File-=>Added markdown-pdf.png, #531
    Wed Jan 10 09:44:11 2024witikoAttached File-=>Added scrot.png, #529
    Tue Jan 9 22:16:05 2024witikoAttached File-=>Added scrot.png, #528
    Tue Jan 9 21:30:04 2024michal_h21Attached File-=>Added fancyvrb.4ht, #527
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray