0

I want to let \url breaks on hyphens '-'. url package has hyphens option but if there are several hyphens in url luatex turnes them to ligatures and latex doesn't. I can't find how to suppress "--", "---" ligatures creation in url using normal font. I tried to edit \UrlBreaks, \UrlOrds, \verbatim@nolig@list by adding/removing \do\- but then I get other buggy results.

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage[hyphens]{url}

% \def\UrlBreaks{\do.\do@\do\\do/\do!\do_\do|\do;\do>\do]% % \do)\do,\do?\do&\do'\do+\do=\do#% % \do- % tried to add it here % }

% original macro from url has two \do\-. Why? % \def\UrlOrds{\do* % \do- % \do~\do'\do" % \do- % }%

% it seems that this should do the trick, but it does'nt? %\makeatletter %\def\verbatim@nolig@list{\do`\do<\do>\do,\do'\do-} %\makeatother

\def\UrlFont{}%\ttfamily}

\fboxsep=0pt \parindent=0pt

\begin{document}

\par\url{-} \par\url{--} \par\url{---}

\fbox{\parbox[t]{3cm}{ \par\url{11111111111111-aaaaaaaa} \par\url{11111111111111--aaaaaaa} \par\url{11111111111111---aaaaaa} }}

\end{document}

latex output:

enter image description here

lualatex output:

enter image description here

I use TL2019 and dvilualatex (dvi mode is a requirement)

Linuxss
  • 957

1 Answers1

0

Here is the solution I came up with. I made - an active character which inserts math character and \penalty\UrlBreakPenalty. Now luatex doesn't creates ndash/mdash and breaks links on -.

\documentclass{article}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage[hyphens]{url}

\AtBeginDocument{% \appto\UrlSpecials{\do-{\mathchar 0045\penalty \UrlBreakPenalty}}% }

\def\UrlFont{}

\begin{document} \fboxsep=0pt \parindent=0pt \par\url{-} \par\url{--} \par\url{---}

\fbox{\parbox[t]{3cm}{ \par\url{11111111111111-aaaaaaaa} \par\url{11111111111111--aaaaaaa} \par\url{11111111111111---aaaaaa} }} \end{document}

enter image description here

Linuxss
  • 957