LaTeX

The engines of footnotes are

\def\@footnotemark{...\@makefnmark...} 
\long\def\@footnotetext#1{...\@makefntext{#1}...} 

with the index suplied to both places in \@thefnmark. We set the following hooks.

\def\@footnotemark{...\a:@makefnmark\@makefnmark 
                                           \b:@makefnmark...} 
\long\def\@footnotetext#1{...\a:@makefntext 
                \@makefntext{\b:@makefntext 
                                   \a:@makefnbody #1\b:@makefnbody 
                            }\c:@makefntext...} 

<..latex ltfloat..>+
 \pend:def\@footnotemark{\bgroup
   \expandafter\ifx \csname @makefnmark\endcsname\relax \else
     \pend:def\@makefnmark{\hbox\bgroup\a:footnotemark}%
     \append:def\@makefnmark{\b:footnotemark\egroup}%
   \fi
 }
 \append:def\@footnotemark{\egroup}
 \NewConfigure{footnotemark}{2}
 \NewConfigure{footnotebody}{2}
 -_-_-

<..latex ltfloat..>+
 \long\def\@footnotetext#1{\leavevmode
    \vbox{%\IgnorePar
       \leftskip0pt {\ht:everypar{}\parindent0pt\leavevmode}%
       <.makefntext for footnotetext.>%
       \reset@font\footnotesize
       \color@begingroup
         \@makefntext{\ignorespaces#1}%
       \color@endgroup
       \ht:special{t4ht@[}}\ht:special{t4ht@]}}
 \NewConfigure{footnotetext}{3}
 -_-_-

<..makefntext for footnotetext..>
 \long\def\:tempc##1{<.footnote label.>\a:footnotetext
    \o:@makefntext:{\b:footnotetext \csname a:footnotebody\endcsname
                 {##1}\csname b:footnotebody\endcsname}\c:footnotetext
 }%
 \HLet\@makefntext\:tempc
 -_-_-

<..footnote label..>
 \protected@edef
   \@currentlabel{\csname p@footnote\endcsname\@thefnmark}%
 \anc:lbl f{footnote}%
 -_-_-

The following arises in cases like ‘ \begin{minipage}{6in} x\footnote{The} \end{minipage}’.

<..latex ltfloat..>+
 \long\def\@mpfootnotetext#1{\leavevmode
    \vbox{%
       \leftskip0pt {\ht:everypar{}\parindent0pt\leavevmode}%
       <.makefntext for mpfootnotetext.>%
       \reset@font\footnotesize
       \color@begingroup
          \@makefntext{\ignorespaces #1}%
       \color@endgroup
       \ht:special{t4ht@[}}\ht:special{t4ht@]}}
 -_-_-

<..makefntext for mpfootnotetext..>
 \def\:tempc##1{<.mpfootnote label.>\a:footnotetext
    \o:@makefntext:{\b:footnotetext \csname a:footnotebody\endcsname
                 {##1}\csname b:footnotebody\endcsname}\c:footnotetext
 }%
 \HLet\@makefntext\:tempc
 -_-_-

<..mpfootnote label..>
 \protected@edef
   \@currentlabel{\csname p@mpfootnote\endcsname\@thefnmark}%
 \anc:lbl f{footnote}%
 -_-_-

The following assign the counter into \FNnum.

<..latex ltfloat..>+
 \def\FNnum{\the\c@footnote}
 \def\:tempc{%
    \HAssign\FNnum = \csname c@\@mpfn\endcsname
    \HAdvance\FNnum by 1
    \o:footnote:
 }
 \HLet\footnote=\:tempc
 \def\:tempc[#1]{%
    \HAssign\FNnum = #1\relax
    \o:@xfootnote:[#1]%
 }
 \HLet\@xfootnote\:tempc
 \def\:tempc{%
    \HAssign\FNnum = \c@footnote
    \HAdvance\FNnum by 1
    \o:footnotemark:
 }
 \HLet\footnotemark\:tempc
 \def\:tempc[#1]{%
    \HAssign\FNnum =  #1\relax
    \o:@xfootnotemark:[#1]%
 }
 \HLet\@xfootnotemark\:tempc
 \def\:tempc{%
    \HAssign\FNnum = \csname c@\@mpfn\endcsname
    \o:footnotetext:
 }
 \HLet\footnotetext\:tempc
 \def\:tempc[#1]{%
    \HAssign\FNnum = #1\relax
    \o:@xfootnotenext:[#1]%
 }
 \HLet\@xfootnotenext\:tempc
 -_-_-