Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm running MiKTeX under Windows 7, trying to compile some LaTeX to HTML using htlatex.

htlatex appears to be converting every instance of 'ff' and 'fi' with a NUL byte in the HTML. Was wondering if anybody had any insight!

Here's the config file I'm using (some stuff I got on the internet that is probably the whole problem):

\Preamble{xhtml}
\Configure{HtmlPar}
{\EndP\Tg<p>}
{\EndP\Tg<p>}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}}
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}}{\HCode{</b>}}
\begin{document}
\EndPreamble

And here is an example tex file that illustrates my problem:

\documentclass{article}

\begin{document}

\section{Letters}
\subsection{Valid Letters}
AA Aa aA aa\\
BB Bb bB bb\\
CD Cd cD cd\\
\subsection{Invalid Letters}
FF Ff fF ff\\
FI Fi fI fi\\

\section{Strings}
a string of text\\
a fine string of text\\
a definition of an efficient and fine string of text\\
finally, the problem is solved!\\

\end{document}

And here is output I get after running the the command

htlatex example.tex MyFonts.cfg "xhtml, NoFonts, -css" -utf8 -shell-escape

1 Letters

1.1 Valid Letters

AA Aa aA aa
BB Bb bB bb
CD Cd cD cd

1.2 Invalid Letters

FF Ff fF
FI Fi fI

2 Strings

a string of text
a ne string of text
a denition of an ecient and ne string of text

nally, the problem is solved!

If I look in the HTML output, all occurences of 'ff' and 'fi' have been replaced by the NUL character. Does anybody know why?

Thanks!

share|improve this question
1  
I saved the first snippet as MyFonts.cfg, but NoFonts gives error; if I remove it, I get errors because of -utf8 and -shell-escape. –  egreg Feb 27 at 0:15
    
The error seems to be caused by the -css argument... but why? Also, you can replicate the error (or I can) with just the following command htlatex minimal.tex MyFonts.cfg "xhtml, -css" –  Robert Kelly Feb 27 at 0:20
    
With that command line I get, for instance, a fine string of text in the .html file. –  egreg Feb 27 at 0:22
    
hm. For some reason the -css is killing it for me. –  Robert Kelly Feb 27 at 0:31

1 Answer 1

up vote 3 down vote accepted

You compile it in a wrong way.

Correct compiling order is:

htlatex filename "tex4ht.sty opt" "tex4ht command opt" "t4ht command opt" "latex opt"

in your case this means this command:

htlatex filename "MyFonts, NoFonts, -css" " -utf8" "" -shell-escape

this generates fine html for me.

some further notes:

you request -utf8 option for tex4ht command, but you doesn't provide option for unicode fonts -cunihtf or -cmozhtf, so generated html is in latin-1 encoding. correct compile sequence for unicode is:

htlatex filename "MyFonts,  NoFonts, -css, charset=utf-8" " -utf8 -cunihtf" "" -shell-escape

note that in this case ligatures are transformed to unicode characters, which maybe isn't what you want. you can simplify the process with my make4ht tool:

you can move options for tex4ht.sty to the cfg file:

\Preamble{xhtml,NoFonts, -css}

so you don't need to specify them on the command line. Now you can simply call:

make4ht -u -c MyFonts -s filename 

also note that NoFonts option may be dangerous - if you add to your tex file:

\textbf{příliš} \emph{žluťoučký} \textit{ďábelské}

and

\usepackage[utf8]{inputenc}

generated html looks like:

<b>Hello příliš</b> <em>žluťoučký</em> ďábelské 

you can see that there are html tags for \textbf and \emph, because you provided configuration for these commands, but \textit doesn't produce any markup. If you remove NoFonts option, due to bug in tex4ht command, lot of unnecessary elements around accented characters are produced, which is probably reason why you use NoFonts. To fix this issue, you can configure \textbf and \emph to turn html fonts off:

\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}\NoFonts}{\EndNoFonts\HCode{</em>}}
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}\NoFonts}{\EndNoFonts\HCode{</b>}}

but if you don't want to provide such configurations for all font changing commands, you can use make4ht filters. create make file filename.mk4:

local filter = require "make4ht-filter"
local process = filter{"cleanspan", "fixligatures", "hruletohr"}
Make:htlatex()
Make:htlatex()
Make:match("html$",process)

three filters are used in this sample:

  • cleanspan removes spurious span elements around accented letters
  • fixligatures replaces ligatures with base characters
  • hruletohr replaces series of ----- characters with <hr /> element

if you remove the NoFonts option, generated html is now:

<b>příliš</b> <em>žluťoučký</em> <span class="cmti-10">ďábelské </span>

so even if \textit doesn't produce semantically meaningful code, the text is italicized thanks of css.

share|improve this answer
    
Thanks! Very informative and helpful answer –  Robert Kelly Feb 27 at 22:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.