2

I tried to get the below output for footnote in through TeX4HT

<p class="indent">Some Text<fn id="sample_fn_001" symbol="1"><p class="noindent">language has evolved gradually: as the need arose for actions beyond</p></fn> some text text</p>

I just tried to re-configure the footnote and footnote-mark

\newbox\footnotebox

\Configure{footnote-mark}{\Configure{textsuperscript}{}{}}{}



\Configure{footnotetext}{\global\setbox\footnotebox=\vtop\bgroup\NoFonts%
                         \ifvoid\footnotebox\else\unvbox\footnotebox\fi%
                         \IgnorePar\HCode{<fn id="\jobname_fn_00\thefootnote" symbol="\FNnum">}\par\ShowPar\IgnoreIndent%
                         \Configure{textsuperscript}{}{}%
                        }%
                        {\Configure{textsuperscript}{\HCode{<sup>}\bgroup}{\egroup\HCode{</sup>}}}%
                        {\ifvmode \IgnorePar\fi \EndP\HCode{</fn>}\egroup\box\footnotebox} 

i am getting the below output

<p class="noindent">Some Text1<a id="x1-1001f1"></a>    </p><fn id="sample_fn_001" symbol="1">   1language has evolved gradually: as the need arose for actions beyond</fn>                     
    some text text

in the footnote mark footnote number is printed in the footnote mark place and in the footnote? how to suppress the footnote number and Link ID <a id="x1-2f1"></a>

para also closing in the wrong place </p> before the <fn>

please suggest how to configure this to get the expected output

MWE

\documentclass{article}

\title{Sample TeX4HT}

\begin{document}
\maketitle

\section{A Head}\label{sec1}

Some Text\footnote{language has evolved gradually: as the need arose for actions beyond} some text text

\end{document}
2

Edit:

I've found a fix for the spurious <a> command. The next link destination for a cross-reference can be disabled using the \SkipRefstepAnchor command. The following configuration patches the \footnote command with that. Description of rest of the code follows in the original answer bellow the configuration file.

\Preamble{xhtml}

\makeatletter

% remove the footnote number in text
\Configure{footnotemark}{\setbox0=\vbox\bgroup}{\egroup}

% the <fnlabel> element is used to enclose the <a> element inserted by the referencing mechanism
% it will be then removed using Lua post-processing


\Configure{footnotetext}{%
\SaveEndP% don't print </p> in the next \EndP
\HCode{<fn id="\jobname_fn_00\thefootnote" symbol="\FNnum">}%
\IgnorePar% ignore next paragraph
\setbox0=\vbox\bgroup% remove the footnote number from footnote text
}%
{\egroup\par\IgnoreIndent\ShowPar}% start the paragraph in footnote
{\EndP% insert the closing </p>
\HCode{</fn>}\RecallEndP}% insert </p> in the next \EndP

\let\oldfootnote\footnote
\def\footnote{\SkipRefstepAnchor\oldfootnote}
\makeatother

\begin{document}
\EndPreamble

Original answer:

Your requested structure is invalid HTML, because <p> element cannot contain any block level element, including <p> itself. But if it doesn't matter to you, here is a solution:

\Preamble{xhtml}

\makeatletter

% remove the footnote number in text
\Configure{footnotemark}{\setbox0=\vbox\bgroup}{\egroup\HCode{<fnlabel>}}

% the <fnlabel> element is used to enclose the <a> element inserted by the referencing mechanism
% it will be then removed using Lua post-processing


\Configure{footnotetext}{%
\HCode{</fnlabel>}%
\SaveEndP% don't print </p> in the next \EndP
\HCode{<fn id="\jobname_fn_00\thefootnote" symbol="\FNnum">}%
\IgnorePar% ignore next paragraph
\setbox0=\vbox\bgroup% remove the footnote number from footnote text
}%
{\egroup\par\IgnoreIndent\ShowPar}% start the paragraph in footnote
{\EndP% insert the closing </p>
\HCode{</fn>}\RecallEndP}% insert </p> in the next \EndP

\begin{document}
\EndPreamble

The footnotemark configuration discards the footnote number inserted in the text. It uses a trick where we save the content into a temporary box, which is then discarded. The same trick is used also in the footnotetext configuration, to remove the footnote mark in the footnote itself.

The <a> element before footnote is inserted by the referencing mechanism and is quite hard to remove from the TeX side. This is the reason why it is enclosed in the <fnlabel> element. The result at this stage is following:

<!--l. 10--><p class="noindent" >Some Text<fnlabel><a 
 id="x1-1001f1"></a></fnlabel><fn id="sample_fn_001" symbol="1">
<!--l. 10--><p class="noindent" ><span 
class="cmr-8">language has evolved gradually: as the need arose for actions beyond</span></p></fn>
some text text
</p>

The <fnlabel> can be removed using a make4ht DOM filter. Save the following as mybuild.mk4:

local domfilter = require "make4ht-domfilter"

local process = domfilter {
  function(dom)
    for _, el in ipairs(dom:query_selector("fnlabel")) do
      el:remove_node()
    end
    return dom
  end
}


Make:match("html$", process)

It can be compiled using

make4ht -e mybuild.mk4 -c config.cfg filename.tex

This is the final result:

<!-- l. 10 --><p class='noindent'>Some Text<fn id='sample_fn_001' symbol='1'>
<!-- l. 10 --><p class='noindent'><span class='cmr-8'>language has evolved gradually: as the need arose for actions beyond</span></p></fn>
some text text
</p>

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.