\frontmatter
As described in a related question, pandoc turns Markdown links such as
[TeX.SE](https://tex.stackexchange.com/)
into
\href{https://tex.stackexchange.com/}{TeX.SE}
However, in contrast to what is stated there, the current version of pandoc turns
# A section
Linking to [A section]
or
# A section {#a-section}
Linking to [A section](a-section)
both into
\hyperdef{}{a-section}{\section{A section}}\label{a-section}
Linking to \hyperref[a-section]{A section}
i.e. it uses \hyperref and not \href.
\mainmatter
I would like to change the formatting of the reference pandoc creates, preferably via my custom class custom.cls I tell pandoc to use (via documentclass: custom in the Markdown-document's YAML-Header). So I tried this:
\documentclass{scrartcl}
\usepackage{hyperref}
\let\orghyperref\hyperref
\renewcommand*{\hyperref}[2]{\orghyperref[#1]{\texttt{#2}}}
\begin{document}
\hyperdef{}{a-section}{\section{A section}}\label{a-section}
Linking to \hyperref[a-section]{A section}
\end{document}
which unfortunately renders the link as
Linking to a-section]A section
instead. What went wrong?