如何將 xmlns 新增至 tex4ht 中的標籤

如何將 xmlns 新增至 tex4ht 中的標籤

根據亞馬遜的 Kindle 出版指南,我需要添加xmlns:mbp="http://www.kreutzfeldt.de/mmc/mbp"<html>我的 html 檔案中的標籤。

我嘗試了以下多種變體:

\documentclass{article}
  \input{tex4ht.sty}
  \Preamble{xhtml}
\begin{document}
    \Configure{PROLOG}{HTML+,HTML,@HTML}
%    \Configure{HTML+}{\HCode{plus-html test}}
%    \Configure{@HTML}{\HCode{at-html test}}
%    \Configure{HTML}{\HCode{naked-html test}}
    \Configure{*XML-STYLESHEET}{\HCode{xmlss test}}
    \Configure{@HEAD}{\HCode{head test} }
    \HCode{<meta name="parameter" content="content">}
    \Configure{TITLE+}{This is my title}
  \EndPreamble

Content
\end{document}

其中大多數都成功地在該<head>部分中插入了一些內容,但沒有任何內容進入<html>標籤。 \Configure{PROLOG}似乎沒有多大區別(如果有的話)。當我不註解掉該\Configure{HTML}行時,我收到錯誤:

! Argument of \Configure has an extra }.
<inserted text> 
                \par 
l.16 \end{document}

顯然,我可以手動插入它,但 tex4ht 似乎是為了執行此操作而設定的。 <rant>在 tex4ht 的所有記錄不足的功能中,與 相關的功能\Configure{PROLOG}似乎是我迄今為止遇到的最糟糕的功能。</rant>

答案1

\Configure{HTML}有兩個參數,而您的範例中只有一個參數,因此這可能是錯誤的根源。請注意,可以\Configure{@HTML}將程式碼插入<html ...>.xml:lang預設會插入正確的語言代碼,因此您需要自己提供。最後,您不需要使用\Configure{PROLOG}.

簡單.cfg文件:

\Preamble{xhtml}
\Configure{@HTML}{xml:lang="en" xmlns:mbp="http://www.kreutzfeldt.de/mmc/mbp" \Hnewline}
\begin{document}
\EndPreamble

結果是:

<html xml:lang="cs" xml:lang="en" xmlns:mbp="http://www.kreutzfeldt.de/mmc/mbp"
xmlns="http://www.w3.org/1999/xhtml"
> 

答案2

這些\Configure語句應該放在前面,\begin{document}以便tex4ht正確處理它們,例如:

\documentclass{article}
\input{tex4ht.sty}
\Preamble{xhtml}
\Configure{HTML}
  {\HCode{<html xmlns="http://www.w3.org/1999/xhtml" xmlns:mbp="http://www.kreutzfeldt.de/mmc/mbp">}}
  {\HCode{</html>}}
\Configure{@HEAD}{\HCode{<meta name="parameter" content="content">}}
\Configure{TITLE+}{This is my title}

\begin{document}
  \EndPreamble
  Content
\end{document}

相關內容