How to use code fences

Tags: #<Tag:0x00007f6173778c98>

Hmm. I never even realized there were icons. LOL I always go old school and just manually type the beginning and ending ```

1 Like

Enclose your configs in:

<code>
This is my config
</code>

Note: Additional markdown for whoever is interested: https://commonmark.org/help/

The above will become:

This is my config

1 Like

Maybe that custom plugin does not work anymore …

If you check using F12 in Chrome (dev tools) you will see that some of the svg icons are missing… (I think) so the plugin may need some maintenance. good catch @sihui

We need @ThomDietrich back ! :smiley:

updated first wiki post to show immediately how to use the generic code fences

edit: added the <code> html flavor also on the table that shows up on the first page

1 Like

I need your advice on how to properly include long log in a post.

I have used the “Hide details” option of this editor to avoid having page long post but then the code fence does not seem to have effect on the hidden text.

I have seen some topics using fixed size blocks in which your can scroll horizontally and vertically the code/text but I have no idea how to include such block in this editor

Highlight your text and use the grafik button. Make sure you have an empty line before and after your code:

Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code Here goes your code

Next line …

Thanks but my log has 100 lines and I would like to have a smaller size block (let say 20 lines) in which the reader could scroll vertically through.

Will that happen automatically with the </> feature?

Yes, but it depends on the overall length of your code. You also can combine them with the “Hide details” function: first use the hide details, then the preformatted text:

Summary
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.1272019-11-10 22:29:50.595 [vent.ItemStateChangedEvent] - ESP8266_Five_Lux_Update changed from 0 lx (So, 22:28) to 0 lx (So, 22:29)
2019-11-10 22:29:50.598 [ome.event.ItemCommandEvent] - Item 'ShutterLuxWestDetected_Proxy' received command OFF
2019-11-10 22:29:54.646 [vent.ItemStateChangedEvent] - TemperatureShadow_Update changed from 4,0 °C (So, 22:28) to 4,0 °C (So, 22:29)
2019-11-10 22:29:54.650 [vent.ItemStateChangedEvent] - Shading_tempDiff_Proxy_Update changed from -0,2 °C (So, 22:28) to -0,2 °C (So, 22:29)
2019-11-10 22:29:54.651 [ome.event.ItemCommandEvent] - Item 'ShutterTempDetected_Proxy' received command OFF
2019-11-10 22:29:57.017 [vent.ItemStateChangedEvent] - Barometer changed from 1015.125 to 1015.127
1 Like

Great thanks

Using code fences does this by default

```
Really long code or logs go here
```
3 Likes

Here is a test post which I will delete once I am done :

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

Using the BB Formatting tool:

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

TABing wont work so I guess that must be correct before you copy

sitemap home label="Uberboltonwagen"
{Frame label="Lights" {
				Switch item=channel1 label="Desk"
				Switch item=channel2 label="Bed Reading"
                                Switch item=channel3 label="Bathroom"
				Switch item=channel4 label="Bed Space"
                              //Switch item=channel5 label="TBA1"
				Switch item=channel6 label="Outside"
                              //Switch item=channel7 label="TBA3"
				Switch item=channel8 label="Galley"
                }   
}

I often see complaints that people aren’t using code fences when requesting help.

I’m using Firefox (77.0.1 (64-bit)) on Ubuntu (18.04), and this is what my edit panel looks like:

All the code fence icons are gone! The links are still there (you can tell if you hover over them). Is this very specific to Firefox on Ubuntu?

Hi @hafniumzinc,

I see this behavior on MacOSX (10.15.4) with Chrome, Microsoft Edge, and other browsers. As mentioned above if I hover over where the icons should be, I get text indicating the usage of the code fences.

Regards,
Burzin

1 Like

Still there:

cf

Further information:

You’ve linked to the thread we’re currently in!

The icon you’ve circled is titled ‘code snippet’, and adds four spaces in front of text for pre-formatted text. I’m talking about the specific ones for items, rules, sitemaps etc which adds three backticks (`) at the start and end of code, also enabling vertical (and horizontal) scroll bars if the code gets long. Those are the code fences.

I know.
Again: use the preformatted text and you are good to go.

As I mentioned previously, the options for the fences actually exist, it’s just their icons have gone missing so they’re ‘hidden’.

The main point is as below:

If we’re asking people to use code fences, let’s make sure they can easily use them!

It could relate to the version of Discourse running on the site. I do not know if it is regularly updated.

EDIT: We are running Discourse 2.5.0-beta 6 that was released 9 days ago. It is missing for me too on chrome for Windows. Hovering brings up the tooltip but no icon. Clicking does work though.

    <meta name="generator" content="Discourse 2.5.0.beta6 - https://github.com/discourse/discourse version 75b1298e997ce7dda904cc88b668a55eb13b457f">

EDIT2: Perhaps somebody want to look for a solution on their forum?

This is the case since ages, there is an old post about it where Kai tried to fix it without success.

Just hit the damn preformatted text button and you have your code fences. Just the color highlighting is missing, so what.

Edit: here is the post about the missing icons (since at least May 2019) and also information on the not active maintainer who developed the plugin:

1 Like