# Abbreviations and acronyms plugin

**URL:** https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501
**Category:** Plugin
**Tags:** deprecated
**Created:** [January 26, 2016, 10:47am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501 "2016-01-26T10:47:03Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [January 26, 2016, 10:47am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/1 "2016-01-26T10:47:03Z")

</div>

I participate in a community where there are enthusiasts with lots of knowledge and newbies with not that much knowledge. It has become a habit that experts use lots of acronyms and abbreviations to refer to common terms, or famous webpages or to name known brands in their field of expertise, sometimes they use only initials when referring to famous people in the field, etc. This is not a problem for the oldest participants in the community, but some new people are having a hard time reading some posts, so the admins have been asked to create a plugin that automatically creates a tooltip for the most common acronyms.

This plugin does so. It automatically surrounds some (configurable) words with an `<abbr>...</abbr>` tag so a tooltip appears when hovering the mouse over the word.

This way IMMO becomes IMMO, YMMV becomes YMMV, R&B becomes R&B, etc

It is a very simple plugin, you can add more abbreviations through the admin panel.

Here is the code:

[https://github.com/PoloGT/abbreviation-discourse-plugin.git](https://github.com/PoloGT/abbreviation-discourse-plugin.git)

Any advice to improve the plugin will be welcome

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 12, 2016, 5:08pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/3 "2016-02-12T17:08:58Z")

</div>

I installed this and added a couple acronyms. I wrote a test post that had several of the listed acronyms. In the editor preview, all 3 showed up with tooltips, but in the final post itself, only the last acronym of 3 showed up with the tooltip. ☹

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [February 12, 2016, 6:13pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/4 "2016-02-12T18:13:13Z")

</div>

That is weird, it is working for me.  
All of the 3 acronyms have the same tooltip? or the first 2 have no tooltip at all?

i am sure this is not the problem, but did you add the new acronyms through the admin panel, or editing the settings.yml file?

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 12, 2016, 6:15pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/5 "2016-02-12T18:15:21Z")

</div>

First two have nothing at all …

I made all changes through admin panel.

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [February 12, 2016, 6:41pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/6 "2016-02-12T18:41:56Z")

</div>

OK, I understand what is going on. The server side only reads the new settings on its startup, not dynamically. If you restart discourse it will work (please confirm).

I am going to investigate a new way to load the settings so it is more dynamic. Thanks for telling me, I reboot my development server all the time, and in the production server we probably never changed our initial list of acronyms so I never noticed.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 2, 2016, 3:46am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/7 "2016-06-02T03:46:40Z")

</div>

@BlackSheep I submitted a PR to use a dialect preprocessor instead such that it calls a preprocessing function which will pull in the latest site settings each time it has to process a post.

[https://github.com/PoloGT/abbreviation-discourse-plugin/pull/1](https://github.com/PoloGT/abbreviation-discourse-plugin/pull/1)

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [June 6, 2016, 4:26pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/8 "2016-06-06T16:26:03Z")

</div>

That is awesome @tgxworld. Thanks a lot! 👍 With your changes the plugin picks the new settings on the run, so you don’t need to restart the application if you want to apply new abbreviations.

I am going to mention @downey to be sure he reads this.

---

<div class="post-metadata">

### Author: ![psbrandt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/psbrandt/32/121745_2.png) [@psbrandt](https://meta.discourse.org/u/psbrandt)
#### Post date: [June 15, 2016, 3:50pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/9 "2016-06-15T15:50:44Z")

</div>

Thanks for the great plugin @BlackSheep!

I’m seeing an issue where if an abbreviation/acronym is in a URL, the plugin (I think) inhibits the ability to make a link to that URL. So, if we had IMMO configured, then the following would be rendered as markdown source instead of as a link:

```plaintext
[link](http://www.domain.com/immo?maybe=something-else)

```

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [June 15, 2016, 11:59pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/10 "2016-06-15T23:59:37Z")

</div>

Maybe i should force to detect a whitespace character (space, tab, new line, etc) on either side of the acronym before i do the substitution. What do you think?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 16, 2016, 12:44am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/11 "2016-06-16T00:44:10Z")

</div>

> [@BlackSheep](#):
>
> Maybe i should force to detect a whitespace character (space, tab, new line, etc) on either side of the acronym before i do the substitution.

Yes, currently the regex is looking for a word boundary after the token as a match.

slashes, question marks. etc. _are_ word boundaries.

Testing for pre and post whitespace will work for the link use case.

But it will break if the acronym is written in parenthesis eg. (YMMV) would fail to match.  
(I can’t say how often that might be the case, but you just know someone will bring it up)

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [June 16, 2016, 7:56am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/12 "2016-06-16T07:56:25Z")

</div>

Good point. But I don’t want the plugin to break the link use case (or any other already existing syntax). Also since discourse has a preview as you type, that would make it very intuitive to see that you need to add the space, so any user could see that has to write ( YMMV) instead of (YMMV) to make it work. It is the same (although not for the same reasons) with the existing emojis:  
this doesn’t work:slight\_smile:  
this works 🙂

It is a matter of making it clear in the documentation. I think is the way to go

---

<div class="post-metadata">

### Author: ![marcospreviato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcospreviato/32/54766_2.png) [@marcospreviato](https://meta.discourse.org/u/marcospreviato)
#### Post date: [June 16, 2016, 4:22pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/13 "2016-06-16T16:22:09Z")

</div>

I was looking for something like this, like a tooltip:

 ![](https://global.discourse-cdn.com/meta/original/3X/7/0/70fd459e0b1f172bc6fa0b5efc47bacfd30a1ac3.png)

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [June 16, 2016, 8:02pm UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/14 "2016-06-16T20:02:21Z")

</div>

OK, I changed it, so a whitespace character (space, tab, new line, etc) is needed before or after the acronym. Thanks for noticing 👍

---

<div class="post-metadata">

### Author: ![psbrandt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/psbrandt/32/121745_2.png) [@psbrandt](https://meta.discourse.org/u/psbrandt)
#### Post date: [June 17, 2016, 8:37am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/15 "2016-06-17T08:37:29Z")

</div>

@BlackSheep thanks for the quick response!

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [July 7, 2016, 12:34am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/16 "2016-07-07T00:34:12Z")

</div>

Can the plugin be installed without touching `settings.yml` file as by your README at github? Also, if no plugin restart is required anymore after adding more acronyms, you should update the README file, it currently says:

> You can keep adding more acronyms through the admin panel later on, but restarting Discourse is still required.

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [July 7, 2016, 9:02am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/17 "2016-07-07T09:02:59Z")

</div>

> [@meglio](#):
>
> Also, if no plugin restart is required anymore after adding more acronyms, you should update the README file

👍 Done! Thank you.

And yes, you don’t really need to touch settings.yml at all. Although it comes with 3 acronyms as example so you probably want to change them in the admin panel after the installation

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [July 7, 2016, 9:05am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/18 "2016-07-07T09:05:06Z")

</div>

So, this is now entirely configurable in administration panel, is it?

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [July 7, 2016, 9:07am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/19 "2016-07-07T09:07:04Z")

</div>

Yes, it is a very simple plugin. You can only enable / disable it, and add / delete new acronyms. Both things can be done though the admin panel.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [July 7, 2016, 9:15am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/20 "2016-07-07T09:15:23Z")

</div>

Are the acronyms added on the fly, or require rebuilding the HTML of the posts? Will the acronyms go away as soon as we turn the plugin off?

---

<div class="post-metadata">

### Author: ![BlackSheep](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blacksheep/32/50170_2.png) [@BlackSheep](https://meta.discourse.org/u/BlackSheep)
#### Post date: [July 7, 2016, 9:19am UTC](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501/21 "2016-07-07T09:19:22Z")

</div>

Messages posted (cooked) while the plugin is active will keep the acronyms. If you want older posts to have the acronyms you will need to rebuild them. If you want the acronyms to go away when you turn the plugin off you will need to rebuild older messages.

[Next page](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501.md?page=2)
