I have this following code:
\documentclass[12pt]{article}
\usepackage{hyperref}
\usepackage{soul}
\usepackage{blindtext}
\begin{document}
\section{Introducton}
\label{sec:intro}
\blindtext{}
\section{Second Section}
\label{sec:second}
This \ul{sentence works with ``ul''}.
Reference without ``ul'': \nameref{sec:intro}
This does not work with ``ul'': \ul{\nameref{sec:intro}}.
\end{document}
In the document I'm working on, I'm trying to get a \nameref{} to be underlined using \ul{}, but it crashes it when I do (for some reason in this document it doesn't crash but just doesn't display). I'm using \ul{} because it supports line wrapping compared to \underline{}. I was wondering if anyone has a solution to this. Thanks.
Edit: This image is what the above code generates:

Attempt 1
I tried looking at similar questions and found this, and changed \ul{\nameref{sec:intro}} to \ul{{\nameref{sec:intro}}} by adding a set of brackets, but it only replaced the missing text with a black square, as you can see here:

Attempt 2
As per Robert's comment on this question, adding \soulregister\nameref7 below \usepackage{soul} made no difference for me on the first image.
Attempt 3
As per Ulrike Fischer's comment, (1st method) \ul{\mbox{\nameref{sec:intro}}} does get the text to show up but does not wrap text on the document this is for.
Attempt 4
As per Ulrike Fischer's comment, (2nd method) Using \underLine{\nameref{sec:intro}} with \usepackage{lua-ul} and running lualatex documentname instead of pdflatex documentname in Terminal worked for me, and does wrap lines for cross-referenced text.
\soulregister\nameref7– Robert Dec 28 '21 at 15:29\usepackage{soul}) – Robert Dec 28 '21 at 15:35\ul{\mbox{\nameref{sec:intro}}}, or use lualatex and the lua-ul package instead of soul. – Ulrike Fischer Dec 28 '21 at 15:45