20

Not sure if there is a SO bug reporting page and if so I'll delete this... but it came to light with this answer

It appears if you try to have a code block immediately follow a list then the first line of the code isn't formatted..

  1. list item
  2. list item

    public void Code() {


In order for a temporary fix I introduced a character on a new line..

  1. list item
  2. list item

'

public void Code()
{
2

1 Answer 1

25

Code block inside the list:

  1. list item
  2. list item

    public void Code()
    {
    

Code block outside the list:

  1. list item
  2. list item
public void Code()
{

The corresponding markdown:

Code block inside the list:

1. list item
2. list item


        public void Code()
        {

---

Code block outside the list:

1. list item
2. list item

<!-- -->

    public void Code()
    {
6
  • Ah nice. Half expected this to be a duplicate
    – Sayse
    Commented May 19, 2014 at 8:36
  • 2
    @Sayse - it is, but with a question in Meta Stack Exchange.
    – ChrisF Mod
    Commented May 19, 2014 at 9:00
  • @ChrisF - yes i upvoted mat's comment under question. Think my comment on this answer was misread.
    – Sayse
    Commented May 19, 2014 at 9:03
  • Hah -- I used this just the other day to separate two code blocks with a blank line. I must've thought, "oh well, everybody must already be doing it this way."
    – Jongware
    Commented May 19, 2014 at 9:41
  • 2
    It would be nice if this were included in the formatting help. I've just wasted hours on this and ended up with a hack in which I replaced my list numbers by (1), (2) etc.
    – David
    Commented Jan 13, 2016 at 23:06
  • That HTML comment thing is still totally a Kludge! I wish there was a non-janky way to do this...
    – NH.
    Commented Jun 4, 2018 at 19:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.