After converting keywords to References, search for keywords is much less useful

(Replying to myself!) After seeing your very useful Reference scripting example in (How) can I display References in my Board and Feed views? I’m wondering: could I use a script to process the Rich Text contents of my Task’s Details field (whenever it changes) in order to reproduce it with all References converted to their names? And then write the result out into a Text field? So eg. if Details contained the (rich) text:

Here is a [T] Kibana reference

then my script would convert it to:

Here is a Kibana reference

ie. is the Rich Text a dict that can be walked (via JS) to find all the References and replace them with their names?

If so then I could automatically maintain a read-only up-to-date non-Reference copy of the Details field, which would be fully searchable and the search results would show up with all the Reference names suitably highlighted: it would achieve my goal perfectly.