summaryrefslogtreecommitdiff
path: root/support/tex4ebook/tex4ebook.4ht
diff options
context:
space:
mode:
Diffstat (limited to 'support/tex4ebook/tex4ebook.4ht')
-rw-r--r--support/tex4ebook/tex4ebook.4ht29
1 files changed, 27 insertions, 2 deletions
diff --git a/support/tex4ebook/tex4ebook.4ht b/support/tex4ebook/tex4ebook.4ht
index 0132463917..7cd6ca39fe 100644
--- a/support/tex4ebook/tex4ebook.4ht
+++ b/support/tex4ebook/tex4ebook.4ht
@@ -318,7 +318,27 @@ href="#1" media-type="\a:CoverMimeType" />}}
}
% Get filename from tableofcontents anchor
-\def\ncx:hfile#1{\Ref{)F\Ref{)Q#1}F-}}
+\def\ncx:hfile#1{\LikeRef{)F\LikeRef{)Q#1}F-}}
+
+\ExplSyntaxOn
+% get filename for the section label
+% sometimes, TeX4ht returns list of file numbers for label. we must use just
+% the first number. we use the LaTeX 3 sequence list to get it.
+\tl_new:N\ncx:hfilename
+\def\ncx:newhfile#1{
+ \cs_if_exist_use:cTF{cw:)Q#1}{%
+ % cw:)Q#1 is csname of tag from the xref file. we convert it to sequence
+ \seq_set_from_clist:Nc\l_tmpa_seq{cw:)Q#1}
+ % get first item and put it to a token list
+ \seq_get_left:NN \l_tmpa_seq \l_tmpa_tl
+ % \RefFileNumber returns file name for the given file number
+ % \ncx:hfilename contains the filename for later use
+ \tl_set:Nx \ncx:hfilename {\RefFileNumber{\l_tmpa_tl}}
+ }{%
+ \tl_set:Nn \ncx:hfilename {nic}
+ }
+}
+\ExplSyntaxOff
% define toc levels which should be included in the NCX file
\NewConfigure{resettoclevels}{1}
@@ -349,7 +369,12 @@ href="#1" media-type="\a:CoverMimeType" />}}
% 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}
+ \Configure{TocLink}{%
+ \ncx:newhfile{##2}
+ \def\navmapsrc{\ncx:hfilename\:sharp ##2}
+ \opf:registerfilename{\ncx:hfilename}
+ ##4
+ }
% Configuraion of entries
\expandafter\resettoclevels\expandafter{\a:resettoclevels}%
\confnavsections%