更新 itemize 环境以便在 tex4ht 中进行定制

更新 itemize 环境以便在 tex4ht 中进行定制

htlatex编译的文档中,标准枚举列表环境显示为<li class="itemize">标签。

对于 pdf 版本,我已经加载了enumitem包来帮助列表自定义,但我很确定这不会有太大帮助(我认为这可能相关,因为以下自定义没有任何效果)。

  • \setlist[itemize,]{label=$-$}
  • \setlist[itemize]{itemsep=0mm}
  • \renewcommand{\labelitemi}{$-$}

因为我只想要一个 ~ 空格和一个像连字符这样的符号,因为这是一个纯文本文档,而不是 html 文档

我想

  1. 删除引入的 itemize 标签并打印出我手动生成的格式

  2. 自定义 html 文件如何处理分项输出

因此,我不确定这两种情况是否有可能,但各自的可能性可能是:

  1. 重建 itemize 环境,以便 tex 编译器可以处理所需的文本,或者
  2. htlatex使用作为命令行参数接收的 自定义配置文件中的 css 指令重新编程格式化显示。

如果我能得到关于这两种方法中的哪一种更htlatex适合的指导,我将设计并发布一个 MWE,并尝试重新定义或定制列表环境。

更新

CFG 文件尝试适应 tex4ht 编译端的列表格式修改:

\Preamble{xhtml}
\Configure{@HEAD}{\HCode{<script type="text/javascript" src="underlinesec.js"></script>\Hnewline}}
\ConfigureList{itemize}{\HCode{\Hnewline}}{\HCode{\Hnewline}}{\setbox0=\hbox\bgroup}{\egroup\HCode{\Hnewline}  - }
\begin{document}
\def\sechead#1#2{.#1Head #2,.like#1Head #2}
\def\sections#1{\sechead{section}{#1}, \sechead{section}{#1}, \sechead{subsection}{#1}, \sechead{subsubsection}{#1}}
\Css{\sections{}{color:black;}}
\Css{\sections{br}{display:none;}}
\Css{\sections{.titlemark}{color:green;}}
\Css{\sections{.titlemark:after}{content:" ";}}
\Css{\sechead{section}{.titlemark}{display:none;}}
\Css{\sechead{section}{}{font-weight:normal;font-size: 100\%;text-align:left;text-transform: uppercase;}}
\Css{body{background-color:white;}}
\Css{body{font-family: 'Lucida Console', sans-serif;}}
\EndPreamble

这个配置文件让我成功了一半,我得到了纯文本列表项,但我没有得到预期的新行,\HCode{\Hnewline}这些行也不是文件的可访问部分。复制文本并将其粘贴到记事本中不会保留这些新行。

理想情况下,段落和列表开头之间不会有换行符(可以换行,但不能有空行)。我以为我可以通过让参数 #2 和 #3 留空来实现这一点,但我在 html 源代码中得到了一组无标签的换行符

class="newline" />last line of text before the list</p>



     <br/>-&#x00A0;

答案1

列表使用 进行配置\ConfigureList{listname}{start tag}{end tag}{item label start}{item label end}。示例配置可能如下所示:

\ConfigureList{itemize}{\HCode{<br />\Hnewline}}{\HCode{<br />\Hnewline}}{\DeleteMark}{\HCode{<br />\Hnewline} -}

\HCode{<br />\Hnewline}插入换行符,有趣的部分是{\DeleteMark}{\HCode{\Hnewline} -}- 它丢弃项目符号项,换行并打印-

为了获得完整的配置文件,我们可以使用我的 Wiki 标记示例配置

\Preamble{xhtml}


\ConfigureList{itemize}{\HCode{<br />\Hnewline}}{\HCode{<br />\Hnewline}}{\DeleteMark}{\HCode{<br />\Hnewline} -} 

% remove html structure
\Configure{HTML}{}{}
\Configure{@HEAD}{}
\Configure{BODY}{}{}
\Configure{DOCTYPE}{}
\Configure{HEAD}{}{}
\Configure{TITLE}{}{}
\Configure{VERSION}{}

\newcommand\starttag[1]{\NoFonts\HCode{#1}}
\newcommand\stoptag[1]{\NoFonts\HCode{#1}}
\newcommand\ConfigureInlinetag[2]{%
  \Configure{#1}{\starttag{#2}}{\stoptag{#2}}%
}

\ConfigureInlinetag{textit}{''}
\ConfigureInlinetag{textbf}{'''}

\newcommand\ConfigureSection[2]{%
  \Configure{#1}{}{}{\starttag{#2}}{\stoptag{#2\Hnewline}}%
}

\ConfigureSection{section}{==}
\ConfigureSection{likesection}{==}
\ConfigureSection{subsection}{===}
\ConfigureSection{likesubsection}{===}

% remove section id
\def\gobbleone#1#2{}
\Configure{toTocLink}{\gobbleone}{}

% remove <p> elements
\Configure{HtmlPar}{}{}{\HCode{\Hnewline}}{\HCode{\Hnewline}}

% \DeclareFieldFormat[article]{entrytype}{Cite journal}
% \DeclareFieldFormat*{titlecite}{{title=#1}}%
% \DeclareFieldFormat*{yearcite}{{year={#1}}}%
% \DeclareNameFormat*{labelname}{\ifthenelse{\value{listcount}=1}{#1}{}}
% \DeclareCiteCommand{\cite}%
%   {\printnames{labelname}\HCode{<ref>}\{\{}%
%   {%
%   \printfield{entrytype}
%   \setunit{|}%
%   \printtext{author=}%
%   \printnames{author}%
%   \setunit{|}%
%   \printfield[titlecite]{title}%
%   \setunit{|}%
%   \printfield[yearcite]{year}%
%   }%
%   {}%
%   {\}\}\HCode{</ref>}}%

\begin{document}

\EndPreamble

示例文件:

\documentclass{article}

\begin{document}
\section{hello}

\begin{itemize}

  \item first item

  \item second \textit{item}

  \item some longer snippet of text. We hope that it may break the line
    somewhere. So it should be longer than it is currently. How about this? It might be enough.

\end{itemize}

\end{document}

转换为:

   ==hello== 





 -first item

 -second ''item''

  -some  longer  snippet  of  text.  We  hope  that  it  may  break  the  line
     somewhere. So it should be longer than it is currently. How about this? It
     might be enough.

有很多空白,但我想这应该不是问题。\Hnewlines如果您愿意,可以删除一些。

相关内容