summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tex4ebook
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-04-28 21:21:37 +0000
committerKarl Berry <karl@freefriends.org>2017-04-28 21:21:37 +0000
commit37dfda47fe844c888a24fb8cc380d34139dca9f4 (patch)
treea1a1d9dc047773102a07f939e2ada149f00fb179 /Master/texmf-dist/tex/latex/tex4ebook
parenteda997681c2c45b147792fe2f546e45150447197 (diff)
tex4ebook (28apr17)
git-svn-id: svn://tug.org/texlive/trunk@44103 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tex4ebook')
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht2
-rw-r--r--Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht83
2 files changed, 53 insertions, 32 deletions
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
index e7d75821123..d7f470552cb 100644
--- a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook-epub3.4ht
@@ -52,7 +52,7 @@
%}
%\:CheckOption{mathml}
%\if:Option
-\apptocmd{\a:DviMath}{\opf:registerfilename{\FileName}\opf:add:property{mathml}}{}{}
+\apptocmd{\a:DviMath}{\opf:add:property{mathml}}{}{}%
%\fi
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{xmlns}{}{http://www.w3.org/1999/xhtml}
diff --git a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
index 8c7c51903b4..6cea65ee653 100644
--- a/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
+++ b/Master/texmf-dist/tex/latex/tex4ebook/tex4ebook.4ht
@@ -161,15 +161,8 @@ href="#1" media-type="\a:CoverMimeType" />}}
% add main html as first file in the OPF
\opf:registerfilename{\jobname.\:html} %
-\:CheckOption{epub}
-\if:Option
-%\Configure{crosslinks+}{}{}{}{}
-
-% add explicit table of contents to OPF
-\let\old:toc\a:tableofcontents
-\def\a:tableofcontents{\old:toc\OpfRegisterFile}
-
+% register all sectioning commands in the OPF
\def\patch:sec:register#1{%
\csgappto{c:#1}{\OpfRegisterFile}%
}
@@ -183,6 +176,13 @@ href="#1" media-type="\a:CoverMimeType" />}}
\patch:sec:register{likesubsection}
\patch:sec:register{likesubsubsection}
+\:CheckOption{epub}
+\if:Option
+%\Configure{crosslinks+}{}{}{}{}
+
+% add explicit table of contents to OPF
+\let\old:toc\a:tableofcontents
+\def\a:tableofcontents{\old:toc\OpfRegisterFile}
% Support for SVG isn't ready
%\Configure{Picture}{.svg}
\Configure{Picture}{.png}
@@ -212,6 +212,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
\ifdef\chapter{%
%\CutAt{chapter}\CutAt{likechapter}
% copied from tex4ht-html4.tex
+ \CutAt{part,appendix}
\CutAt{chapter,likechapter,appendix,part}
\CutAt{likechapter,appendix,part}
\CutAt{appendix,chapter,likechapter,part}
@@ -237,23 +238,47 @@ href="#1" media-type="\a:CoverMimeType" />}}
\def\finishtoclevel#1{%
\csgdef{nav#1finish}{\d:NavSection}
}
+
\def\closelevels#1{
- \usetoclevels{#1}
- \resettoclevels{#1}
+ \expandafter\usetoclevels\expandafter{#1}
+ \expandafter\resettoclevels\expandafter{#1}
}
% 1 - section type 2 - closed sections
\def\navsection#1#2{
\ConfigureToc{#1}%
- {\closelevels{#2}%
+ {\expandafter\closelevels\expandafter{#2}
\a:NavSection\Ncx:Mark}
{\c:NavSection}
{}
{\b:NavSection%
- \finishtoclevel{#1}%
+ \expandafter\finishtoclevel\expandafter{#1}%
+ }
+}
+
+% define closing groups for all levels defined in \Configure{resettoclevels}
+
+\def\tmp:processlevel#1{
+ \bgroup
+ \csxdef{tmp:resettoclevels#1}{}
+ \def\do##1{\csxdef{tmp:resettoclevels#1}{\csname tmp:resettoclevels#1\endcsname ##1,like##1,}}
+ \def\tmp:parse##1#1##2\nil{
+ \docsvlist{#1##2}
}
+ \expandafter\tmp:parse\a:resettoclevels\nil
+ \egroup
+ \navsection{#1}{\csname tmp:resettoclevels#1\endcsname}
+ % define hierarchy also for starred sections
+ \navsection{like#1}{\csname tmp:resettoclevels#1\endcsname}
}
+% define children levels for each sectioning level
+\def\confnavsections{%
+ \def\do##1{%
+ \tmp:processlevel{##1}%
+ }
+ \expandafter\docsvlist\expandafter{\a:resettoclevels}
+}
% As reported by Nat Kuhn on http://tex.stackexchange.com/q/209312/2891
% zeroes were printed as section numbers when secnumdepth counter was set to negative value
% so just strip then out
@@ -282,6 +307,10 @@ href="#1" media-type="\a:CoverMimeType" />}}
% Get filename from tableofcontents anchor
\def\ncx:hfile#1{\Ref{)F\Ref{)Q#1}F-}}
+% define toc levels which should be included in the NCX file
+\NewConfigure{resettoclevels}{1}
+\Configure{resettoclevels}{part,chapter,section,subsection,subsubsection,paragraph}
+
\def\:tempa{%
\EndP
\HtmlParOff
@@ -297,30 +326,22 @@ href="#1" media-type="\a:CoverMimeType" />}}
% so:
\let\contentsname=\empty
\Configure{tableofcontents}{\boolfalse{tocnoempty}\Tg<navMap>}{%
- \usetoclevels{part,chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}%
+ \usetoclevels{part,chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection,subsubsubsection,paragraph}%
\ifbool{tocnoempty}{}%
{\HCode{<navPoint id="mainentry" playOrder="1">
<navLabel><text>Document</text></navLabel>
<content src="\jobname.\:html" />
</navPoint>}}%
\Tg</navMap>}{}{}{}
-% We need to configure TocLink
-% in navmapsrc is link to the file and anchor, where chapter or section is located
-\def\navmapsrc{}
-\Configure{TocLink}{\def\navmapsrc{\ncx:hfile{##2}\:sharp ##2}\opf:registerfilename{\ncx:hfile{##2}}##4}
-% Configuraion of entries
-\resettoclevels{part,chapter,section,subsection,subsubsection}
-\navsection{part}{part,chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{chapter}{chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{likechapter}{chapter,likechapter,section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{section}{section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{likesection}{section,likesection,subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{subsection}{subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{likesubsection}{subsection,likesubsection,subsubsection,likesubsubsection}
-\navsection{subsubsection}{subsubsection,likesubsubsection}
-\navsection{likesubsubsection}{subsubsection,likesubsubsection}
- \HtmlParOff
- \Configure{toTocLink}{}{}
+ % We need to configure TocLink
+ % in navmapsrc is link to the file and anchor, where chapter or section is located
+ \def\navmapsrc{}
+ \Configure{TocLink}{\def\navmapsrc{\ncx:hfile{##2}\:sharp ##2}\opf:registerfilename{\ncx:hfile{##2}}##4}
+ % Configuraion of entries
+ \expandafter\resettoclevels\expandafter{\a:resettoclevels}%
+ \confnavsections%
+ \HtmlParOff%
+ \Configure{toTocLink}{}{}%
\Configure{NavSection}{\booltrue{tocnoempty}\HCode{\Hnewline<navPoint id="navPoint-}%
\stepnavpoint\HCode{" playOrder="}%
\the\navpoint\HCode{">\Hnewline<navLabel>\Hnewline<text>}%
@@ -359,7 +380,7 @@ href="#1" media-type="\a:CoverMimeType" />}}
{\HCode{<dc:language>}\GetLanguage\HCode{</dc:language>\Hnewline}}
%Add interface for such things
{\HCode{<dc:identifier id="dcidid" \print:opf:scheme\a:OpfScheme>\a:UniqueIdentifier}\HCode{</dc:identifier>\Hnewline}}
-\def\and{<\HCode{/dc:creator>\Hnewline<dc:creator>}}
+\def\and{\HCode{</dc:creator>\Hnewline<dc:creator>}}
{\HCode{<dc:creator>}\Author\HCode{</dc:creator>\Hnewline}}
%{\HCode{<dc:contributor>\HP:file</dc:contributor>\Hnewline}}
{\HCode{<dc:date>}\:iso:date\HCode{</dc:date>}}