It is possible to do that, but it is not that easy. Here is a MWE:
\documentclass{article}
\newcommand\eqannotate[1]{#1}
\title{Grasp movement initiation and representation}
\begin{document}
We recorded single neurons in F1 and hold actions, and investigated the population-level differences could explain, please refer $t_{1,92} = -0.55$ plotted $\mathbf{V_{Obs}}$ at x10 gain) how condition.
\[
c^2 = \sqrt{a^2+b^2}
\]
\begin{equation}
\eqannotate{c^2 = \sqrt{a^2+b^2}}
\end{equation}
\end{document}
As you can see, I introduced the \eqannotate
command, which is used in the equation
environment. I am afraid that it is not easily possible to catch contents of environments, so they need to be marked by hand (or using pre-processing script).
Here is a configuration file:
\Preamble{xhtml}
\newtoks\eqtoks
\def\AltMath#1${\eqtoks{#1}%
#1\HCode{</mrow><annotation encoding="application/x-tex">\the\eqtoks</annotation>}$}
\Configure{$}{\Configure{@math}{display="inline"}\DviMath\HCode{<semantics><mrow>}}{\HCode{</semantics>}\EndDviMath}{\expandafter\AltMath}
\long\def\AltDisplay#1\]{\eqtoks{#1}#1\HCode{</mrow><annotation encoding="application/x-tex">\the\eqtoks</annotation></semantics>}\]}
\Configure{[]}{\Configure{@math}{display="block"}\DviMath$$\DisplayMathtrue\HCode{<semantics><mrow>}\AltDisplay}{$$\EndDviMath}
\renewcommand\eqannotate[1]{\eqtoks{#1}\HCode{<semantics><mrow>}#1\HCode{</mrow><annotation encoding="application/x-tex">\the\eqtoks</annotation></semantics>}}
\begin{document}
\EndPreamble
MathML has the <annotation>
element, it can be used to insert raw LaTeX code to the HTML as an annotation.
\Configure{$}
and \Configure{[]}
configure what HTML code will be inserted for $ ... $
and \[ ... \]
. It also calls command that saves the original LaTeX code in a token list, typesets MathML and then prints the saved tokens inside <annotation>
. Most of this code is copied from mathml.4ht
, it is only a bit simplified.
Regarding wrong formatting of $\mathbf{V_{Obs}}$
, this can be fixed using the following DOM filter:
local domfilter = require "make4ht-domfilter"
local function find_mstyle(x)
-- find if element has <mstyle> parent, and its value of mathvariant
if not x:is_element() then
return nil
elseif x:get_element_name() == "mstyle" then
return x:get_attribute("mathvariant")
else
return find_mstyle(x:get_parent())
end
end
local process = domfilter {
function(dom)
-- fix bold subscript
for _, el in ipairs(dom:query_selector "mstyle mi") do
local mathvariant = find_mstyle(el:get_parent())
if mathvariant and el:get_attribute("mathvariant") then
el:set_attribute("mathvariant", mathvariant)
end
end
return dom
end
}
Make:match("html$", process)
Compile using:
make4ht -e build.lua -c config.cfg sample.tex "mathml,mathjax"
This is the resulting HTML:
<p class='noindent'>We recorded single neurons in F1 and hold actions, and investigated
the population-level differences could explain, please refer
<!-- l. 9 --><math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><msub><mrow><mi>t</mi></mrow><mrow><mn>1</mn><mo class='MathClass-punc'>,</mo><mn>92</mn></mrow></msub> <mo class='MathClass-rel'>=</mo> <mo class='MathClass-bin'>−</mo><mn>0.55</mn></mrow><annotation encoding='application/x-tex'>t_{1,92} = -0.55</annotation></semantics></math> plotted
<!-- l. 9 --><math display='inline' xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mrow><mstyle mathvariant='bold'><msub><mrow><mi>V</mi></mrow><mrow><mi mathvariant='bold'>Obs</mi></mrow></msub></mstyle></mrow><annotation encoding='application/x-tex'>\mathbf {V_{Obs}}</annotation></semantics></math> at
x10 gain) how condition.
</p><!-- l. 11 --><p class='indent'> <!-- l. 11 --><math display='block' xmlns='http://www.w3.org/1998/Math/MathML'>
<semantics><mrow><msup><mrow><mi>c</mi></mrow><mrow><mn>2</mn></mrow></msup> <mo class='MathClass-rel'>=</mo> <msqrt><mrow><msup><mrow><mi>a</mi></mrow><mrow><mn>2</mn> </mrow> </msup> <mo class='MathClass-bin'>+</mo> <msup><mrow><mi>b</mi></mrow><mrow><mn>2</mn></mrow></msup></mrow></msqrt></mrow><annotation encoding='application/x-tex'> c^2 = \sqrt {a^2+b^2} </annotation></semantics>
</math>
</p>
<table class='equation'><tr><td>
<!-- l. 16 --><math class='equation' display='block' xmlns='http://www.w3.org/1998/Math/MathML'>
<mstyle class='label' id='x1-2r1'></mstyle><!-- endlabel --><semantics><msup><mrow><mi>c</mi></mrow><mrow><mn>2</mn></mrow></msup> <mo class='MathClass-rel'>=</mo> <msqrt><mrow><msup><mrow><mi>a</mi></mrow><mrow><mn>2</mn> </mrow> </msup> <mo class='MathClass-bin'>+</mo> <msup><mrow><mi>b</mi></mrow><mrow><mn>2</mn></mrow></msup></mrow></msqrt><annotation encoding='application/x-tex'>c^2 = \sqrt {a^2+b^2}</annotation></semantics>
</math></td><td class='eq-no'>(1)</td></tr></table>
And rendered page:
It seems that this is an error in biblatex.4ht
which happens only in the XeTeX mode. This is the culprit:
\ifdefined\XeTeXversion
\def\abx@aux@defaultrefcontext#1#2#3{%
\global\boolfalse{refcontextdefaults}%
\csxdef{blx@assignedrefcontextbib@#1@\detokenize{#2}}{\detokenize{#3}}}
\fi
It redefines some internal macro when XeTeX is active, adding additional \detokenize
to protect special characters. It seems that the refcontextdefaults
boolean variable is not used by BibLaTeX anymore, so we can just remove this line. It seems to fix the issue.
Here is the full biblatex.4ht
with the fix:
% biblatex.4ht (2021-12-27-13:23), generated from tex4ht-4ht.tex
% Copyright 2007-2009 Eitan M. Gurari
% Copyright 2009-2021 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2021-12-27-13:23}
\def\make:blx:ver#1.#2#3\relax{%
%\ifdim#1pt< 3pt \xdef\blx:ver:no{2}\else\xdef\blx:ver:no{3}\fi%
\gdef\blx:ver:no{#1}
\gdef\blx:subver:no{#2}
}
\expandafter\make:blx:ver\[email protected]\relax
\ifx\a:printshorthands\Undef\let\blx@shorthands\@empty\fi
\ifx\blx@startbib\:UnDef
\pend:def\blx@shorthands{%
\pend:def\blx@bibinit{%
\HAssign\shorthands:cnt=0
\NewConfigure{printfield-shorthand}{2}%
\Configure{printfield-shorthand}%
{\gHAdvance\shorthands:cnt by 1\relax
\ifnum \shorthands:cnt=1 \a:printshorthands
\else \c:printshorthands \fi
}
{\d:printshorthands}%
\append:def\endtheshorthands{\b:printshorthands}%
\csname a:@shorthands\endcsname}
}
\ifx\b:printshorthands\Undef\let\endtheshorthands\@empty\fi
\def\a:entryhead{CVR}
\def\a:entryhead:full{CV Radhakrishnan}
\ifx\bib@macro@entryhead:name\UnDef
\let\bib@macro@entryhead:name\@empty\fi
\ifx\bib@macro@entryhead:full\UnDef
\let\bib@macro@entryhead:full\@empty\fi
\gdef\BibFileName[#1]#2{\expandafter\xdef\csname
BibFileName#1\endcsname{#2}}
\newcount\sv:sec:cnt
\def\bibSecConfigure{%
\let\save:section\section
\global\sv:sec:cnt=\c@secnumdepth
\def\section{\@ifstar
{\c@secnumdepth=0\relax\save:section}%
{\c@secnumdepth=\sv:sec:cnt\save:section}}%
}
\gHAssign\bibN=0
\ifdefined\TE@hook\else%
\def\TE@hook{}%
\fi%
\AtBeginDocument{%
\Configure{ifthenelse}{\TE@hook}
}
\:CheckOption{ooffice}\if:Option
\def\bibConfigure{\ConfigureList{thebibliography}%
{\IgnorePar\EndP \gHAdvance\bib:N by 1
\HCode{<text:bibliography text:name="bib-\bib:N" >
<text:bibliography-source>\Hnewline
<text:index-title-template>}
\NoFonts\ref:name\EndNoFonts
\HCode{</text:index-title-template>\Hnewline
%
<text:bibliography-entry-template\Hnewline
text:bibliography-type="custom1"
text:style-name="Bibliography11">\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="identifier"/>\Hnewline
%
<text:index-entry-span>: </text:index-entry-span>\Hnewline
<text:index-entry-bibliography
text:bibliography-data-field="author" />\Hnewline
<text:index-entry-span>, </text:index-entry-span>\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="title" />\Hnewline
<text:index-entry-span>, </text:index-entry-span>\Hnewline
%
<text:index-entry-bibliography
text:bibliography-data-field="year" />\Hnewline
</text:bibliography-entry-template>\Hnewline\Hnewline
</text:bibliography-source>\Hnewline
<text:index-body>\Hnewline}%
\let\en:bib=\empty
}%
{\en:bib\HCode{</text:index-body></text:bibliography>}}
{\en:bib\gdef\en:bib{\HCode{</text:p>\Hnewline}}%
\HCode{<text:p text:style-name="p-bibitem">}%
\gHAdvance\bibN by 1
\HCode{<text:reference-mark
text:name="X0-\csname BIB-\bibN\endcsname">%
</text:reference-mark>}%
}%
{}{}
}
\else
\def\bibConfigure{%
\ConfigureList{thebibliography}
{\ifvmode \IgnorePar \fi \EndP \EndP
\HCode {<dl class="thebibliography">}%
%
% This is for linking citations with biblist items which
% are in a different file when output is split into different
% chunks. [CVR 2012-09-27]
%
%
% <biblatex-2.2>
%
\immediate\write\@auxout{%
\string\BibFileName[\therefsection]{\FileName}}%
%
% </biblatex-2.2>
%
\PushMacro \end:itm \global \let \end:itm =\empty}%
{\ifvmode \IgnorePar \fi \EndP
\PopMacro \end:itm \global \let \end:itm \end:itm \EndP
\HCode {</dd></dl>}\ShowPar}%
{\ifvmode \IgnorePar \fi \EndP \gHAdvance \bibN by 1
\end:itm \global \def \end:itm {\EndP \Tg </dd>}%
\HCode {<dt id="X\therefsection-\abx@field@entrykey"
class="thebibliography">}\bgroup \bf}%
{\ifvmode \IgnorePar \fi \EndP
\egroup
\HCode {</dt><dd\Hnewline id="bib-\bibN"
class="thebibliography">}%
\par \ShowPar}%
}
\fi
\NewConfigure{printshorthands}{4}
\NewConfigure{@shorthands}[1]{\concat:config\a:@shorthands{#1}}
\let\a:@shorthands\empty
% \def\nolinkurl{\o:url:}
% \def\blx@checksum{\ifx \blx@checksum@old \blx@checksum@new \else
% \blx@warning@noline {Page references have changed.\MessageBreak
% Rerun to get references right}\@tempswatrue \blx@reruntrue \fi
% \@nameuse {blx@rerun}}
\def\blx@checksum#1#2#3{%
\begingroup
\blx@tempcnta\the\numexpr0#2*0#3\relax
\blx@tempcntb\blx@tempcnta
\divide\blx@tempcntb10
\multiply\blx@tempcntb10
\advance\blx@tempcnta-\blx@tempcntb
\xdef#1{#1\the\blx@tempcnta}%
\endgroup}
\@ifpackagelater{biblatex}{2018/03/01}{\let\blx:pend:def\pend:defI}{\let\blx:pend:def\pend:def}
\blx:pend:def\blx@bibliography{\bibSecConfigure%
\pend:def\blx@bibinit{%
\bibConfigure
\csname onthebibliography:list\endcsname
}%
}
\let\en:bib\@empty
\newcounter{bib}
\ifnum\blx:ver:no < 3
\protected\def\blx@bbl@entry#1#2#3{%
\begingroup
\def\texht@bibkey{#1}
\edef\abx@field@entrykey{\detokenize{#1}}%
\global\advance\c@bib 1
\immediate\write\@auxout{\string\expandafter\string\gdef
\string\csname\space BIB-\thebib\string\endcsname
{\expandafter\strip@prefix\meaning\texht@bibkey}}%
\Tag{)QX\therefsection-#1}{\thebib}%
\blx@setoptions@type{#2}%
\blx@bbl@options{#3}%
\blx@setoptions@entry
\edef\blx@bbl@data{blx@data@\the\c@refsection @\abx@field@entrykey}%
\csuse\blx@bbl@data
\cslet\blx@bbl@data\@empty
\blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
\blx@bbl@addfield{entrytype}{#2}%
\blx@imc@iffieldundef{options}
{}
{\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}
%
\protected\def\blx@finentry{%
\unspace
\a:finentry
\finentrypunct
\blx@postpunct
\b:finentry
\blx@initunit
}
%
\else
% Biblatex 3.0
%
% Hacks for biblatex
% MakeUppercase is redefined by tex4ht, biblatex tries to redefine it as well, but it relies on original
% LaTeX version:
\DeclareRobustCommand{\MakeUppercase}[1]{{%
\def\i{I}\def\j{J}%
\def\reserved@a##1##2{\let##1##2\reserved@a}%
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
\let\UTF@two@octets@noexpand\@empty
\let\UTF@three@octets@noexpand\@empty
\let\UTF@four@octets@noexpand\@empty
\blx@hook@uc\protected@edef\reserved@a{\uppercase{#1}}%
\reserved@a
}}
% Same applies also for \MakeLowercase
\DeclareRobustCommand{\MakeLowercase}[1]{{%
\def\reserved@a##1##2{\let##2##1\reserved@a}%
\expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}%
\let\UTF@two@octets@noexpand\@empty
\let\UTF@three@octets@noexpand\@empty
\let\UTF@four@octets@noexpand\@empty
\blx@hook@lc\protected@edef\reserved@a{\lowercase{#1}}%
\reserved@a
}}
% I don't really understand this, but language processing is broken by default
% with biblatex. It loads language file, but it executes code which should be
% executed only in the case if the language file fails, it displays an error message
% and language handling doesn't work. When we execute following code, the language
% files are loaded before checking of the success and it seems to work.
\AtBeginDocument{%
\@ifpackageloaded{babel}
{% This is required for languages which are never explicitly selected
% It seems this code was executed also with Polyglossia, where it caused compilation error
\@ifpackageloaded{polyglossia}{}{%
\def\do#1{\blx@lbxinput{#1}{}{}}%
\ifx\@empty\bbl@loaded\else%
\expandafter\docsvlist\expandafter{\bbl@loaded}%
\fi}}{}%
}
\fi % end of version boolean
\NewConfigure{finentry}{2}
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:printfield-#2\endcsname\relax
\NewConfigure{printfield-#2}{2}%
\a:printfield{printfield-#2}%
\fi
\Configure{blx@unit}%
{\csname a:printfield-#2\endcsname}%
{\csname b:printfield-#2\endcsname}%
\csname o:\string\blx@printfield:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@printfield\endcsname\:tempc
\NewConfigure{printfield}[1]{\def\a:printfield##1{#1}}
\Configure{printfield}{%
\Configure{#1}%
{\HCode{<!--#1-->}}%
{\HCode{<!--/#1-->}}%
}
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibstring-#2\endcsname\relax
\NewConfigure{bibstring-#2}{2}%
\a:printfield{bibstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibstring-#2\endcsname}%
{\csname b:bibstring-#2\endcsname}%
\csname o:\string\blx@bibstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibcpstring-#2\endcsname\relax
\NewConfigure{bibcpstring-#2}{2}%
\a:printfield{bibcpstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibcpstring-#2\endcsname}%
{\csname b:bibcpstring-#2\endcsname}%
\csname o:\string\blx@bibcpstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibcpstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:biblcstring-#2\endcsname\relax
\NewConfigure{biblcstring-#2}{2}%
\a:printfield{biblcstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:biblcstring-#2\endcsname}%
{\csname b:biblcstring-#2\endcsname}%
\csname o:\string\blx@biblcstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@biblcstring\endcsname\:tempc
\def\:tempc[#1]#2{%
\expandafter\ifx \csname a:bibucstring-#2\endcsname\relax
\NewConfigure{bibucstring-#2}{2}%
\a:printfield{bibucstring-#2}%
\fi
\Configure{blx@unit}%
{\csname a:bibucstring-#2\endcsname}%
{\csname b:bibucstring-#2\endcsname}%
\csname o:\string\blx@bibucstring:\endcsname[#1]{#2}%
}
\expandafter\HLet\csname\string\blx@bibucstring\endcsname\:tempc
\NewConfigure{biblatex-style}[2]{%
\def\:temp{#1}%
\ifx \:temp\blx@cbxfile
#2%
\global\let\biblatex:style\def
\fi
}
\def\biblatex:style{}
\Configure{biblatex-style}{}{}
\pend:def\at:docend{%
\ifx \UnDef\biblatex:style
\:warning{\string\Configure{biblatex-style}{\blx@cbxfile}{...}
not available}%
\fi
}
\let\blx:item\@item
\def\@item[#1]{%
\blx:item[#1]%
\ifhmode \spacefactor\blx@sf@par\fi
}
\let\blx@resetpuncthook\@empty
\let\blx@csq@ifkernmark\@empty
\newskip\blx@unitmark
\blx@unitmark=10pt plus 1pt minus 1pt
\let\abx@aux@page\@gobbletwo
\let\abx@aux@fnpage\@gobbletwo
\let\abx@aux@refsection\@gobbletwo
%
% <[email protected]> reported that After updating
% biblatex and biblatex.ht to versions 2.2 respectively
% 2012-09-28-17:49 (using MiKTeX 2.9 64 bit), tex4ht seemed no longer
% respected the defernumbers option in biblatex.sty: When applied to
% the attached file tex4hterror.tex.
%
% The problem was due to nullifying \abx@aux@number which in fact
% should have been redefined to \blx@aux@number when defernumbers
% option is true.
%
% This is done now and as per Kristian, the fix works fine now.
%
\ifnum\blx:ver:no < 3
%
\protected\def\blx@aux@number#1#2#3#4{%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}%
\ifblank{#4}%
{}%
{\csgdef{blx@labelnumber@#3}{#4}%
%\blx@addchecksum{#1}{#4} % this can cause a nodocument error!
}}
%
\iftoggle{blx@defernumbers}%
{\setkeys{blx@opt@pre}{labelnumber}%
\let\blx@thelabelnumber\blx@addlabelnumber
\let\abx@aux@number\blx@aux@number}%
{\let\blx@thelabelnumber\relax
\let\abx@aux@number\@gobblefour}
%
\else
\def\@gobblefive#1#2#3#4#5{}%
\protected\def\blx@aux@number#1#2#3#4#5{%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}{#5}%
\blx@bbl@addentryfield{\detokenize{#2}}{#3}{labelnumber}{#4}{#5}%
\global\toggletrue{blx@localnumber}%
\ifblank{#5}
{}
{\csgdef{blx@labelnumber@#3@#4}{#5}}}
\iftoggle{blx@defernumbers}%
{\setkeys{blx@opt@pre}{labelnumber}%
\let\blx@thelabelnumber\blx@addlabelnumber
\let\abx@aux@number\blx@aux@number}%
{\let\blx@thelabelnumber\relax
\let\abx@aux@number\@gobblefive}
\fi % end of version boolean
%
\AtEndDocument{%
\def\abx@aux@page#1#2{\blx@addpagesum{#1}{#2}}%
\def\abx@aux@fnpage#1#2{\blx@addpagesum{#1}{#2}}%
}
%
\def\blx@begunit{%
\toggletrue{blx@tempa}%
\iftoggle{blx@insert}%
{\iftoggle{blx@unit}%
{\begingroup
\let\blx@begunit\@empty
\let\blx@endunit\@empty
\let\blx@endnounit\@empty
\blx@unitpunct\blx@postpunct
\endgroup
\global\togglefalse{blx@unit}%
\togglefalse{blx@tempa}}
{\blx@postpunct}%
\iftoggle{blx@block}%
{\begingroup
\let\blx@begunit\@empty
\let\blx@endunit\@empty
\let\blx@endnounit\@empty
\newblockpunct
\endgroup
\global\togglefalse{blx@block}%
\togglefalse{blx@tempa}}%
{}}%
{}%
\blx@postpunct
\blx@imc@resetpunctfont
\iftoggle{blx@tempa}%
{}%
{\global\togglefalse{blx@insert}}%
\csname a:blx@unit\endcsname
\blx@leavevmode
\begingroup
\Configure{blx@unit}{}{}%
}
\def\blx@endunit{%
\endgroup
\csname b:blx@unit\endcsname%
\Configure{blx@unit}{}{}%
\global\toggletrue{blx@insert}%
\global\toggletrue{blx@lastins}%
}
\NewConfigure{blx@unit}{2}
%
\else
\fi
\ifdefined\XeTeXversion
\def\abx@aux@defaultrefcontext#1#2#3{%
\csxdef{blx@assignedrefcontextbib@#1@\detokenize{#2}}{\detokenize{#3}}}
\fi
\renewrobustcmd*{\addnbspace}{%
\unspace\blx@postpunct%
% insert real non-breaking space character
\nobreakspace\blx@imc@resetpunctfont}
\NewConfigure{thebibliography}{4}
\append:def\blx@bibinit{\a:bibinit}%
\NewConfigure{bibinit}{1}%
\let\blx@anchors\@empty
\let\bib@field@entrykey\@empty
\protected\def\blx@anchor{%
\xifinlist{X\the\c@refsection -%@
\bib@field@entrykey}{\blx@anchors}%
{}%
{\listxadd\blx@anchors{X\the\c@refsection -%@
\bib@field@entrykey}%
\hyper:natanchorstart{X\the\c@refsection -%@
\bib@field@entrykey}%
\hyper:natanchorend}}
\protected\def\blx@bibhyperref{%
\@ifnextchar[%]
{\blx@bibhyperref@i}%
{\blx@bibhyperref@i[\bib@field@entrykey]}}%
\long\def\blx@bibhyperref@i[#1]#2{%
\hyper:natlinkstart{X\the\c@refsection -%@
#1}%
#2\hyper:natlinkend}%
\protected\long\def\blx@bibhyperlink#1#2{%
\hyper:natlinkstart{X\the\c@refsection -%:
#1}%
#2\hyper:natlinkend}%
\protected\long\def\blx@bibhypertarget#1#2{%
\@bsphack
\hyper:natanchorstart{X\the\c@refsection -%:
#1}%
\@esphack
#2\hyper:natanchorend}%
\let\blx@ifhyperref\@firstoftwo
% Oleg Domanov [email protected] reports:
% tex4ht ends with an error when compiles biblatex files. I'm on
% Windows, texlive 2012. I put here a minimal example and files
% generated with the command latexmk test && mk4ht oolatex test
%
% https://www.dropbox.com/s/hn1zm40htqs13mf/t4htlink.zip
%
% There is a superfluous \relax in the file test.tmp, line 65 which
% seems to cause the error.
%
% Changes to cope with biblatex upgrade caused this problem. It is now
% fixed. --CVR 2012/10/26
%
\:CheckOption{ooffice}\if:Option
\def\hyper:natanchorstart#1{\Link{}{#1}\EndLink}%
\def\hyper:natlinkstart#1{\Link{#1}{}}%
\else
\def\hyper:natanchorstart#1{%
\expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
\Tag{)Qpage.\thepage}{\file:id}%
\HCode{<a id="page.\thepage"></a>}%
\expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
\fi
\Link[\csname BibFileName\therefsection\endcsname]{}{#1}\EndLink}
\def\hyper:natlinkstart#1{%
\expandafter\ifx\csname QXpage.\thepage\endcsname\relax%
\Tag{)Qpage.\thepage}{\file:id}%
\HCode{<a id="page.\thepage"></a>}%
\expandafter\xdef\csname QXpage.\thepage\endcsname{0}%
\fi
\Link[\csname BibFileName\therefsection\endcsname]{#1}{}}
\fi
\def\hyper:natanchorend{}
\def\hyper:natlinkend{\EndLink}
\def\writeCiteLink#1{\immediate\write\@mainaux{%
\string\@namedef{#1.\thepage}{\FileName}}}
\let\blx@addpagesum\@gobbletwo
% \let\nolinkurl\relax
\ifx\blx:ver:no < 3
%
% biblatex 2.9a
%
% Newly added to process {keylist} environment (CVR)
%
\let\keylist\description
\let\endkeylist\enddescription
\def\keyitem#1{\item[#1]}%
%
%
\else
%
% biblatex 3.0
%
\let\keylist\Un:def
\let\endkeylist\Un:def
\newenvironment*{keylist}
{\list{}{%
\setlength{\labelwidth}{1.25in}%
\setlength{\labelsep}{10pt}%
\setlength{\leftmargin}{0pt}%
\setlength{\itemsep}{0pt}%
\raggedright%
\renewcommand*{\makelabel}[1]{\hss\bfseries##1}}}
{\endlist}
%
\def\keyitem#1{%
\item[#1]
\begingroup
\keyitemhook%
\blx@bibinit%
\midsentence\ifbibstring{#1}{}{\latintext}\biblstring{#1}%
\expandafter\lbx@initnamehook\lsmartoftext%
\par\nobreak
\midsentence\ifbibstring{#1}{}{\latintext}\bibsstring{#1}%
\expandafter\lbx@initnamehook\ssmartoftext%
\endgroup
\par\nobreak}
\fi % End of version boolean
\ConfigureList{keylist}%
{\EndP\HCode{<dl \a:LRdir class="description">}%
\PushMacro\end:itm
\global\let\end:itm=\empty}%
{\PopMacro\end:itm \global\let\end:itm \end:itm
\EndP\HCode{</dd></dl>}\ShowPar}%
{\end:itm \global\def\end:itm{\EndP\Tg</dd>}\HCode{<dt
class="description">}\bgroup \bf}%
{\egroup\EndP\HCode{</dt><dd\Hnewline class="description">}}
\let\:temp\do
\def\do#1{%
\patchcmd#1%
{\color@begingroup}%
{\color@begingroup\toggletrue{blx@footnote}}%
{\togglefalse{blx@tempa}\listbreak}%
{}}%
\docsvlist{%
\@footnotetext,% latex
\H@@footnotetext,% hyperref
\scr@saved@footnotetext,% koma-script 3.x
\l@dold@footnotetext,% ledmac
\l@doldold@footnotetext,% ledmac
\@fntORI}% frenchle
\let\do\:temp
\pend:defI\blx@backref{%
% prevent duplicate backlink on the same page
\ifcsdef{bk##1\thepage}{}{%
% insert link to the page
\html:addr\Link-{}{x\last:haddr}\EndLink%
% save link to the .xref file
\Tag{)Q##1\thepage}{x\last:haddr}%
% we need to save the link destination in .xref file
% too, otherwise \Link command would issue warning
\Tag{)Qx\last:haddr}{\FileNumber}%
}%
% declare this backlink destination as used, so we don't
% declare another one with the same name
\expandafter\gdef\csname bk##1\thepage\endcsname{}%
}
% version of \hyperlink that links back to saved link in citation
% on the given DVI page
\def\bbx:hyperlink#1#2{
% first argument is destination used by Hyperref, second is page number
% test if we saved link to the current bibitem and page
\ifTag{)Q\abx@field@entrykey#2}{%
\Link{\LikeRef{)Q\abx@field@entrykey#2}}{}#2\EndLink%
}%
{#2}% print just page number if there is no saved link
}
% we need to redefine pageref format, which is used for printing of
% back link page numbers. custom \hyperlink command is used
\DeclareListFormat{pageref}{%
% we redefine \hyperlink command to link page numbers in backreferences
% back to the citations on the given pages
\let\orig:hyperlink\hyperlink%
\let\hyperlink\bbx:hyperlink%
\ifnumless{\abx@pagerefstyle}{0}
{\usebibmacro{list:plain}%
\ifhyperref
{\hyperlink{page.#1}{#1}}
{#1}}
{\ifnumequal{\value{listcount}}{1}
{\usebibmacro{pageref:init}}
{}%
\usebibmacro{pageref:comp}{#1}%
\ifnumequal{\value{listcount}}{\value{liststop}}
{\usebibmacro{pageref:dump}}
{}}
\let\hyperlink\orig:hyperlink%
}
\Hinput{biblatex}
\endinput
Best Answer
The main problem is that the
elife
class loads Unicode-math package, which is not supported by TeX4ht. It even causes fatal error. To fix that, we need to create a special file that will prevent Unicode-math from loading, and define dummy version of\setmathfont
.Here is the file,
unicode-math-hooks.4ht
:We need to register this file in TeX4ht, using
usepackage.4ht
:With this fix, you will not get a fatal error, but you will still get a compilation error caused by
elife
's additions to\maketitle
. We can fix this issue withelife.4ht
file:It inserts some configurable hooks that can be used to insert HTML code. Yu can configure these hooks in a
.cfg
file:It should compile correctly now: