I'm parsing user HTML to LaTeX templates. The HTML comes from a rich text editor, so of course the incoming HTML syntax can be almost anything. There's one case that breaks LaTeX that I have to handle.
<u><a href="http://www.google.com">text</a></u>
This HTML, which I do not control, is parsed by a neutral parser into LaTeX templates. It might become something like:
\ul{\url{http://www.google.com}}
Due to the nature of the input, and the nature of the parser, I must assume I have some sort of underline tag wrapping some sort of link tag. This is a required constraint for answering this question. I do not have direct control over the input, and the parser is neutral. I can control what the parser outputs per per tag, such as <u>
input can be compiled into \uline
, but I cannot change the structure of the AST.
See what happens when I include the ulem package and wrap the link with \uline
:
\usepackage{ulem}
Text: \uline{\url{http://test.com/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/}}
Now the link is underlined, but does not wrap:
This is despite the ulem documentation saying "Unlike regular underlining, ulem allows line breaks".
I have also tried using the soul package and the \ul
command:
\usepackage{soul}
Text: \ul{\url{http://test.com/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/uline-text/}}
Which chokes with the error:
! Argument of \hyper@n@rmalise has an extra }.
l.9 ...ne-text/uline-text/uline-text/uline-text/}}
I do not directly control the creation of the LaTeX source code, so I cannot directly modify the order of the tags. Please read this question carefully before voting. I am not asking how to underline a link tag.
\UrlFont
to be\uline
? Or put\url{\uline{http://longcatislong.long}}
or similar?\uline
lies: Text: \uline{test.com/uline-text/uline-text/uline-text/uline-text/uline-text/…} fails, too\-
to suggest linebreaks seems to help ....