4

How can I separate two following codeblocks.

I mean something like this:

First command + output

 sudo apt-cache policy 
[sudo] Passwort für alex: 
Paketdateien:
 100 /var/lib/dpkg/status
     release a=now
 300 http://ppa.launchpad.net/system76-dev/stable/ubuntu focal/main i386 Packages
     release v=20.04,o=LP-PPA-system76-dev-stable,a=focal,n=focal,l=System76 Stable PPA,c=main,b=i386
     origin ppa.launchpad.net
 300 http://ppa.launchpad.net/system76-dev/stable/ubuntu focal/main amd64 Packages
     release v=20.04,o=LP-PPA-system76-dev-stable,a=focal,n=focal,l=System76 Stable PPA,c=main,b=amd64
     origin ppa.launchpad.net
snip

sudo apt update 
OK:1 http://archive.ubuntu.com/ubuntu focal InRelease
snip
2
  • IMO for something like this, you don't really need separate code blocks. Just use $ or something to show the prompt next to commands. This way long blocks of command output can scroll, reducing the overall length of the post.
    – muru
    Feb 19, 2021 at 12:46
  • 2
    I disagree with muru on this (a rare occurrence) - I think that each command plus output should be in its own block, as otherwise it can be difficult to find each command's output, especially if they are long.
    – Zanna Mod
    Feb 19, 2021 at 12:54

1 Answer 1

6

There are several options.

Perhaps the easiest is to use separate code fences like this:

```
code
```

```
separate code
```

Which produces this:

code
separate code

Another way is to insert a line rule by putting three (or more) hyphens/dashes (---) on an empty line, without indentation, between the blocks, which produces a sharper separation:

code

separate code

(this can be used with indented code blocks as I've done here, or in addition to separate code fences as shown in my first example)

With indentation you can also use an unindented <br> tag, or better, as noted by muru a html comment <!-- --> to force a break (this also works in list context), which does this:

code

separate code

or

code
separate code

NB: In case it's useful, those with 2k reputation can click the edit button under this post to see the markdown. Since there is no facility to suggest edits on meta, I have pasted the markdown text here for those who don't have 2k reputation.

3
  • 2
    <br> produces too much of a gap, an HTML comment <!-- --> won't
    – muru
    Feb 19, 2021 at 12:45
  • Thanks @muru :)
    – Zanna Mod
    Feb 19, 2021 at 12:51
  • 2
    fwiw, It's possible to find a post's "source code" by checking its revisions even if a user doesn't have edit privileges i.stack.imgur.com/5uLWQ.png (unsure though if that easily accessible in the UI by users if the post has never been edited).
    – Dan
    Feb 19, 2021 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .