Preformatted Text colorization in Forum

I saw many forum articles and posts in which preformetted text command highligted in color, here is random post of @SGS,

Here, the "source" keyword is highlighted in blue.
When I try to copy and paste the terminal code, it pasted in plain text with without any type of format in forum.
So my question is that how can I make preformatted text colorized??

It's a markdown syntax:

```bash
echo "Hello, here is the answer!"
```

becomes:

echo "Hello, here is the answer!"
3 Likes
```bash
sudo pacman -Syu
```

It gives me this output not working!!!

Try this:

Edit: depending on the highlighter YMMV.

1 Like
echo "Hello, here is the answer!"
1 Like

Why in all the codes its not working?

It's working on my computer:

(Screenshot)

1 Like
   ```bash
   CPU: Dual Core Intel Core i3-3110M (-MT MCP-) 
   speed/min/max: 2292/1200/2400 MHz Kernel: 5.9.10-zen1-1-zen x86_64 
   Up: 1h 16m Mem: 3532.4/9801.9 MiB (36.0%) Storage: 465.76 GiB (9.3% used) 
   Procs: 241 Shell: Zsh inxi: 3.1.09 
   ```

and the real image is this

1

  1. The top and the bottom line should be removed to make the code fence work.
  2. It's terminal output rather than bash commands so the code highlighting may would not work.
1 Like

Thanks for your reply @sosiristseng. This will improve my knowledge. But I specifically need the terminal command highlighting. And by the way love for Taiwan.

2 Likes

Some extra things:

If you want to share colored terminal sessions both colored input and output, I found asciinema an interesting choice. But it's an external tool so it's not the first line choice in the forum.

2 Likes
sudo pacman-Syu

Like this?
Use ~ 3 times before and after

source usr/share/p10k/bla/bla/bla
4 Likes
sudo pacman -Syu 
2 Likes