# Code fences toolbar button plugin

**URL:** https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508
**Category:** Development
**Created:** [2016年五月19日 16:21 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508 "2016-05-19T16:21:49Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年五月19日 16:21 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/1 "2016-05-19T16:21:49Z")

</div>

Hey guys,  
We are looking into adding the ability to insert

```php
code fences with ('syntax highlighting')

```

as a button to the toolbar because code snippets are important in our installation and not all users know about code fences. The plugin can be found here: [GitHub - ThomDietrich/discourse-plugin-code-fences-buttons: Discourse Plugin: Code Fences Buttons (cfbtn) · GitHub](https://github.com/ThomDietrich/discourse-plugin-code-fences-buttons)

I am having a **problem** though. Descriptor and placeholder for the buttons are not replaced by the internationalized representations. So the string “cf\_ohitems\_button\_title” defined [here](https://github.com/ThomDietrich/discourse-plugin-toolbar-buttons/blob/code-blocks/assets/javascripts/discourse/initializers/spoiler-ui.js.es6#L10) is not replaced by the corresponding string in my `config/locales/client.en.yml`. What am I missing?

Thanks!

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年五月19日 16:40 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/2 "2016-05-19T16:40:44Z")

</div>

Are you doing this on a development machine or on a docker installation?

If on a development machine, did you try clearing the cache, using `rm -Rf tmp/cache`?  
If docker, did you run `./launcher rebuild app`?

---

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年五月19日 18:13 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/3 "2016-05-19T18:13:28Z")

</div>

Damn I knew it was something this simple. I already had the feeling this is cache related (development machine with vagrant) and cleared the cache. Now I had to realize I had tried to clear `/tmp/cache` 😫  
Thanks!  
Btw. I guess you already realized that I forked your spoiler-ui plugin. If you want to pull something back, go for it! (I did some “deduplication” in spoiler-ui.js.es6 for example)

---

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年五月19日 18:17 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/4 "2016-05-19T18:17:23Z")

</div>

There is actually one more function you maybe can help me with. I want options for activating/deactivating buttons in the admin\>plugins\>settings pane so you only see the php button if this is all your users will need.  
I have my `config/settings.yml` file with 4 settings but only “codefence\_buttons\_enabled” is shown.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年五月19日 18:24 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/5 "2016-05-19T18:24:14Z")

</div>

You didn’t update the plugin.rb to reference the 3 other site settings.

---

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年五月19日 18:38 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/6 "2016-05-19T18:38:12Z")

</div>

And how? 🙂  
Putting them line by line will only show the last one and putting all options in an array crashes my admin area.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年五月19日 18:44 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/7 "2016-05-19T18:44:52Z")

</div>

Oh, actually that was bad advice anyway, give me more time to look at your repo

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年五月19日 18:57 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/8 "2016-05-19T18:57:40Z")

</div>

Hmm… I just cloned your repo and it works fine for me…

 ![](https://global.discourse-cdn.com/meta/original/3X/3/3/3361abe049af3cd8c0ab93cde5965951c112410b.png)

---

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年五月19日 19:02 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/9 "2016-05-19T19:02:37Z")

</div>

I just needed to search for openhab? 😂  
Aah the time 🙂 Thank you very much!

I’ll clean everything up and add options for commonly used syntax languages.  
Can you or one of the moderators move this thread to plugins?

Best! Thomas

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年五月19日 19:05 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/10 "2016-05-19T19:05:35Z")

</div>

I can, though it may be more useful to post a new topic there (so it doesn’t have all of this back and forth).

Maybe provide some screenshots to show the composer changes and what not.

---

<div class="post-metadata">

### Author: ![Mazzen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mazzen/32/121178_2.png) [@Mazzen](https://meta.discourse.org/u/Mazzen)
#### Post date: [2016年七月4日 12:21 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/11 "2016-07-04T12:21:54Z")

</div>

Topic resolved.  
The working plugin can be found here:

> [@Code Fences Highlighting Buttons Plugin](https://meta.discourse.org/t/code-fences-highlighting-buttons-plugin/46661):
>
> Hey guys, I’ve created a plugin for Discourse, which adds additional code fences and syntax highlighting buttons to the composer toolbar. The plugin, documentation and all future updates can be found here: [GitHub - ThomDietrich/discourse-plugin-code-fences-buttons: Discourse Plugin: Code Fences Buttons (cfbtn) · GitHub](https://github.com/ThomDietrich/discourse-plugin-code-fences-buttons) The available buttons in your toolbar are configured through the plugin settings. Currently there is one javascript option and one with free to choose syntax highligh…

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年七月4日 13:46 UTC](https://meta.discourse.org/t/code-fences-toolbar-button-plugin/44508/12 "2016-07-04T13:46:18Z")

</div>


