My team has come to conclusion that in order to highlight certain text we will use !!! as special symbol. Long story.
I love !!!JavaScript and jQuery!!!.
should get transformed into
I love <span class='hl'>JavaScript and jQuery</span>.
Do not worry about the edge cases. We are developing a system for school children and they don’t have complex text with lots of bangs.
How do I do that?
Bonus question: After the span is applied then I was going to use jQuery higlighter plugin to highlight that code. Any suggestion in that direction.
replacein Javascript only replaces the first occurrence of a string, so you can put this feature to good use and do this:Output:
I love <span class="hl">Javascript and jQuery</span>. Ya, <span class="hl">jQuery</span> rocks!