samcarter
### Preface:
*I don't actually need a solution, this question is more out of curiosity and because a sprained ankle keeps me bound to the couch for the day ... Please only invest time if you find this interesting yourself.*
----
Is there any underline/highlight macro which acts like a switch and will underline/highlight all the text until the end of the current group? In the following mock-up code, I'm using lua-ul, but any other package or solution would also be fine.
Mock-up:
```
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage{lua-ul}
\usepackage{luacolor}
\begin{document}
\highLight{A very long text which spans more then one line and might have paragraph breaks.
Like this new paragraph.}
{\magic A very long text which spans more then one line and might have paragraph breaks.
Like this new paragraph.}
\end{document}
```
I checked the usual suspects, like `lua-ul` or `soul`, but could only find macros with an argument.
----
### Background story:
I recently came across a beamer question in which the OP wanted to censor not yet uncovered text, which would be very doable if there were a switch, like the `\bfseries` in the example below:
```
\documentclass{beamer}
\usepackage{lipsum}
\setbeamercovered{transparent}
\makeatletter
\patchcmd{\beamer@startcovered}{\color{.}}{\color{.}\bfseries}{}{}
\makeatother
\begin{document}
\begin{frame}
\pause
\lipsum[2]
\end{frame}
\end{document}
```
The closes thing I found was replacing all characters with blocks, but this changes the width of the "letters" and thus can look jumpy when switching between slides: https://tex.stackexchange.com/revisions/696018/3
Top Answer
Skillmon
Looking at the internals of `lua-ul` this becomes quite easy. The following is the definition of `\highLight`:
```
\NewDocumentCommand \highLight {O{\l__luaul_highlight_color_tl} +m} {
\group_begin:
\@highLight [#1] #2
\group_end:
}
```
One educated guess later, we simply drop the `\group_begin:` and `\group_end:` and are done:
```
\documentclass{article}
\usepackage{lua-ul}
\usepackage{luacolor}
\ExplSyntaxOn
\makeatletter
\NewDocumentCommand \magic {O{\l__luaul_highlight_color_tl}} {
\@highLight [#1]
}
\makeatother
\ExplSyntaxOff
\begin{document}
\highLight{A very long text which spans more then one line and might have paragraph breaks.
Like this new paragraph.}
{\magic A very long text which spans more then one line and might have paragraph breaks.
Like this new paragraph.}
\end{document}
```
Actually we could also just give a public name to `\@highLight`: `\NewCommandCopy\magic\@highLight` and you're done.