[tex4ht] Error with listings for R programs

Steven Dunbar sdunbar1 at unl.edu
Wed Jun 15 17:32:53 CEST 2016

I write lecture notes for my students including program listings in
the language R.  I want to process these with tex4ht to HTML with
MathJax to post on my class webpages.  The program listings use the
package "listing".

When processing with files (see below for example) with tex4ht, I get the following error:
! Missing } inserted.
<inserted text>
}
l.9 S <-
50

Answering with a "q" during each processing pass seems to ignore the
problem and produce a valid HTML file.  The error does not
occur when processing with pdflatex, and the pdf is fine.

I want to automate the processing.  Therefore, either fixing the problem
altogether (best!) or commanding tex4ht to run quietly without asking
(good enough!) would be a solution.

A minimal working example demonstrating the problem:
\documentclass[12pt]{article}
\usepackage{listings}           %for computer code fragments

\begin{document}

Some text that precedes the listing for $S = 50$ in R notation.

\begin{lstlisting}[language=R]
S <- 50
\end{lstlisting}

\end{document}

Command and Envrionment:
htlatex minworkexample.tex "~/ht5mathjax,xhtml,mathml" " -cunihtf" "-cvalidate"

I'm using TeX Live 2014 on a Fedora 23 installation.