66.13 color.sty

Was ‘\def\color@setgroup{\begingroup \ht:special {color push \current@color }% \aftergroup \reset@color }’ indirectly through \set@color. It caused an extra leading line for verbatim environments. As a side comment, the \aftergroup might cause an ordering problem, if html code is attached to it.

<..color.4ht..>
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % color.4ht                             2014-07-12-22:36 %
 % Copyright (C) 1997--2009       Eitan M. Gurari         %
 <.TeX4ht copyright.>
 \expandafter\ifx \csname color:def\endcsname\relax
     \let\color:def\def
 \else  \expandafter\endinput\fi
 \let\:temp=\begingroup
 \HLet\color@setgroup=\:temp
 <.def HColor.>
 \NewConfigure{color}{1}
 \def\:tempc#1#2#3{\protect\leavevmode{\protect\a:textcolor
       \color#1{#2}#3\protect\b:textcolor}}
 \HLet\@textcolor=\:tempc
 \NewConfigure{textcolor}{2}
    <.fix color.>
 <.boxes of color.>
 \Hinput{color}
 \endinput
 -_-_-

<..def HColor..>
 \def\HColor{\:warning{\string\Hcode{...}{...} is deprecated; Use
    \string\Configure{HColor}{...}{...}}\Configure{HColor}}
 \NewConfigure{HColor}[2]{\if !#1!<.internal HColor.>\else
    \expandafter\edef\csname CLR:#1\endcsname{#2}\fi}
 -_-_-
 
 \def\:temp#1#2{%
    \let\a:fcol=\empty   \let\b:fcol=\empty
    \color@b@x\relax{\color#1{#2}}}
 \HLet\color@box=\:temp
 \def\:temp#1#2#3{%
    \let\a:fcol=\a:fcolorbox   \let\b:fcol=\b:fcolorbox
    \color@b@x{\fboxsep\z@\color#1{#2}\fbox}{\color#1{#3}}}
 \HLet\color@fbox=\:temp
 \long\def\:temp#1#2#3{%
    \def\:temp{#1}\def\:tempa{\relax}\ifx\:temp\:tempa\else\leavevmode\fi
    {\a:fcol #1{\ifcolors@ \a:colorbox\fi \leavevmode #2%
       {\set@color#3}\ifcolors@ \b:colorbox\fi}}\b:fcol}
 \HLet\color@b@x=\:temp -_-_-

<..boxes of color..>
 \long\def\:temp#1#2#3{%
    \ifcolors@
       \def\:temp{#1}\def\:tempa{\relax}\ifx\:temp\:tempa
       \a:colorbox \else \a:fcolorbox \fi
    \fi
    {#1{\leavevmode #2{\set@color#3}}}%
    \ifcolors@
       \def\:temp{#1}\def\:tempa{\relax}\ifx\:temp\:tempa
       \b:colorbox \else \b:fcolorbox \fi
    \fi
 }
 \HLet\color@b@x\:temp
 \NewConfigure{colorbox}{2}
 \NewConfigure{fcolorbox}{2}
 -_-_-

<..fix color..>
 \def\pagecolor{%
   \begingroup \a:pagecolor
       \let\ignorespaces\endgroup
       \let\set@color\set@page@color
       \color}
 \NewConfigure{pagecolor}{1}
 -_-_-

<..fix color..>+
 \def\@undeclaredcolor[#1]#2{\a:color{#1 #2}%
   \@ifundefined{color@#1}%
     {\@latex@error{Undefined color model ‘#1’}\@ehd}%
     {\csname color@#1\endcsname\current@color{#2}%
      \set@color}%
   \ignorespaces}
 \pend:defI\@declaredcolor{\a:color{##1}}
 -_-_-

<..fix color..>+
 \NewConfigure{SetHColor}[2]{{%
    \expandafter\let\expandafter\:temp \csname CLR:#2\endcsname
    \ifx \:temp\relax
       \edef\:temp{#2 //}\expandafter\get:HColor\:temp
       \ifx \HColor\relax
           <.xcolor SetHColor.>%
       \fi
    \else             \let\HColor=\:temp \fi
    \ifx \HColor\relax
       \:warning{missing \string\Configure{HColor}{#2}{...}
            (in LaTeX: \csname\string\color @#2\endcsname)}%
       \expandafter\global\expandafter\let\csname CLR:#2\endcsname=\empty
     \else #1\fi }}
 -_-_-

The first argument to SetHColor above is the XML code to be added for the color, with the color itself referenced by \HColor. The second argument is the same color name as provided to \color of color.sty. That is, the configuration is employed in the following manner.

   \Configure{SetHColor} 
        {#1: XML code for color provided in \HColor} 
        {#2: latex color name} 

The SetHColor typically is requsted indirectly in the following manner

             \a:color{latex color name} 

Where \a:color is similar to.

\Configure{color} 
  {\Configure{SetHColor} 
        {...XML code for color provided in \HColor...}% 
  } 

The \get:HColor does the job of looking for XML color value, and it assignes that value to \HColor.

<..fix color..>+
 \def\get:HColor#1 #2//{%
   \expandafter\ifx \csname HColor:#1\endcsname\relax
      \let\HColor=\relax
      <.color from def.>%
   \else
      \csname HColor:#1\endcsname #2//%
   \fi
 }
 \def\c:HColor:gray:{\def\HColor:gray##1 ##2//}
 \Configure{HColor:gray}{\Configure{HColor}{}{}}
 \def\c:HColor:rgb:{\def\HColor:rgb##1,##2,##3 ##4//}
 \Configure{HColor:rgb}{\Configure{HColor}{}{}}
 \def\c:HColor:cmyk:{\def\HColor:cmyk##1,##2,##3,##4 ##5//}
 \Configure{HColor:cmyk}{\Configure{HColor}{}{}}
 -_-_-

<..color from def..>
 \expandafter\ifx \csname\string\color @#1\endcsname \relax\else
    \expandafter\ifx \csname colortyp:\endcsname\relax \else
       \csname colortyp:\expandafter\expandafter\expandafter\endcsname
          \csname\string\color @#1\expandafter\endcsname
          \space . //%
 \fi \fi
 -_-_-

<..internal HColor..>
 \if!#2!\let\HColor=\relax \else \edef\HColor{#2}\fi
 -_-_-

<..def HColor..>+
 \def\:temp#1#2#3{%
   \@ifundefined{color@#2}%
     {\c@lor@error{model ‘#2’}}%
     {\@ifundefined{\string\color @#1}{}%
       {\PackageInfo{color}{Redefining color #1}}%
      \csname color@#2\expandafter\endcsname
          \csname\string\color @#1\endcsname{#3}}}
 \ifx \definecolor\:temp
    \pend:defIII\definecolor{%
      \expandafter\ifx\csname HColor:##2\endcsname\relax\else
         \csname HColor:##2\endcsname ##3 //%
         \edef\:temp{{HColor}{##1}{\HColor}}%
         \expandafter\Configure\:temp
      \fi}
 \fi
 -_-_-

The \color{red} instruction might be problematic since it does not on its own determine the extent of the text to be colored. As a result, its effect can cross logical boundaries. That is against the philosophy of markup languages in general and of XML in particular.

It is possible to implement the \color{...} feature but I’m not sure it is desirable to do so. I think it is preferable to expect users to use commands of the form \textcolor{red}{...} for code fragments.