2

I wish to have cleaner html code from tex4ht, but I am not able to see, form the code from the file, why there are carriage returns in the html code

this is the code for tabular. I added several HCode{\Hnewline}, in order to have a better view:

\Configure{tabular}
      {\ifvmode \IgnorePar\fi \EndP \halignTB{tabular}\putVBorder }
      {\HCode{</table>}\HCode{\Hnewline}}
      {\HCode{<tr \Hnewline}\halignTR
                            \HCode{ id="TBL-\TableNo-\HRow-">}\HCode{\Hnewline}}
      {\r:HA\HCode{\Hnewline}}
      {\HCode{\Hnewline}\HCode{<td \ifnum \HMultispan>1 colspan="\HMultispan"\fi}%
         \halignTD \HCode{ id="TBL-\TableNo-\HRow-\HCol"
         \Hnewline class="td}\NoFonts
           \bgroup
              \ifx \ttfamily\:UnDef \else \ttfamily\fi
              \ColMargins
           \egroup
\EndNoFonts 

for instance, a table like this

\begin{tabular} {c c}
AAA & QQQ  \tabularnewline
WWW & SSS
\end{tabular}

produces something ugly with breakings of line everywhere:

<div class="tabular"><table id="TBL-1" class="tabular" 
cellspacing="0" cellpadding="0"  
><colgroup id="TBL-1-1g"><col 
id="TBL-1-1" /><col 
id="TBL-1-2" /></colgroup><tr  
 style="vertical-align:baseline;" id="TBL-1-1-"> 

<td  style="white-space:nowrap; text-align:center;" id="TBL-1-1-1"  
class="td11"> <span 
class="cmr-12">AAA </span></td> 
<td  style="white-space:nowrap; text-align:center;" id="TBL-1-1-2"  
class="td11"> <span 
class="cmr-12">QQQ  </span></td>
</tr> 
<tr  
 style="vertical-align:baseline;" id="TBL-1-2-"> 

<td  style="white-space:nowrap; text-align:center;" id="TBL-1-2-1"  
class="td11"> <span 
class="cmr-12">WWW </span></td> 
<td  style="white-space:nowrap; text-align:center;" id="TBL-1-2-2"  
class="td11">  <span 
class="cmr-12">SSS   </span></td>
</tr> 
</table> 

</div>

is it possible to have something nicer in avoiding the carriage returns, for instance at the beginning:

<div class="tabular"><table id="TBL-1" class="tabular"  cellspacing="0" cellpadding="0">
<colgroup id="TBL-1-1g">
<col id="TBL-1-1" /><col id="TBL-1-2" /></colgroup>
<tr  style="vertical-align:baseline;" id="TBL-1-1-"> 

which means keeping as many environment < XXX>, like <table id="TBL-1", .....> on one line, with each new beginning/closing of an environment appearing on a new line ?

1

You insert lots of newlines in your configuration with \HCode{\Hnewline}. Just put them only in places where you really want them:

\Preamble{xhtml}
\Configure{tabular}
      {\ifvmode \IgnorePar\fi \EndP \halignTB{tabular}\putVBorder }
      {\HCode{\Hnewline</table>}}
      {\HCode{\Hnewline<tr }\halignTR    \HCode{ id="TBL-\TableNo-\HRow-">}\HCode{}}
      {\HCode{</tr>}}
      {\HCode{}\HCode{<td \ifnum \HMultispan>1 colspan="\HMultispan"\fi}%
         \halignTD \HCode{ id="TBL-\TableNo-\HRow-\HCol"
         class="td}\NoFonts
           \bgroup
              \ifx \ttfamily\:UnDef \else \ttfamily\fi
              \ColMargins
           \egroup
\EndNoFonts \HCode{">}}{\HCode{</td>}}
\begin{document}

\EndPreamble

produces:

<div class="tabular"> <table id="TBL-1" class="tabular" 
cellspacing="0" cellpadding="0"  
><colgroup id="TBL-1-1g"><col 
id="TBL-1-1" /><col 
id="TBL-1-2" /></colgroup> 
<tr  style="vertical-align:baseline;" id="TBL-1-1-"><td  style="white-space:nowrap; text-align:center;" id="TBL-1-1-1" class="td11"> AAA </td><td  style="white-space:nowrap; text-align:center;" id="TBL-1-1-2" class="td11">QQQ</td></tr> 
<tr  style="vertical-align:baseline;" id="TBL-1-2-"><td  style="white-space:nowrap; text-align:center;" id="TBL-1-2-1" class="td11">WWW</td> <td  style="white-space:nowrap; text-align:center;" id="TBL-1-2-2" class="td11"> SSS</td> </tr> 
</table>
</div>  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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