Skip to content

[FR] highlight/wrap function #16

@michaelrog

Description

@michaelrog

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."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions