28

I have prepared a question that includes a bullet list with four levels. The "Help" on lists says to make nested lists by indenting each subsequent level after the first by an additional four spaces. So I made a list like this:

  • 1
    • 2
      • 3
        • 4

Hmm, that seems to be working here. So let me give you the list from my question:

Hmm, that is copy-pasted directly from the text of my question. It's working here, but on Stack Overflow, I get the error message, "Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button ..." and it won't let me post the question.

What do I need to do to make this work and post my question?

11
  • 2
    Is the problem whenever you make sublists, or only when those sublists contain links?
    – Davy M
    Dec 30, 2018 at 0:13
  • 3
    @DavyM - The only way to test that was to attempt posting the question without the links on the list items, so I did that, and the question posted. Then I edited it to put back the links. I found that I could put links on the first three levels of list items, but not on the fourth. So I put in a note with those links. This is the paragraph that starts with "(The system is not allowing me to put links ..." at stackoverflow.com/questions/53974804/… . Is this a bug or am I doing something wrong?
    – NewSites
    Dec 30, 2018 at 2:34
  • 2
    This sounds like an edge case where the format for the nested list plus the format for the link is overlapping with the unformatted code detection... I'd call it a bug, but I think you'll get a better response with support as you're more likely to get help making it work, since these kinds of false positives with the unformatted code detector are few and far between, they might not consider this a big enough need to bother making a change to the system.
    – Davy M
    Dec 30, 2018 at 4:27
  • 3
    Unformatted code detection doesn't always work properly. See also meta.stackoverflow.com/questions/368687/…
    – user202729
    Dec 30, 2018 at 4:51
  • 1
    I just tried to add the links and was able to do so. I guess, the unformatted code detection has some reputation trigger. Anyway, maybe you can try to add some empty lines between the list items. This seems to work for similar cases...
    – honk
    Dec 30, 2018 at 7:25
  • 1
    @honk - Thank you. Would you like to also remove the note under that list about links not working on 4th-level list items since you now got them to work? I just tried to remove that note and got the same error message as before. But I also wonder if that means I'll not be able to do any more edits of the question with those links on the list items.
    – NewSites
    Dec 30, 2018 at 7:39
  • 1
    You are welcome. I just removed the note. In case adding empty lines between the list items doesn't work for you, please try to add some comment tags (<!-- -->) between the items. Maybe this helps...
    – honk
    Dec 30, 2018 at 8:56
  • 1
    If you need four levels of list, is the question a good fit for Stack Overflow? Normally, SO deals with simpler issues that don't need so much indentation. I'd be worried about a 4-level list. Dec 30, 2018 at 20:00
  • I think low-rep users are limited to the number of external links that their question (and maybe answers too) can contain. This, along with an additional restriction on the presence of code blocks in a large-ish question had you restricted from posting the question.
    – hjpotter92
    Dec 31, 2018 at 17:52
  • 2
    Okay, thank you. Let me point out that it would be helpful if the error message had included a link to something that clearly lays out the restrictions so I could have understood what was going on and considered what to do about it instead of having to write here for help. (But I'm also grateful that effective and timely help was available!)
    – NewSites
    Dec 31, 2018 at 20:33
  • Doesn't seem to work with ordered lists.
    – odigity
    Dec 17, 2022 at 20:58

1 Answer 1

3

The help text is wrong. It may or may not have been correct as of the time which it was written, but it's definitely wrong now. At this point, Stack Exchange uses CommonMark, which definitely doesn't work with a single fixed number of spaces required to indicate that the line is under the prior list item.

The CommonMark specification for List Items goes into considerable detail as to what's required for something to be considered "under" the current list item. The basics of what is says is:

The most important thing to notice is that the position of the text after the list marker determines how much indentation is needed in subsequent blocks in the list item. If the list marker takes up two spaces of indentation, and there are three spaces between the list marker and the next character other than a space or tab, then blocks must be indented five spaces in order to fall under the list item.

Effectively, you need to line the sub-items up in the character column where the text starts for the list item under which you want the item to be.

Unordered list example

So, for a simple unordered list:

  • bullet item
    • first sub-bullet item (needs 2 spaces at the beginning of the line; "* " is 2 characters)
      • sub-sub-bullet item (needs 2 + 2 = 4 spaces at the beginning of the line; "* * " is 4 characters)
    • second sub-bullet item (back to needs 2 spaces at the beginning of the line; "* " is 2 characters)
* bullet item
  * first sub-bullet item (needs 2 spaces at the beginning of the line; "* " is 2 characters)
    * sub-sub-bullet item (needs 2 + 2 = 4 spaces at the beginning of the line; "* * " is 4 characters)
  * second sub-bullet item (back to needs 2 spaces at the beginning of the line; "* " is 2 characters)

Ordered list example

For an ordered list, the minimum number of spaces which you will need will depend on the numeric value for the line item. For example:

  1. Lines under this line item, require 3 spaces, because "1. " is three characters.
    This is another line under the first item.

    1. Lines under this line item require 3 + 4 spaces = 7 spaces, because "1. 10. " is seven spaces.

      This is another paragraph under line 10.

The above is:

1. Lines under this line item, require 3 spaces, because "1. " is three characters.  
   This is another line under the first item.

   10. Lines under this line item require 3 + 4 spaces = 7 spaces, because "1. 10. " is seven spaces.

       This is another paragraph under line 10.

That's the basics. Both fewer and more spaces will work under some conditions. The CommonMark ➞ HTML converter will try to do the "smart" thing, both in the preview during editing and in the backend. However, there are other types of formatting which are indicated by prepending spaces to the line (e.g. code formatting can be indicated by starting a line with 4 space characters, which can be combined with any level of list item). If you're not using the exactly specified number of spaces, then the converter may guess something which you're not intending. Given that the CommonMark ➞ HTML converter for the editor preview and the CommonMark ➞ HTML converter which is used in the backend for all posts are two different pieces of code, in two different languages, there will be some differences. You may need to try a few things to get it looking the way you want it.

You must log in to answer this question.

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