bdtc / lwarp

The LaTeX lwarp package — Convert LaTeX to HTML.
https://ctan.org/pkg/lwarp
31 stars 0 forks source link

Line indentation is inconsistent within the verse environment when \flagverse is used with text formatting #28

Open helkaluin opened 1 month ago

helkaluin commented 1 month ago

One common use case of the \flagverse command of the verse package is to print verse numbers. With LuaLaTeX, the following output is achieved in PDF (with \vleftskip set to 0.5em, and the \flagverse formatted with \textsuperscript):

image

However, when compiled with lwarp, the following appears (with \HTMLvleftskip also set to 0.5em):

image

This should not happen. The "body text" of the verse lines should all align on the left on the same vertical line. I think this might be because lwarp translates the verse environment into a <pre> environment in HTML, which preserves whitespace, and the HTML it generates looks like this:

image

As you can see, the <sup> (and indeed things like italics and bold as well) gets ignored in the white-space counting, resulting in the inconsistent spacing. Is there a way for the HTML generated to not have this "hanging indentation"? I've included below a minimal working example.

=============================

\documentclass{book}
\usepackage{lwarp}
\usepackage{verse}
\setlength{\vleftskip}{0.5em}
\setlength{\HTMLvleftskip}{0.5em}

\begin{document}
  \begin{verse}
  A reading from the book of the prophet Isaiah.

  \flagverse{\textit{1}} The word that Isaiah son of Amoz saw concerning\\
  Judah and Jerusalem.

  \flagverse{\textsuperscript{2}} In days to come\\
  the mountain of the LORD's house\\
  shall be established as the highest of the mountains,\\
  and shall be raised above the hills;\\
  all the nations shall stream to it.
  \end{verse}
\end{document}
bdtc commented 1 month ago

Yes, the entire use of PRE for verse and listings and such can be a problem when things are formatted. It may be possible to use some other system for verse especially, since PRE is usually monospace text which is not very nice for verse. This would be something to investigate some day, but it'll be a while. Busy at the moment.

In the meantime you could try an HTML-only definition of \flagverse without the formatting.