15

I ran into a problem formatting a code block in a numbered list. I notice that I am not the first one to run into this problem -- there are more than a dozen questions related to this topic.

The solution is to add four extra spaces for each nested level of the list item that the code block appears in.

I wonder if the following steps can be taken to help newbies out with this issue --

  1. In the "How to Format" reference (that appears to the right of you when edit, reword the "indent code by 4 spaces": "indent code by 4 spaces. In lists, add an extra 4 spaces for level of the list item"

  2. Add this information to the full reference as well. Currently, it says this" "To put other Markdown blocks in a list; just indent four spaces for each nesting level:" which is helpful to those who know markdown and are familiar with the terms, but will totally fly over the head of a newbie (who is the one who actually needs to know). Add an example of a code block within an nested list.

  3. Fix the code button on the format bar (above the edit box) to figure out how many spaces to add automatically.

  4. Add this information to the FAQ

4
  • 1
    +1. i'd actually prefer it if the code button just added a 4-space indent each time i pressed it. or maybe sequential pressings should add 4-space indents, but a select-new-text-then-press should remove all indentation (if that's possible). it's rare that i need to remove code-block markdown; i need to add extra spaces much more frequently. May 13, 2010 at 19:47
  • Well it would indeed be a plus to have a context aware indentation.
    – M'vy
    Jul 6, 2011 at 9:15
  • This [question] shows the same problem. You either have to put a pre tag to format your code, or add an extra 4 spaces, even if the code block is at the end of the numbered list.
    – Laf
    Sep 4, 2013 at 14:52
  • +1 This fix is super important. So annoying to have to copy to an external editor to get the correct indentation.
    – Andrew Mao
    Sep 18, 2013 at 20:14

0

You must log in to answer this question.

Browse other questions tagged .