5

why is code formatting in answer https://tex.stackexchange.com/a/169741/5328 disabled when I remove the period between itemization and the code?

Edit: I changed the answer by inserting a HTML comment as suggested, so now all is properly formatted. However, the link above is now a bit useless. Thanks to all answerers and commentators, to describe the initial problem again and for their support.

  • 2
    The Markdown is seeing the code as part of the list, so you'd need two indents (8 spaces) to make this work. Not sure if that's a bug or not! – Joseph Wright Apr 5 '14 at 14:46
  • 2
    If the code is part of the list you need 8 spaces, if not you could add an HTML comment after the list as in meta.tex.stackexchange.com/questions/1558/… – Torbjørn T. Apr 7 '14 at 5:06
  • 1
    @TorbjørnT. I believe that this is the correct answer ;) – yo' Apr 13 '14 at 20:11
  • @tohecz I don't know, but I added an answer anyway. – Torbjørn T. Apr 13 '14 at 21:09
8

References:

This is because any indented text immediately following a list is seen as part of the list, as Joseph mentions. Hence, if you have

* list item

   some text

some more text

this is printed as

  • list item

    some text

some more text

As mentioned in the first question referenced above, this is basically a limitation in the Markdown format, nothing to do about it.

There are two ways of dealing with this, depending on what your intention is:

  1. If the code is part of the list, indent it with eight spaces instead of four.

  2. If the code is not part of the list, but follows after it, add something between the two, such as an HTML comment, i.e.

     <!--  -->
    

A tip for indenting blocks with eight spaces: Select the block and hit the {} button/Ctrl+K to indent with four spaces. Then write a single character (such as your period) on the line just before the block, select both this and the entire block, then hit the {} button again. Finally, delete the single character.

You must log in to answer this question.

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