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.
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.
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”).