So I've read that code blocks not working after a list item thing is due to an ambiguity in the spec and this kind of makes sense, however there is no ambiguity in what the "Code sample" button means:

The code sample button

Admitedly this isn't anywhere near as annoying now that I know about the workaround, but there are still plenty of people who don't know about the workaround - they press this button but their code doesn't become "codey" and they have no idea why!

Can't this button detect cases where there is a code block immediately following a list item and inset the neccessary extra <!-- --> for them?

I know that this isn't ideal:

  • If the code sample is moved away from a list item then the comment is useless, but its not doing any harm
  • If the code sample is moved under a list item then it will break again, but at least users can click on this button again to have it fix the problem for them

But its better than nothing


I liked this idea, and I almost implemented it (at least for the 99% case, it's pretty easily doable), but then this came to me:

When you're writing a list and adding code, I would argue that in almost every case, you want to add the code block to the current list item, and not after the list. The answer that probably made you post this is a good example (see my edit to it): That code block was supposed to be part of the list item 2., not to stand independently of the list.

So if anything, I suppose the editor should cause the code block to appear as such in the current context; in this case, as part of the list item. That however is a much more complicated thing to do. I'll think about it, but it's much more non-trivial, given the way the editor works.

Either way, wanting to force the codeblock to be separate from the list is not the most common situation, and thus should definitely not be what the button does. So instead of almost fulfilling your reuqest, I have to decline it.

  • True, actually when editing that post it never occurred to me that the code sample should have been part of the list item, just that it should be formatted as a code sample. – Justin Nov 29 '11 at 14:17
  • 2
    Is there a possibility that this request could be reconsidered? I ran into this issue myself, and it took nearly half an hour to figure out why the code formatting button wouldn't format my code. – Stevoisiak May 5 '17 at 18:57

You must log in to answer this question.

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