Spurious “.pdf” added to the first argument of `\href` if inside `\ExplSyntaxOn`/`\ExplSyntaxOff`
dbitouze opened this issue · 2 comments
A spurious “.pdf” is added to the URL given in the first argument of \href
if (and only if, AFAICS) the latter is used inside \ExplSyntaxOn
/\ExplSyntaxOff
.
This issue has been discussed here. egreg gave an answer, basically by making the \hyper@normalise
function applied by \href
aware that :
might have a different category code:
\begingroup
\makeatletter
\endlinechar=-1 %
\catcode`\^^A=14 %
\catcode`\^^M\active
\catcode`\%\active
\catcode`\#\active
\catcode`\_\active
\catcode`\$\active
\catcode`\&\active
\gdef\hyper@normalise{^^A
\begingroup
\@makeother{:}^^A THIS WAS MISSING
\catcode`\^^M\active
\def^^M{ }^^A
\catcode`\%\active
\let%\@percentchar
\let\%\@percentchar
\catcode`\#\active
\def#{\hyper@hash}^^A
\def\#{\hyper@hash}^^A
\@makeother\&^^A
\edef&{\string&}^^A
\edef\&{\string&}^^A
\edef\textunderscore{\string_}^^A
\let\_\textunderscore
\catcode`\_\active
\let_\textunderscore
\let~\hyper@tilde
\let\~\hyper@tilde
\let\textasciitilde\hyper@tilde
\let\\\@backslashchar
\edef${\string$}^^A
\Hy@safe@activestrue
\hyper@n@rmalise
}^^A
\endgroup
In the last comment of his own to his answer, he said that:
hyperref
has been amended to also have\@makeother\:
in\hyper@normalise
; it will be in TeX Live 2016.
But, AFAICS, this is not the case anymore since the 1st link of the following MCE is still wrong:
\documentclass{article}
\usepackage{hyperref}
% \begingroup
% \makeatletter
% \endlinechar=-1 %
% \catcode`\^^A=14 %
% \catcode`\^^M\active
% \catcode`\%\active
% \catcode`\#\active
% \catcode`\_\active
% \catcode`\$\active
% \catcode`\&\active
% \gdef\hyper@normalise{^^A
% \begingroup
% \@makeother{:}^^A THIS WAS MISSING
% \catcode`\^^M\active
% \def^^M{ }^^A
% \catcode`\%\active
% \let%\@percentchar
% \let\%\@percentchar
% \catcode`\#\active
% \def#{\hyper@hash}^^A
% \def\#{\hyper@hash}^^A
% \@makeother\&^^A
% \edef&{\string&}^^A
% \edef\&{\string&}^^A
% \edef\textunderscore{\string_}^^A
% \let\_\textunderscore
% \catcode`\_\active
% \let_\textunderscore
% \let~\hyper@tilde
% \let\~\hyper@tilde
% \let\textasciitilde\hyper@tilde
% \let\\\@backslashchar
% \edef${\string$}^^A
% \Hy@safe@activestrue
% \hyper@n@rmalise
% }^^A
% \endgroup
\begin{document}
\section{Inside ``ExplSyntax'' (NOT okay)}
\ExplSyntaxOn
\href{http://www.ctan.org/pkg/foo}{foo}
~$\rightarrow$~\url{http://www.ctan.org/pkg/foo.pdf}
\ExplSyntaxOff
\section{Outside ``ExplSyntax'' (okay)}
\href{http://www.ctan.org/pkg/foo}{foo}
~$\rightarrow$~\url{http://www.ctan.org/pkg/foo}
\end{document}
I can't find any indication that this was ever added to hyperref but it seems to work, so I added it in develop.
resolved in 7.01i, uploaded to ctan.