7

As noted in What is the preferrred method for formatting code?, the "Ask a question" sidebar that shows up while writing the body of a new question suggests to "indent code by 4 spaces" even though its example of code block formatting uses fenced blocks, as seen in this screenshot (taken from the aforementioned Meta question):

Ask a question sidebar

There seems to be no need to show two essentially equivalent ways of doing the same thing in a quick summary aimed at new askers like this one. That being so, the "indent code by 4 spaces" line probably should be removed, assuming that fenced blocks are supposed to be the primary recommendation. (Conversely, if the example were to be changed to indented blocks, no mention of fenced blocks should be necessary.)

6
  • 1
    I disagree. I'd actually wish this were at the top of the list. So many people (nnewbies) use "fences" and it turns out really wrong. That's a lot more work to correct. Also, the editor tool uses the indent, so I think a mention is important (avoid confusion). Logically, though, it is in the wrong place in the list... Jul 28, 2019 at 4:30
  • @CindyMeister A fair concern. Reverting the example there to use indented blocks sounds worthy of a separate [feature-request].
    – duplode
    Jul 28, 2019 at 6:09
  • @CindyMeister I have edited the question to mention the alternative possibility.
    – duplode
    Jul 28, 2019 at 16:36
  • Is there any way to enable syntax highlighting with indented blocks?
    – Bubbler
    Jul 29, 2019 at 2:10
  • 1
    @Bubbler Assuming the relevant language is supported by the highlighter, adding an HTML comment like <!-- language: rust --> just before the code block will do. See meta.stackoverflow.com/q/274371/2751851 for details.
    – duplode
    Jul 29, 2019 at 9:52
  • Thanks :-) However, the edit doesn't really address my concern... I see no problem mentioning both options. But they should be adjacent in the list. And if there's any usage difference, that should be mentioned, as well. Jul 29, 2019 at 14:08

0

You must log in to answer this question.

Browse other questions tagged .