Function to parse through some text and replace each occurrence of words/substrings of interest with wrapped/"highlighted" text, e.g. foo to <em>foo</em>.
We'd want options to enable or prevent highlighting/wrapping partial words.
Some examples of how this might work:
"This is example text." | highlight(needle='example', html='<span class="highlight">')
→ "This is <span class="highlight">example</span> text."
"This is example text." | wrapWords(words=['this', 'example'], before='~', after='%', caseSensitive=false )
→ "~This% is ~example% text."
"This is example text; this is nifty." | wrap(needle=['this', 'ex'], before='~', after='%', caseSensitive=true )
→ "This is ~ex%ample text; ~this% is nifty."
Function to parse through some text and replace each occurrence of words/substrings of interest with wrapped/"highlighted" text, e.g.
foo
to<em>foo</em>
.We'd want options to enable or prevent highlighting/wrapping partial words.
Some examples of how this might work:
"This is example text." | highlight(needle='example', html='<span class="highlight">')
→"This is <span class="highlight">example</span> text."
"This is example text." | wrapWords(words=['this', 'example'], before='~', after='%', caseSensitive=false )
→"~This% is ~example% text."
"This is example text; this is nifty." | wrap(needle=['this', 'ex'], before='~', after='%', caseSensitive=true )
→"This is ~ex%ample text; ~this% is nifty."