I want to truncate (cut/shorten) a string that contains newline (\\ or \newline) in such a way that only the first line remains.
My problem is, that I use the todonotes package and have command wrapped around the normal \todo. Here is a minimal working example: (my actual command is more complex)
\newcommand{\TODO}[2]{\todo[#1,inline, caption={#2}]{#2}} The problem is, that I might call that function with something that contains a newline. This will fail while setting the caption. Also, it is a bad idea to have a multi-line caption.
\TODO{foo \\ bar} Therefore I want to truncate the string first. I tried the xstring package, but I can not find anything on how to do it for newline (\\ or \newline). I could use xstring to cut the string after x characters, but I do not know how soon the \\ will happen.

caption={\zz#2\\\relax}works were\zzis defined by\def\zz#1\\#2\relax{#1}