I don't know if already exists a question like this, but after 20 minutes I haven't found one. There are similar ones, like How to define a command that bolds the first letter of each word in the ...
I wrote a little piece of code (function \getfirst:w) that splits its delimited argument at the first embedded :. The code works well if used standalone, but I am unable to place it into the .code:n ...
Tex has powerful support for extensions triggered by events happen in generating output, by running one of six token lists appropriately: \everycr \everydisplay \everyhbox \everymath \everypar ...