This is a follow-up question to this one. There, a method is described how to "escape underscores". I would like to use that to put hyperlinks into the margin.
As you can see, with a very long link text, this overflows and doesn't break.
I would like it to break without inserting dashes. I tried \linebreak but that messes up the link URL.
MWE:
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
% <https://tex.stackexchange.com/a/20892>
\makeatletter
\DeclareRobustCommand*{\escapeus}[1]{%
\begingroup\@activeus\scantokens{#1\endinput}\endgroup}
\begingroup\lccode`\~=`\_\relax
\lowercase{\endgroup\def\@activeus{\catcode`\_=\active \let~\_}}
\newcommand\thyrefdist[1]{\marginpar{\href{https://some.web.site/#1.html}{\texttt{\escapeus{#1}}}}}
%opening
\title{}
\author{}
\begin{document}
\maketitle
\begin{abstract}
\end{abstract}
Test\thyrefdist{Very_Long_Text_That_Does_Not_Wrap}
\end{document}


httpsand.htmlyou could have had simply\marginpar{\url{#1}}– David Carlisle Oct 19 '18 at 12:01