Hi Erik,
it’s a good idea but I think it could be very intensive for performance.. now with a regular expression I search for highlight text but only in the truncated string that is a “small” portion of text. Imagine that the content is very long, the reg-ex could be hard and time consuming.. this could give you back the search result items after seconds..
I’m thinking if the is a quick solution..
I am very curious what you’ll come up with 🙂
If slow performance would be the result, it may be better to utulize the Excerpt field of posts/pages:

…instead of showing the first lines of (main) Content in the search results. Which could be plagued with shortcodes and troublesome HTML code like:

Again, I am curious about your take on this!
Hi Erik! Your solution is the great one! If you content contains many markup, shortcodes, etc.. it could be a better way to use the excerpt and show it! In this way you provide a first “summary” with a thin and useful text (without bad tags), and clicking on it you can go to the article details and see the complete post content with HTML and SHORTCODES..
For me is a very good solution! You maximize the control of what to see in the results..
Bye