54

It would be great to add support for fenced code blocks as defined in the CommonMark spec:

  • it would be consistent with GitHub code blocks
  • it would be much more practical to type, instead of having to indent every line which is a pain…
  • it would allow to define explicitly (and easily) a language for a code block
8
  • 4
    I'm not sure if only cherry picking is wise given the fact that they might implement CommonMark all the way
    – rene
    Commented Mar 19, 2015 at 22:19
  • 1
    @rene ah right it's on meta.stackexchange that's why I didn't find an actual discussion about that. Yeah I support that, however in the meantime that would be great to improve that part as it's (for me) a huge deal. I end up contributing on stack overflow much less because of that detail… Maybe I'm too spoiled by github. Commented Mar 19, 2015 at 22:35
  • 1
    As a workaround for now: Indenting lines can be done by (a) using a code editor, (b) selecting the text and pressing Ctrl+K, (c) selecting the text and pressing the "code" button on the menu bar. Don't let the lack of fenced code blocks put you off contributing!
    – TRiG
    Commented Mar 20, 2015 at 0:27
  • This would be awesome. Dealing with the extra level of indentation is extra confusing for new users and a hassle for everyone else. Yes, cherry pick it, get it deployed yesterday.
    – max
    Commented May 14, 2015 at 0:06
  • I agree that it's silly that this feature gets blocked because someday we might have "CommonMark all the way". I don't contribute to StackOverflow as much now because of that… Commented May 19, 2015 at 7:13
  • Very much agree. It's a pain to add lines to the way current code is.
    – corvid
    Commented May 28, 2015 at 13:19
  • 2
    This feature request is detailed at this MSE post.
    – samthebrand StaffMod
    Commented Feb 5, 2016 at 17:22
  • 4
    I don’t care if this is implemented with CommonMark or not. All I care about is all the Python questions which are indecipherable because somebody (usually but not always new to the site) got confused by the indentation requirements. I care about the other languages too, but it’s particularly noticeable for Python because there is no other indication of scope like {/} pairs.
    – Daniel H
    Commented Sep 15, 2017 at 15:24

1 Answer 1

39

Code fences are now implemented. See Implement ```-style (fenced) Markdown code blocks on MSE for all the details.

3
  • 6
    Let there be rejoicing and dancing in the streets. This is great!
    – yivi
    Commented Jan 8, 2019 at 17:15
  • 3
    @Jeremy Yep: stackoverflow.com/editing-help#syntax-highlighting
    – balpha StaffMod
    Commented Jan 8, 2019 at 17:20
  • 3
    So happy that this has finally happened. It always seemed so weird, that the absolute core function of StackOverflow - code snippets within questions - was so poorly implemented, and incompatible with the standard everyone expects. Commented Jan 14, 2019 at 0:00

You must log in to answer this question.

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