# How may I test whether a document is being compiled by tex4ht? [duplicate]

Is there a way to programatically test whether the current document is being compiled by tex4ht?

What I am looking for is something like \iftexfourht, or perhaps some \@ifundefined{...}, in order to make \variable expand either to $#1$ or to \textit{#1} conditionally upon whether or not tex4ht is in charge.

\documentclass{article}

\newcommand \variable [1]
{%
\iftexfourht
\textit{#1}%
\else
$#1$%
\fi
}

\begin{document}

• \@ifundefined{HCode}{NO HT}{YES HT}, but I wouldn't rely on it; anybody can define anything, so someone can define \HCode even tex4ht is not active. – yo' Sep 3 '16 at 15:15