[tex4ht-commits] [SCM] tex4ht updated: r1037 - trunk/lit

Michal Hoftich INVALID.NOREPLY at gnu.org.ua
Mon Dec 20 23:36:14 CET 2021


Author: michal_h21
Date: 2021-12-20 22:36:14 +0000 (Mon, 20 Dec 2021)
New Revision: 1037

Modified:
   trunk/lit/ChangeLog
   trunk/lit/tex4ht-4ht.tex
Log:
added backlink support for biblatex

Modified: trunk/lit/ChangeLog
===================================================================
--- trunk/lit/ChangeLog	2021-12-20 12:42:58 UTC (rev 1036)
+++ trunk/lit/ChangeLog	2021-12-20 22:36:14 UTC (rev 1037)
@@ -1,5 +1,8 @@
 2021-12-20  Michal Hoftich  <michal.h21 at gmail.com>
 
+	* 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  <michal.h21 at gmail.com>

Modified: trunk/lit/tex4ht-4ht.tex
===================================================================
--- trunk/lit/tex4ht-4ht.tex	2021-12-20 12:42:58 UTC (rev 1036)
+++ trunk/lit/tex4ht-4ht.tex	2021-12-20 22:36:14 UTC (rev 1037)
@@ -1909,6 +1909,7 @@
    |<shared config biblatex|>
    |<biblatex-crosslinking|>
    |<biblatex AtEndPreamble|>
+   |<biblatex backlinks|>
 \Hinput{biblatex}
 \endinput
 >>>        \AddFile{6}{biblatex}
@@ -2753,6 +2754,60 @@
    {\egroup\EndP\HCode{</dt><dd\Hnewline class="description">}}
 >>>
 
+Fix backlink support in BibLaTeX
+
+\<biblatex backlinks\><<<
+\pend:defI\blx at backref{%
+  % prevent duplicate backlink on the same page
+  \ifcsdef{bk##1\thepage}{}{%
+    % insert link to the page
+    \html:addr\Link-{}{|<haddr prefix|>\last:haddr}\EndLink%
+    % save link to the .xref file
+    \Tag{)Q##1\thepage}{|<haddr prefix|>\last:haddr}%
+    % we need to save the link destination in .xref file
+    % too, otherwise \Link command would issue warning
+    \Tag{)Q|<haddr prefix|>\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 at field@entrykey#2}{%
+      \Link{\LikeRef{)Q\abx at 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 at 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}
 



More information about the tex4ht-commits mailing list.