10

I was going through the first-posts queue and came across this answer. It's correct, but the formatting was a little off, so I thought I'd fix it for them.

Turns out though, that the formatting is/was correct (codeMagic "fixed" it) - but the markdown parser is considering the code part of the answer to be a part of the list. Note the extra indentation.

See my example below. If you click edit on this question, you'll see that there's multiple lines between the list and the <string> tags. This should terminate the list section and start the code formatting section. It doesn't matter whether the tags are present or not - though if they are present, they don't show up.

  1. List item 1.
  2. List item 2.

    This should be code formatted.

However, if you put any (?) non-whitespace text at least 1 line after the list, it "fixes" it:

  1. List item 1.
  2. List item 2.

.

<string>This should be code formatted.</string>

Is there a workaround for this?

I have tried this in 2 other Markdown editors (Atom editor, and dillinger.io) and both exhibit the behaviour of requiring 2 line breaks between the list and the code.

7
  • 2
    Put at <!-- --> between the list and the code, with empty lines before and after.
    – gunr2171
    Jul 16, 2014 at 2:43
  • Note that I took the lazy man's fix for the edit. <tsk tsk>
    – codeMagic
    Jul 16, 2014 at 2:45
  • 1
    That works. I mostly was just hoping to be better than codeMagic.
    – Adam S
    Jul 16, 2014 at 2:46
  • This was posted today, and might be related to what you're looking for. Might have read your question too quickly, but hope not...
    – awksp
    Jul 16, 2014 at 2:46
  • Yeap, that's exactly the same issue. Is there likely to be a fix for this, or is this a quirk of some custom logic in the SE Markdown editor?
    – Adam S
    Jul 16, 2014 at 2:48
  • 1
    @AdamS congratulations! You have accomplished what most only dream of
    – codeMagic
    Jul 16, 2014 at 2:48
  • Looks like this has been brought up before.
    – Adam S
    Jul 16, 2014 at 2:56

1 Answer 1

14

You can get around it by putting an Html comment between the list and the code

<!-- -->

This will separate the list and the code.

  1. So,
  2. For example
This is some code, not in the list

Also handy when you want to separate other elements, like 2 code blocks.

Code line 1
Code line 2
1

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