# How to replace text in the composer?

**URL:** https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526
**Category:** Development
**Created:** [August 1, 2020, 3:52pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526 "2020-08-01T15:52:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Newuser](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/newuser/32/184725_2.png) [@Newuser](https://meta.discourse.org/u/Newuser)
#### Post date: [August 1, 2020, 3:52pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/1 "2020-08-01T15:52:52Z")

</div>

Hi all,

I have a very simple question, but I can’t find the answer anywhere.  
I want to create custom BBcode without a closing tag, how do I do that?

Thanks to this topic I already figured out how to replace [something]something else[/something] with html code.

> [@Custom BBCode Help/Advice](https://meta.discourse.org/t/custom-bbcode-help-advice/84005):
>
> UPDATE: Figured it out! I’m trying to make make a plugin that makes a custom bbcode that maps [vote]name[/vote] to \<p\>\<span class="highlight"\>\<b\>VOTE:name\</b\>\</span\>\</p\> I’ve been reading the stuff in [this topic](https://meta.discourse.org/t/developers-guide-to-markdown-extensions/66023) along with going through the various bbcode plugin repos that exist, and If I’m understanding the examples correctly the only relevant nontrivial places I have to change would be the stuff after wrap here ruler.push('vote',{ tag: 'vote', wrap: }); and the stuff in squ…

But now I would like to find out how to just replace [something]. For instance, I would like to know how to replace [br] with \<br\>. Or just any substring (not containing a closing tag) with something else. I already looked at the source of the discourse-bbcode plugin, but every bbcode in that plugin has a closing tag.

Basically I am looking for something like this:

> [@(Superseded) Plugin Tutorial #1 - How to manipulate the text in the composer?](https://meta.discourse.org/t/plugin-tutorial-1-how-to-manipulate-the-text-in-the-composer/10925):
>
> information_source This topic has been superseded by [Developing Discourse Plugins - Part 1 - Create a basic plugin](https://meta.discourse.org/t/developing-discourse-plugins-part-1-create-a-basic-plugin/30515) So, you want to manipulate the text in the composer but have no idea how? Let met guide you through the creation of a basic plugin that will turn the text into [Pirate Speak](http://en.wikipedia.org/wiki/International_Talk_Like_a_Pirate_Day). tada Update August 2018: you can create a complete discourse plugin skeleton in your plugins directory with [Rails plugin generator](https://meta.discourse.org/t/rails-plugin-generator/95907) tada First of all, you need to create a plugin.rb file that will b…

But then something that still works.  
Can someone help me or point me in the right direction?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 2, 2020, 1:54am UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/2 "2020-08-02T01:54:33Z")

</div>

One feature request that keeps coming up is a “substitute / replace” section in Admin → Logs → Watched Words.

I still think we should do this @sam and @eviltrout though it could be a 2.7 or beyond thing.

---

<div class="post-metadata">

### Author: ![Newuser](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/newuser/32/184725_2.png) [@Newuser](https://meta.discourse.org/u/Newuser)
#### Post date: [August 2, 2020, 12:59pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/3 "2020-08-02T12:59:08Z")

</div>

> [@codinghorror](#):
>
> One feature request that keeps coming up is a “substitute / replace” section in Admin → Logs → Watched Words.

That would be really great, as long as the replacement allows HTML 😃

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 3, 2020, 1:23am UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/4 "2020-08-03T01:23:08Z")

</div>

For 2.7 I did slot linked words, we can surely add this as well while at it… will add to the release.

---

<div class="post-metadata">

### Author: ![jughead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jughead/32/184261_2.png) [@jughead](https://meta.discourse.org/u/jughead)
#### Post date: [June 3, 2021, 3:00pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/5 "2021-06-03T15:00:02Z")

</div>

I see this still hasn’t been done. Although the option to replace words was added under watched words, it does not allow to replace a word with HTML code. I need the ability to have certain words replaced by HTML.

Furthermore, if anyone else can point me to a resource to embed a piece of html in a single post, please let me know.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 3, 2021, 4:51pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/6 "2021-06-03T16:51:02Z")

</div>

You can replace words with other words, or you can replace word(s) with a link. Do this via Admin → Customize → Watched Words. That’s as of Discourse 2.7 and later.

But you can’t replace words with markup due to limitations in our rendering pipeline.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 3, 2021, 4:51pm UTC](https://meta.discourse.org/t/how-to-replace-text-in-the-composer/159526/7 "2021-06-03T16:51:06Z")

</div>


