不需要的 para 标签 `` 出现在 tex4ht 中的部分末尾

不需要的 para 标签 `` 出现在 tex4ht 中的部分末尾

我正在尝试更改\Configure{section}自定义标签<div><title>

我正在使用以下 tex 编码

\documentclass{book}
\usepackage{amsmath}
%\usepackage{macros}

\newenvironment{exe}{Exercise: }{}

    \begin{document}
    \section{sample}
    This version uses the powerful Uniscribe library in order to better handle Unicode and complex language processing (including support for bidirectional text).

    This version uses the powerful Uniscribe library in order to better handle Unicode and complex language processing (including support for bidirectional text).
    \end{document}

在 cfg 文件中我做了如下修改

\Configure{section}
    {\ifvmode \IgnorePar\fi \EndP\IgnorePar%
    \HCode{<section class="section\thesection"\a:LRdir>}\TitleMark}
    {\EndP\HCode{</section>}}
    {\HCode{<title>}}
    {\HCode{</title>}\HtmlParOn\ShowPar \IgnoreIndent \par}

当 tex 文件只有一个部分时,我得到了正确的输出,如下所示

<section class="section0.1"><label>0.1</label><title><a id="x1-10000.1"></a>sample</title>
<p class="noindent">This version uses the powerful Uniscribe library in order to better handle Unicode and complex language processing (including support for bidirectional text).</p>
<p class="indent">This version uses the powerful Uniscribe library in order to better handle Unicode and complex language processing (including support for bidirectional text).</p>
</section>

当我们在 .tex 文件中添加另一个部分时,额外的内容<p>会出现在该部分之前,如下所示

<section class="section0.1"><label>0.1</label><title><a id="x1-10000.1"></a>sample</title>
<p class="noindent" >This version uses.</p>
<p class="indent" >   This version uses the text).</p>
<p class="noindent" ></p>
<p class="indent" > 
</section>
</p>
<section class="section0.2"><label>0.2</label><title><a id="x1-20000.2"></a>sample</title>
<p class="noindent" >This version uses.</p>
<p class="indent" >   This version uses the text).</p>
</section>

如何抑制<p> ... </p>HTML 中的多余标签?

答案1

大多数错误的段落实例可以\ifvmode\IgnorePar\fi\EndP在有问题的标签前使用来修复:

\Configure{section}
{\ifvmode \IgnorePar\fi \EndP\IgnorePar%
\HCode{<section class="section\thesection"\a:LRdir>}\TitleMark}
{\ifvmode\IgnorePar\fi\EndP\HCode{</section>}}
{\HCode{<title>}}
{\HCode{</title>}\HtmlParOn\ShowPar \IgnoreIndent \par}

它产生以下结果:

 <section class="section0.1"><span class="titlemark">0.1   </span><title><a 
 id="x1-10000.1"></a>sample</title>
<p class="noindent">This version uses the powerful Uniscribe library in order to better handle
Unicode and complex language processing (including support for bidirectional
text).
</p><p class="indent">   This version uses the powerful Uniscribe library in order to better handle
Unicode and complex language processing (including support for bidirectional
text).
</p>
   </section> 
<section class="section0.2"><span class="titlemark">0.2   </span><title><a 
 id="x1-20000.2"></a>another section</title>
<p class="noindent">some text </p></section> 

相关内容