%\typeout{!!!!!!!!!!!!!!!!!!!!!!!!!!!epub3!!!!!!!!!!!!}
\Configure{NcxDoctype}{}
\Configure{VERSION}{}
% we must remove attributes from opf namespace
\def\print:opf:scheme#1{}
\Configure{OpfScheme}{}
\Configure{OpfMetadata}{\HCode{<meta property="dcterms:modified">}\:iso:date\HCode{</meta>}}
\def\opf:package:lang{xml:lang="\GetLanguage"}
%%%%%%%%%%%%%%%%%%%%%%%
%% Configure toc nav %%
%%%%%%%%%%%%%%%%%%%%%%%
\Configure{tableofcontents}{
\a:NavMap
\resettoclevels{part,appendix,chapter,section,subsection,subsubsection}
\navsection{part}{part,appendix,chapter,section,subsection,subsubsection}
\navsection{appendix}{appendix,chapter,section,subsection,subsubsection}
\navsection{chapter}{appendix,chapter,section,subsection,subsubsection}
\navsection{section}{section,subsection,subsubsection}
\navsection{subsection}{subsection,subsubsection}
\navsection{subsubsection}{subsubsection}
%\HtmlParOff
\Configure{toTocLink}{}{}
}{\b:NavMap}{}{}{}
%%%%%%%%%%%
\newcount\:toccount
\Configure{NavMap}{\ifvmode\IgnorePar\fi\EndP\boolfalse{tocnoempty}\global\advance\:toccount by1\HCode{<nav id="toc\the\:toccount" class="toc" \ifnum\:toccount<2 epub:type="toc" role="doc-toc"\fi>\Hnewline<ol>}%
\opf:registerfilename{\FileName}
\ifnum\:toccount<2 \opf:add:property{nav}\fi
}{\usetoclevels{part,appendix,chapter,section,subsection,subsubsection}%
\ifbool{tocnoempty}{}{\HCode{<li><a href="\jobname.\:html">Document</a></li>}}
\HCode{</ol></nav>}}
%%%%%%%%%%%
\Configure{NavSection}{%
\booltrue{tocnoempty}
\HCode{<li>}}{\HCode{<ol>\Hnewline}}{\ }{\Tg</ol>\Tg</li>}
% Disable numbering of the TOC by the reading system, numbers are added by tex4ht
\Css{nav.toc ol{list-style: none;}}
%%%% End toc nav configuration
\def\CoverMetadata#1{%
\special{t4ht+@File: #1}%
\Configure{OpfManifest}{\HCode{<item id="cover-image" properties="cover-image" href="#1" media-type="\a:CoverMimeType" />}}%
}
%\Configure{CoverImage}{%
% \HPage{}%
% \Configure{OpfManifest}{\HCode{<item id="cover-image" properties="cover-image" href="}\CoverImageName\HCode{" media-type="\a:CoverMimeType" />}}%
%\box0=\hbox\bgroup
% \ifvmode \IgnorePar\fi \EndP%
% \HCode{<section epub:type="cover">\Hnewline}}
%}
% {%\ifvmode \IgnorePar\fi \EndP%
%\HCode{</section>\Hnewline}%
%\EndHPage{}
%\egroup
%}
%\:CheckOption{mathml}
%\if:Option
\apptocmd{\a:DviMath}{\opf:add:property{mathml}}{}{}%
%\fi
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{xmlns}{}{
http://www.w3.org/1999/xhtml}
\Configure{xmlns}{epub}{
http://www.idpf.org/2007/ops}
%\Configure{xmlns}{m}{
http://www.w3.org/1998/Math/MathML}
%\Configure{HTML}{\HCode{<html\t4ht:xmlns lang=\"}\GetLanguage\HCode{">\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{HTML}{\HCode{<html\t4ht:xmlns lang="}\NoFonts\GetLanguage\EndNoFonts
\HCode{">\Hnewline}}{\HCode{\Hnewline</html>}}
\Configure{@HEAD}{}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(
http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
\Configure{@HEAD}{\HCode{<link
rel="stylesheet" type="text/css"
href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}
\Configure{EpubVersion}{3.0}
\Configure{OpfItemProperties}{properties="}{"}
% Daisy configuration
\:CheckOption{daisy-}\if:Option\else
% This configuration is used to generate the DAISY accessibility metadata
%
https://kb.daisy.org/publishing/docs/metadata/schema.org/index.html
\Configure{OpfMetadata}{\HCode{<meta property="dcterms:conformsTo" id="daisy-conf">EPUB Accessibility 1.1 - WCAG 2.0 Level AA</meta>}}
% from
https://kb.daisy.org/publishing/docs/metadata/schema.org/index.html#ex-01
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessMode">textual</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessMode">visual</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessModeSufficient">textual</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilityFeature">alternativeText</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilityFeature">MathML</meta>}}
% highContrastDisplay, DisplayTransformability, index, PrintPageNumbers, alternativeText, MathML, LongDescription, readingOrder, structuralNavigation, tableOfContents
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilityHazard">noFlashingHazard</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilityHazard">noSoundHazard</meta>}}
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>}}
% I didn't find that specific wording (accessibilityhazard) in the descriptions of WCAG, but in the error messages during the publication process with my service party
\Configure{OpfMetadata}{\HCode{<meta property="schema:accessibilitySummary">This publication conforms to WCAG 2.0 Level AA.</meta>}}
\fi
% Structural elements
\:CheckOption{fn-in}
\if:Option
\else
% Foootnote configuration for epub3
% Footnotes are printed directly after the paragraph they appeared in
% footnotebox - configure box in which footnotes are printed
% default configuration doesn't work in ibooks, don't know why
\NewConfigure{footnotebox}{2}
\Configure{footnotebox}{\ifvmode\IgnorePar\fi\HCode{<section epub:type="footnotes" class="footnotes">\Hnewline}}%
{\ifvmode\IgnorePar\fi\HCode{\Hnewline</section>\Hnewline}}%
\newbox\footnotebox%
% We must create new link command, so footnote mark can link to footnote text
\LinkCommand\fnlink{aside,href,id,class="footnote" epub:type="footnote" role="doc-footnote"}
\Configure{footnotemark}{\NoFonts\Link[ epub:type="noteref" role="doc-noteref"]{fn\FNnum x\minipageNum}{}}{\EndLink\EndNoFonts}%
\Configure{footnotetext}{\SaveEndP\global\setbox\footnotebox=\vtop\bgroup\NoFonts%
\ifvoid\footnotebox\else\unvbox\footnotebox\fi%
\bgroup%
\IgnorePar%
\fnlink{}{fn\FNnum x\minipageNum}\par\AnchorLabel%
}{\EndNoFonts}
{%
\ifvmode\IgnorePar\fi\EndP\HCode{\Hnewline}%
\Endfnlink\egroup\egroup\RecallEndP}%
\def\printfn{%
\ifvoid\footnotebox\else%
\a:footnotebox%
\box\footnotebox%
\b:footnotebox%
\fi%
}
% configure HtmlPar to print footnotebox.
\Configure{HtmlPar}
{\EndP\printfn\HCode{<p class="noindent">}}
{\EndP\printfn\HCode{<p class="indent">}}
{\HCode{</p>\Hnewline}}
{\HCode{</p>\Hnewline}}
\Css{.footnote{font-size:small;}}
\Css{.footnotes hr{width:30\%;margin:0 auto 0 0;}}
\Css{p + section.footnotes{margin-bottom: 1rem;}}
\fi