9

Indented code does not display properly after a list item (bulleted or numbered). Is this a bug, or am I doing something wrong?

(*some good code here*)
f[x]=1

A list:

  • one
  • two
  • three

    (some good code here) f[x]=1

After a normal paragraph, everything is OK.

(*some good code here*)
f[x]=1

(I'm using win7 and Chrome)

7

It works, but you need to add some extra spaces. It needs to be indented twice, to distinguish between a new paragraph within a single list item and actual code.

Example MarkDown

 * one

 * two

   two continued

        code

The above, formatted

  • one

  • two

    two continued

    code
    
  • Ahhh, thanks! Do I just delete the question? – Ajasja May 4 '12 at 13:41
  • @Ajasja Don't delete it, I'm sure there are other people who are confused. I was confused about this as well, and you got 2 upvotes in less than an hour. We can retag it from 'bug' to 'markdown' and 'support' (I'll do that, adjust if necessary) – Szabolcs May 4 '12 at 13:43
  • I would have never guessed such a solution, thanks Szabolcs! – István Zachar Sep 28 '12 at 9:28
3

Szabolcs' answer works if you want to make the code part of the indented list. If you don't want to make it part of the indented list, a simple comment can be used to stop it. Example Markdown:

* point 1
* point 2

  point 2 continued

        (*this code is part of point 2.*)

  point 2 continued

<!-- this comment serves only to stop point 2 -->

    (*This code no longer belongs to point 2.*)

This gives:

  • point 1
  • point 2

    point 2 continued

    (*this code is part of point 2.*)
    

    point 2 continued

(*This code no longer belongs to point 2.*)

As you can see, the comment, while not being rendered itself, takes the function of stopping point 2.

  • How come that in the first example, the <!-- ... --> comment is visible? They are hidden only when quoted? – István Zachar Oct 3 '12 at 13:55
  • @IstvánZachar: Because in the first example, it is part of the code block, and thus not interpreted but displayed literally. – celtschk Oct 3 '12 at 14:16
  • Oh, yes, that makes sense. Of course. Silly me. Thanks! – István Zachar Oct 3 '12 at 14:19

You must log in to answer this question.

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