I'm attempting to adapt Segletes's Revised Solution in List of Underlining Packages - Pros and Cons that employs alexwlchan's Four ways to underline text in LATEX in order to re-create alexwlchan's 'really nice underline' macro that also wraps at the end of the line.
I found that Segletes's rendition of the \xblackout macro works nicely to create alexwlchan's version of the 'really nice underline' macro that also wraps at the end of the line. Nice.
I've been able to apply Segletes's revised \xblackout macro to a few different text styles, but I'm having trouble applying it to the Glossary \gls macro, as in \xblackout{\gls[hyper=true]{LED}}.
I've included an MWE that essentially duplicates Segletes's MWE that appears in the List of Underlining Packages - Pros and Cons with the necessary code added to implement a Glossary. The next-to-last line of code in the MWE: \xblackout{\gls[hyper=true]{LED}} is where the LaTeX error Missing \endcsname inserted. occurs.
Note: I've essentially left all of Segletes Revised Solution in the MWE intact as a way to show that his code works, except for my next-to-last line of code for the glossary where the only LaTeX error occurs.
Any help would be greatly appreciated. Thanks in advance.
% Adapted from Steven B. Segletes post on Aug 1, 2013 at 12:51:
% "List of Underlining Packages - Pros and Cons"
% at https://tex.stackexchange.com/questions/126291/list-of-underlining-packages-pros-and-cons
% Adapted from alexwlchan's "Four ways to underline text in LATEX"
% at https://alexwlchan.net/2017/10/latex-underlines/
\documentclass{article}
\usepackage[none]{hyphenat}
\usepackage{censor}
\usepackage{xcolor}
\usepackage{stackengine}
\usepackage{scalerel,lipsum}
% Added
\usepackage{ulem}
\usepackage{glossaries}
\makeglossaries
\censorruledepth=-.25ex
\censorruleheight=.1ex
\newlength\maxkern
\setlength{\maxkern}{.14ex}
\newlength\nextcharwidth
\makeatletter
\renewcommand@cenword[1]{%
\setlength{\nextcharwidth}{\widthof{#1}}%
\censorrule{\nextcharwidth}%
\kern -\nextcharwidth%
\color{white}%
\kern -.5\maxkern #1\kern .5\maxkern%
\kern -\nextcharwidth%
\kern -\maxkern #1\kern \maxkern%
\kern -\nextcharwidth%
\kern .5\maxkern #1\kern -.5\maxkern%
\kern -\nextcharwidth%
\kern \maxkern #1\kern -\maxkern%
\kern -\nextcharwidth%
\color{black}%
#1}
\let\sv@cenword@cenword
\newcommand\m@cenword[1]{\ThisStyle{%
\stackengine{\mcensorruledepth}{$\SavedStyle#1$}%
{\rule{\widthof{$\SavedStyle#1$}}{\the\censorruleheight}}{U}{c}{F}{T}{L}}}
\newcommand\mblackout[2][\dp\strutbox]{%
\let@cenword\m@cenword%
\def\mcensorruledepth{#1}%
\blackout{#2}%
\let@cenword\sv@cenword%
}
\newcommand\mcensor[2][\dp\strutbox]{%
\let@cenword\m@cenword%
\def\mcensorruledepth{#1}%
\censor{#2}%
\let@cenword\sv@cenword%
}
\makeatother
% Added
\newglossaryentry{LED}
{
name={LED},
description={light emitting diode},
first={\glsentrydesc{LED} (\glsentrytext{LED})},
plural={LEDs},
descriptionplural={light emitting diodes},
firstplural={\glsentrydescplural{LED} (\glsentryplural{LED})}
}
\begin{document}
\blackout{This is a great test today}
{\raggedright\xblackout{This is a great test today}}
% Modified
[ \mblackout{y = A x^2} + Bx + \mblackout{C} ]
% [ \mblackout{y = A x^{2}} + Bx + \mblackout{C} ]
% Modified
[ \mblackout[.3ex]{y = \frac{a^3 + b^2 + c}{d_3}}]
% [ \mblackout[.3ex]{y = \frac{a^{3} + b^{2} + c}{d_{3}}}]
[ \mcensor[3ex]{y = \frac{a^{3} + b^{2} + c}{d_{3}}}]
\xblackout{Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel
justo vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In hac habitasse platea dictumst.
Integer tempus convallis augue. Etiam facilisis. Nunc elementum
fermentum wisi. Aenean placerat. Ut imperdiet, enim sed gravida sollicitudin, felis odio placerat quam, ac pulvinar elit purus
eget enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.
Vivamus quis tortor vitae risus porta vehicula.} \par \vspace{1cm}
% Added
\uline{\gls[hyper=true]{LED}} \par \vspace{1cm}
\uline{\gls[hyper=true]{LED}} \par \vspace{1cm}
% Error: Missing \endcsname inserted.
\xblackout{\gls[hyper=true]{LED}}
\end{document}

\glsnor\xblackoutare expandable, so this poses a big hurdle. – Steven B. Segletes Aug 23 '23 at 21:09\glsentrytextby way of\expandafter\xblackout\expandafter{\expanded{\glsentrytext{LED}}}. However, any hyperlinks would be lost by\glsentrytext. – Steven B. Segletes Aug 23 '23 at 21:16