Highlight text Theme Component

AI-generated summary

sbernhard introduced the “Highlight Text” theme component for Discourse, which uses mark.js to automatically highlight specified brand terms or regex patterns in posts, using the theme’s quaternary color. The component is configurable via theme settings for case sensitivity, single words, or regex (e.g., \sdiscourse\s), and includes a preview and repo. After merefield requested clearer usage examples, sbernhard updated the OP with an example. merefield and neounix praised the component’s utility and simplicity, with neounix noting that “small things” like this can be highly valuable and educational for theme developers. sbernhard acknowledged the feedback, emphasizing its usefulness for highlighting brand names.

Screenshot

Repo

discourse-highlight-text

About

Add some common brand terms on your forum to the theme settings, and they will get highlighted in every post.
Uses https://markjs.io/ to highlight text in discourse. Supports mark() and markRegExp() methods. The ‘quaternary’ theme color (discourse → customize → colors) is used to highlight the text.

Installation

How do I install a Theme or Theme Component?

Preview

Configuration

Configure the theme component in its settings. Set if you want to mark a single word or if you prefer to set a regular expression for selecting the text. It’s also possible to specify if case (in)-sensitive.

Example regular expression: [\s]discourse[\s] (See above screenshot and the highlighted word “discourse”).

Thanks

Thank you, https://markjs.io/

3 Likes

Might be a good idea if you could add some simple instructions & example on how to use to the OP?

The example is in the settings. I can add a example if you insist.

Don’t insist, but maybe I’m being slow this morning but wasn’t clear to me how to exploit. :thinking:

An example would really help I think. What does the post look like to generate this screenshot?

1 Like

Thanks for the feedback. See changed first post.

2 Likes

Great! What an interesting option. Thanks for making!

2 Likes

@sbernhard

This kind of “utility” theme components are really useful.

Thanks for making and sharing.

1 Like

Its just a small thing but to highlight the brand name e.g. can be useful. Thanks for the feedback.

1 Like

“Small things” are sometimes the best things.

Plus, some of us can learn from your theme components easily, since they are “simple” :). “Simplicity” is. a kind of zen… good job!

Looking forward to your next one!

1 Like