我希望 tex4ht 中有更清晰的 html 代码,但是我无法从文件代码中看到为什么 html 代码中有回车符
这是 的代码。为了看得更清楚,tabular
我添加了几个:HCode{\Hnewline}
\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
例如这样的表格
\begin{tabular} {c c}
AAA & QQQ \tabularnewline
WWW & SSS
\end{tabular}
会产生一些丑陋的东西,到处都是断线:
<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>
是否有可能有一些更好的方法来避免回车,例如在开始时:
<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-">
这意味着保留尽可能多的环境< XXX>
,比如<table id="TBL-1", .....>
在一行上,每个新的环境的开始/结束都出现在新行上?
答案1
你可以在配置中用 插入大量换行符\HCode{\Hnewline}
。只需将它们放在你真正需要的位置即可:
\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
生成:
<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>