Community ToolTip: How to embed RMscript nicely in a post

When including code in a post, it is helpful for it to be displayed in pretty-print for increased legibility. By default, Discourse provides some formatting assistance via the UI when creating a topic; interestingly, it also supports further inline Markdown formatting as well where needed.

After some experimentation, after observing quite a degree of inconsistency in how RMScript was being recognised, the following recommendation seems to achieve the best results.

Not only is it is possible to enclose the code snippet inside three back-ticks: ```, it is also possible to specify the language styling of the code itself. Best results are found to come from enforcing the use of SCSS styling. Then,

```scss
// Here’s an example code snippet
[List.Where: values={=TheArray}, condition=“jPath(value,‘Count’) > 2”, =>Result]
```

becomes

// Here's an example code snippet
[List.Where: values={=TheArray}, condition="jPath(value,'Count') > 2", =>Result]

Without the explicit scss being placed after the opening triple back-ticks, the ensuing styling for different code snippets will likely have variable results.

By using the explicit scss as above, consistency and the desired goal of increased legibility is achieved.

3 Likes