Outline

hyperref

Ask hyperref to load

  1. A cut-down version of hyperref.sty in which the modifications to LaTeX commands are removed.
  2. The ‘hypertex.def’ file with the ‘\special{htm:...}’ commands being replaced by TeX4ht-oriented commands of the form ‘\special{t4ht=...}’.

    This will not work for documents broken into pages!! The \Link command should be used for the specials.

manual, msg02358, msg02400

<..hyperref.4ht..>
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % hyperref.4ht                          2014-07-12-22:36 %
 % Copyright (C) 1999--2009       Eitan M. Gurari         %
 <.TeX4ht copyright.>
 \csname end:hyperref\endcsname
 <.nameref.sty.>
 <.ifHy@texht undefined?.>
 <.post 2001 late hyperrref.>
 <.autoref 2008.>
 <.tex4ht option on hyperrref.>
 <.hyperref utils.>
 <.hyperref 2011-01-30.>
 <.config hyperref.>
 <.htex4ht.def.>
 \expandafter\ifx\csname ifHy@hyperindex\endcsname\relax
 \else \Hy@hyperindexfalse
 \fi
 \Hinput{hyperref}
 \endinput
 -_-_-

The following modification became necessary consequent to the bug report filed by Alex Ball �[email protected]�. The bug was that hyperref.4ht failed consequent to the combination of memoir + hyperref deal with section headings that are below the numbering threshold as set by secnumdepth. Alex vouched that the fix worked fine with his documents.

<..hyperref 2011-01-30..>
 \def\Hy@MakeCurrentHref#1{%
   \edef\HyperLocalCurrentHref{#1}%
   \@onelevel@sanitize\HyperLocalCurrentHref
   \global\let\HyperGlobalCurrentHref\HyperLocalCurrentHref
   \let\HyperLocalCurrentHref\HyperGlobalCurrentHref
   \ifHy@localanchorname
     \let\@currentHref\HyperLocalCurrentHref
   \else
     \global\let\@currentHref\HyperGlobalCurrentHref
   \fi
 }
 
 \let\Hy@SectionAnchorHref\@gobble
 \newlength\Hy@SectionHShift
 
 \def\Hy@MakeCurrentHrefAuto#1{%
   \Hy@GlobalStepCount\Hy@linkcounter
   \Hy@MakeCurrentHref{#1.\the\Hy@linkcounter}%
 }
 -_-_-

<..config hyperref..>
 \def\hyper@makecurrent#1{%
   \begingroup
     \edef\Hy@param{#1}%
     \ifx\Hy@param\Hy@chapterstring
       \let\Hy@param\Hy@chapapp
     \fi
     \ifHy@hypertexnames
       \let\@number\@firstofone
       \@ifundefined{latin@Alph}{}{%
         \ifx\@Alph\greek@Alph
           \def\@Alph{Alph\@arabic}%
         \fi
       }%
       \ifHy@naturalnames
         \let\textlatin\@firstofone
         \xdef\@currentHlabel{\csname the#1\endcsname}%
       \else
         \xdef\@currentHlabel{\csname theH#1\endcsname}%
       \fi
       \xdef\@currentHref{%
         \Hy@param.\expandafter\strip@prefix\meaning\@currentHlabel
       }%
     \else
       \Hy@GlobalStepCount\Hy@linkcounter
       \xdef\@currentHref{\Hy@param.\the\Hy@linkcounter}%
     \fi
   \endgroup
 }
 -_-_-

<..hyperref utils..>
 \ifx \@@wrindex\:UnDef \else
    \def\@@wrindex#1|#2|#3\\{%
      \protected@write\@indexfile{}{\string\indexentry{#1}{\thepage}}%
      \endgroup \@esphack
    }
 \fi
 \ifx \HyInd@@wrindex\:UnDef \else
    \def\HyInd@@wrindex#1#2|#3|#4\\{\HyInd@org@wrindex{#1}{#2}}%
 \fi
 \ifx \Hy@RestoreLastskip\:UnDef
    \let\Hy@RestoreLastskip\relax
 \fi
 -_-_-

<..config hyperref..>+
 \def\hyper@natlinkend{%
   \hyper@linkend
 }
 -_-_-

<..htex4ht.def..>
 \def\hyper@linkstart#1#2{%
   \expandafter\Hy@colorlink\expandafter{\csname @#1color\endcsname}%
   \def\Hy@tempa{#1}%
   \ifx\Hy@tempa\@urltype
     \Link[#2]{}{}%
   \else
     {\hyper@chars\ifx\rel:hyper\def\Link{#2}{}\else\Link[\##2]{}{}\fi}%
   \fi  \global\let\rel:hyper=\:UnDef
 }
 \def\hyper@linkend{%
   \EndLink
   \Hy@endcolorlink
 }
 -_-_-

<..htex4ht.def..>+
 \def\hyper@anchorstart#1{%
   \Hy@SaveLastskip
   \begingroup
     \hyper@chars\Link{}{#1}%
   \endgroup
   \Hy@activeanchortrue
 }
 \def\hyper@anchorend{%
   \EndLink
   \Hy@activeanchorfalse
   \Hy@RestoreLastskip
 }
 \def\hyper@anchor#1{\hyper@anchorstart{#1}\hyper@anchorend}
 -_-_-

<..config hyperref..>+
 \def\hyper@linkurl#1#2{%
   \leavevmode  \begingroup    \hyper@chars
    \ifx \hyper:normalise\:UnDef
       \expandafter\pend:defI\expandafter\:autoref
                             \expandafter{\HyRef@currentHtag}%
       \let\HyRef@currentHtag\empty
       \Hy@colorlink{\@urlcolor}#1\Hy@endcolorlink
     \else
       \Link[#2]{}{}\Hy@colorlink{\@urlcolor}#1\Hy@endcolorlink\EndLink
       \global\let\hyper:normalise=\:UnDef
     \fi
   \endgroup }
 \AtBeginDocument{%
 %  \pend:defI\hyper@normalise{\let\hyper:normalise=\def}%
   \expandafter\pend:def\csname hyperref
                      \endcsname{\let\hyper:normalise\def}%
   \expandafter\pend:def\csname href \endcsname{\let\hyper:normalise\def}%
   \pend:defI\T@ref{\edef\RefArg{##1}}}
 -_-_-

When ‘\pend:defI\hyper@normalise{\let\hyper:normalise|=\def}%’ is needed? It breaks code like the following one.

\documentclass{article} 
  \usepackage{hyperref} 
\begin{document} 
  \url{http://thisdomain.org} 
\end{document} 

\XR@ext get its value from the the ‘\usepackage’ option: dvi—default; html—tex4ht; pdf—hpdftex, dvipdfm, pdfmark, dvips, vtex, dvipsone, textures; htm—vtex.

<..tex4ht option on hyperrref..>
 \expandafter\ifx \csname H@item\endcsname\relax
    \def\:temp{dvi}\ifx \XR@ext\:temp \else
      \def\:temp{html}\ifx \XR@ext\:temp \else
          \:warning{\string\usepackage[...]{hyperref} assumes ‘\XR@ext’
               option, not ‘tex4ht’}
    \fi\fi
 \else
       \:warning{\string\usepackage[...]{hyperref} assumes ‘\XR@ext’
            option, not ‘tex4ht’}
 \fi
 -_-_-

Check ‘\zap@space#2 \@empty’ for removing spaces

ifHy@texht might be undefined, or defined with lowercase character (in earlier versions).

<..ifHy@texht undefined?..>
 \expandafter\ifx \csname ifHy@texht\endcsname\relax
    \expand:after{\expandafter
       \let \csname ifHy@texht\endcsname=}\csname ifhy@texht\endcsname
 \fi
 \expandafter\ifx \csname ifHy@texht\endcsname\relax
    \expand:after{\expandafter
       \let \csname ifHy@texht\endcsname=}\csname iffalse\endcsname
 \fi
 \ifHy@texht \else
     \:warning{tex4ht loaded after hyperref}
     \csname Hy@texhttrue\endcsname
 \fi
 -_-_-

The following is to take care of \newlabel of hyperef, which requires 5 fields instead of 2.

<..hyperref label..>
 \ifx \prf:label\:UnDef \else \prf:label\fi
 -_-_-

<..config hyperref..>+
 \def\label@hyperref[#1]#2{{%
    \def\hyperrefLabel{#2}%
    \Configure{ref}
      {\Link}{\EndLink}{\Configure{ref}{}{}{}#2}\ref{#1}}}
 <.autoref references.>
 <.restore pre hyperref.>
 <.nameref.sty NOT HERE.>
 \csname ReadBookmarks\endcsname
 -_-_-

A \def\@@hyperref#1#2#3{\Link[#2]{}{}#1\EndLink} got removed since it fails the second case below.

   \href{test2.xml}{link made with href} 
   \hyperref{test2.xml}{a}{b}{link made with hyperref} 

The nameref offers ‘\def\strip@period#1.\relax#2\@@@{#1}’ to subfigure.

<..restore pre hyperref..>
 \ifx \H@equation\:UnDef \else
    \let\o:equation:\H@equation
 \fi
 \ifx \H@endequation\:UnDef \else
    \let\o:endequation:\H@endequation
 \fi
 \ifx \H@eqnarray\:UnDef \else
    \let\o:eqnarray:\H@eqnarray
 \fi
 \ifx \H@endsubeqnarray\:UnDef \else
    \let\o:endsubeqnarray:\H@endsubeqnarray
 \fi
 \ifx \H@subeqnarray\:UnDef \else
    \let\o:subeqnarray:\H@subeqnarray
 \fi
 \ifx \H@endsubeqnarray\:UnDef \else
    \let\o:endsubeqnarray:\H@endsubeqnarray
 \fi
 -_-_-

<..nameref.sty..>
 \@ifpackageloaded{nameref}{}
 {
    \let\sv:label\label
    \RequirePackage{nameref}%
    \let\label\sv:label
    \input nameref.4ht
 }
 -_-_-

<..nameref moved from old hyperref..>
 \def\tht:label#1{%
   \@bsphack
   \begingroup
     \@onelevel@sanitize\@currentlabelname
     \edef\@currentlabelname{%
       \expandafter\strip@period\@currentlabelname.\relax\@@@%
     }%
 %   \typeout{::::::::::::[\@currentlabelname]::::::::::::}%
     \protected@write\@auxout{}{%
       \string\newlabel{#1}{%
         {\string\rEfLiNK{\cur:th\:currentlabel}
            {\string\csname\space :autoref\string\endcsname
              {\@@currentlabelname}\@currentlabel}%
         }%
         {\thepage}%
         {\a:newlabel\@currentlabelname}%
         {\@@currentlabelname.\@currentlabel}{}%
       }%
     }%
   \endgroup
   \@esphack
 }%
 
 \HLet\label\tht:label
 
 \Configure{newlabel}
    {\cur:th \:currentlabel}
    {\string\csname\space%\string\string\space
     :autoref\string\endcsname {\@currentlabelname}#1}
 
 \ifx \@@currentlabelname\:UnDef
    \let\@@currentlabelname\empty
 \fi
 \append:defI\refstepcounter{\def\@@currentlabelname{#1}}
 \pend:def\eqnarray{\edef\@@currentlabelname{equation}}
 \pend:def\equation{\edef\@@currentlabelname{equation}}
 \pend:defI\section{\edef\@@currentlabelname{section}}
 \pend:defI\subsection{\edef\@@currentlabelname{section}}
 \pend:defI\subsubsection{\edef\@@currentlabelname{section}}
 
 \ifx \figure\:UnDef \else
   \pend:def\figure{\edef\@@currentlabelname{figure}}
   \expandafter\pend:def\csname
      figure*\endcsname{\edef\@@currentlabelname{figure}}
 \fi
 \ifx \table\:UnDef \else
   \pend:def\table{\edef\@@currentlabelname{table}}
   \expandafter\pend:def\csname
      table*\endcsname{\edef\@@currentlabelname{table}}
 \fi
 \pend:defII\:thm{\edef\@@currentlabelname{##1}}
 -_-_-

The following should be offered in nameref.4ht.  
 \ifx \part\:UnDef \else
    \def\:temp#1->#2//{#1}
    \def\:tempc#1{}
    \edef\:tempc{\expandafter\:temp\meaning\:tempc//}
    \edef\:temp{\expandafter\:temp\meaning\part//}
    \ifx \:temp\:tempc
       \pend:defI\part{\def\@currentlabelname{part}}
 \fi\fi
 \ifx \chapter\:UnDef \else
    \let\NR:chapter\@chapter
    \def\@chapter[#1]#2{%
      <.adjust minipageNum for setcounter footnote 0.>%
      \def\@currentlabelname{\ch:autorefname}%
      \NR:chapter[{#1}]{#2}%
    }
    \let\NR:schapter\@schapter
    \def\@schapter#1{%
      \gdef\@currentlabelname{}%
      \NR:schapter{#1}%
    }
    \def\ch:autorefname{chapter}
    \let\hy:appendix\appendix
    \def\appendix{\def\ch:autorefname{appendix}\hy:appendix}
 \fi
 \let\NR:sect\no@sect
 \def\no@sect#1#2#3#4#5#6[#7]#8{%
   \xdef\@currentlabelname{\ifnum #2>\c@secnumdepth\else #1\fi}%
   \NR:sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{#8}%
 }
 \let\NR:ssect\no@ssect
 \def\no@ssect#1#2#3#4#5{%
   \gdef\@currentlabelname{}%
   \NR:ssect{#1}{#2}{#3}{#4}{#5}%
 } -_-_-

\documentclass{article} 
 \usepackage{hyperref} 
\begin{document} 
 \section{abc} 
 \label{foo} 
 
 autoref:  \csname autoref\endcsname{foo} 
 
 nameref:  \csname nameref\endcsname{foo} 
 
 ref: \ref{foo} 
\end{document} 

<..late hyperref..>
 \let\:temp=\real@setref
 \let\real@setref=\ref
 \let\ref=\o:ref
 \let\o:ref=\:temp
 -_-_-

<..hyperref utils..>+
 \def\hyperlink#1#2{\Link{#1}{}#2\EndLink}
 \def\hypertarget#1#2{\Link{}{#1}#2\EndLink}
 \ifx \hyperpage\:UnDef  \let\hyperpage=\empty  \fi
 -_-_-

<..config hyperref..>+
 \ifx \Hy@linkfileprefix\empty\else
    \:warning{\noexpand\href of hyperref.sty introduces the prefix
              ‘\Hy@linkfileprefix’ to prefix-free references.
              The command \string\hyperlinkfileprefix{...}
              may be used for changing the prefix (probably
              \string\hyperlinkfileprefix{}).}
 \fi
 -_-_-

<..config hyperref..>+
 \def\hyper@linkfile#1#2#3{\Link[#2]{#3}{}#1\EndLink}
 -_-_-

<..config hyperref..>+
 \def\phantomsection{%
  \Hy@GlobalStepCount\Hy@linkcounter
  \xdef\@currentHref{likesection.\the\Hy@linkcounter}%
  \Hy@raisedlink{\hyper@anchorstart{\@currentHref}\hyper@anchorend}%
 }
 -_-_-

The following fix is to hold hypertex from modifying the links in

\documentclass{article} 
  \usepackage{hyperref}  \hyperlinkfileprefix{} 
\begin{document} 
  \href{/somewhere/foo/}{look here} 
\end{document} 

<..config hyperref..>+
 \catcode‘\:=12
 \def\@hyper@readexternallink#1#2#3#4:#5:#6\\#7{%
       \hyper@linkurl{#3}{#7\ifx\\#2\\\else\##2\fi}}
 \catcode‘\:=11
 -_-_-