3

I've written an answer to a question but no matter what I do the editor refuses to format my code block properly.

I've reformatted several times, manually entering spaces and have tried the automatic 'code block' option. Both ignore segments of my code.

Is there something I'm missing?

The post in question is here, 1st answer by Visualife is the issue.

2 Answers 2

7

If the code is part of a bulleted (or numbered) list then 8 spaces are needed to indent it and display it, but if the code is not part of the bulleted list and should not appear indented, then the correct action is to end the list with a null comment, for example:

<!-- end list -->

Then the code will format correctly.

2
  • ah, thanks Brian, I somehow wasn't aware of that.
    – Rich
    Commented Aug 26, 2015 at 15:41
  • Is there a more efficient way of indenting other than manually hitting the space bar 4 (or 8) times on each and every line? (tab would be the default method for text editors, but, being in the browser, it navigates down the page)
    – stevec
    Commented Dec 30, 2018 at 19:39
6

If you're going to put code in a bullet point or numbered list you need 8 spaces instead of the usual 4. I've edited the answer for you to fix the formatting.

2
  • What if i dont want the code be part of the bullet point list? Right now I have to entere a point "." and one <enter> after the list to show the code format properly. Commented Aug 26, 2015 at 15:02
  • thanks Robert, but i had no intention of the code being part of the bullet list, it merely came immediately after the list. I had placed a return after the list but it kept associating it. Thanks for sorting it
    – Rich
    Commented Aug 26, 2015 at 15:41

You must log in to answer this question.

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