When I try to paste code into Trello I get very weird formatting after saving but it seems it does format code, I just can't get it to work right. Currently I'm just putting links to Gist, but I would prefer to just paste it straight in there.
5 Answers
Include formatted code by wrapping it in three backticks (```) at the beginning and end of the block, or by starting a line with four spaces.
Important note — the triple backticks have to be on a separate line and ensure you have a blank line before and after the code block.
-
Adding a tab or 4 spaces at the beginning of each code line (as other users have answered) looks way better. I don't understand why this answer has so many upvotes. Apr 13, 2022 at 12:45
-
While @LucioMollinedo is correct, it requires "work" :-) For those of us who are lazy simply pasting text and surround it with ``` is easy. The BIG point in this answer is the bold section regarding Blank Lines above and below!! I knew of ``` but couldn't get it work until I found this.– ripvlanApr 25, 2022 at 18:44
-
@ripvlan I agree. Trello needs to improve its formatting tools. Doing the same here in StackOverflow is trivial in comparison. Still, I go the extra mile and add the tab/4 spaces in my code editor and paste the code in Trello afterwards because readability is very important :-) Apr 25, 2022 at 22:13
Either surround the code by backticks (`
) for smaller segments of code, or make sure that each line begins with a tab or at least four spaces.
In 2020, wrapping a code block in ``` (triple backticks) in Trello still drops newlines, etc.
I have to add 4 spaces before each line to get it display lines and indentation properly. Thanks @GiH for leading me to the source docs.
-
1You need a blank line before and after the triple backticks to separate the code block from the rest of the card text.– axxisMar 5, 2021 at 7:37
Finally found the answer here:
http://daringfireball.net/projects/markdown/syntax#code
using markdown is outdated, its not as easy as just using Gist haha, think I'll keep that route... they should really work on their tools.
-
2I don't feel that merely because someone feels Tool-A is "not just as easy as" Tool-B that that makes Tool-A "outdated" and worthless. I happen to love Markdown, and it is used by far more tools than Gist. Plus, Gist is aimed really at CODE -- Markdown is aimed at DOCUMENTATION. Two different tools.– BaneMay 7, 2015 at 17:00
I know that the subject is a bit old, but I found myself faced with this problem.
I wrote an userscript if anyone is interested in it. It works with triple backslash with line feed and allows syntax highlighting, according to the indicated language.
(edit: here)
Eg:
# Title
Text line
```javascript
import Vue from 'vue';
import App from './App.vue';
let vm = new Vue({
el: '#box',
render: h => h(App)
});
```
Text...
Result: