From 956b4d32335efcb457be1f3e20529bce220968ea Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 20 Dec 2021 22:50:40 +0000 Subject: backlinks for biblatex, tex4hr r1037 git-svn-id: svn://tug.org/texlive/trunk@61362 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/generic/tex4ht/ChangeLog | 3 ++ .../source/generic/tex4ht/tex4ht-4ht.tex | 57 +++++++++++++++++++++- Master/texmf-dist/tex/generic/tex4ht/biblatex.4ht | 54 +++++++++++++++++++- 3 files changed, 111 insertions(+), 3 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/source/generic/tex4ht/ChangeLog b/Master/texmf-dist/source/generic/tex4ht/ChangeLog index a5f973895b1..21c5b056204 100644 --- a/Master/texmf-dist/source/generic/tex4ht/ChangeLog +++ b/Master/texmf-dist/source/generic/tex4ht/ChangeLog @@ -1,5 +1,8 @@ 2021-12-20 Michal Hoftich + * tex4ht-4ht.tex (biblatex.4ht): added support for back links. + https://github.com/michal-h21/make4ht/issues/58 + * tex4ht-4ht.tex (backref.4ht): removed spurious space. 2021-12-19 Michal Hoftich diff --git a/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex b/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex index 46fa29dc6cd..9acf761cb57 100644 --- a/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex +++ b/Master/texmf-dist/source/generic/tex4ht/tex4ht-4ht.tex @@ -1,4 +1,4 @@ -% $Id: tex4ht-4ht.tex 1036 2021-12-20 12:42:58Z michal_h21 $ +% $Id: tex4ht-4ht.tex 1037 2021-12-20 22:36:14Z michal_h21 $ % tex tex4ht-4ht or ht tex tex4ht-4ht % % Copyright 2009-2021 TeX Users Group @@ -1909,6 +1909,7 @@ and \''\Tg'. | | | + | \Hinput{biblatex} \endinput >>> \AddFile{6}{biblatex} @@ -2753,6 +2754,60 @@ they caused compilation error when the AUX file is loaded. {\egroup\EndP\HCode{}} >>> +Fix backlink support in BibLaTeX + +\<<< +\pend:defI\blx@backref{% + % prevent duplicate backlink on the same page + \ifcsdef{bk##1\thepage}{}{% + % insert link to the page + \html:addr\Link-{}{|\last:haddr}\EndLink% + % save link to the .xref file + \Tag{)Q##1\thepage}{|\last:haddr}% + % we need to save the link destination in .xref file + % too, otherwise \Link command would issue warning + \Tag{)Q|\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% +} + +>>> + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \SubSection{backref.4ht} diff --git a/Master/texmf-dist/tex/generic/tex4ht/biblatex.4ht b/Master/texmf-dist/tex/generic/tex4ht/biblatex.4ht index 2db5ba238ff..ee7346a4829 100644 --- a/Master/texmf-dist/tex/generic/tex4ht/biblatex.4ht +++ b/Master/texmf-dist/tex/generic/tex4ht/biblatex.4ht @@ -1,4 +1,4 @@ -% biblatex.4ht (2021-08-14-14:10), generated from tex4ht-4ht.tex +% biblatex.4ht (2021-12-20-14:48), generated from tex4ht-4ht.tex % Copyright 2007-2009 Eitan M. Gurari % Copyright 2009-2021 TeX Users Group % @@ -17,7 +17,7 @@ % % If you modify this program, changing the % version identification would be appreciated. -\immediate\write-1{version 2021-08-14-14:10} +\immediate\write-1{version 2021-12-20-14:48} \def\make:blx:ver#1.#2#3\relax{% %\ifdim#1pt< 3pt \xdef\blx:ver:no{2}\else\xdef\blx:ver:no{3}\fi% @@ -598,6 +598,56 @@ \@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 -- cgit v1.2.3