1

Sometimes it makes sense to write answer in points, and include couple lines of code in one point. However, indenting with 4 spaces does not work for lists, and breaking list with no-list text causes list numbering to reset. Using apostrophes ` makes all lines of code to display as one line (or separate code blocks).

Is there a good way to do it?

Example:

  1. a

  2. b

    first code

  3. d

list break

second code
  1. e third code line 1 third code line 2
| |
3

Inside lists, indent the code by (N + 1) * 4 spaces, where N is the indentation level for the list item containing the code.

  1. First point
  2. Second point
  3. Third point

    // This code is indented by 4 spaces; the item containing it is indented by 1 level.
    $account = user_load($uid);
    
  4. Fourth point

    1. Another point
    2. Yet another one

       // This code is indented by 8 spaces; the item containing it is indented by 2 levels.
       $account = user_load($uid);
      
| |

You must log in to answer this question.

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