-8

In the Markdown help it says that you need to

Indent four spaces to create an escaped block

This however does not work. In a comment I wrote XML with 4 spaces indentation, plus a language definition. This is the actual text:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<title>De mægtige vikinger</title>
<defs>
<xhtml:link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</defs>
</svg>

Also, spaces for indentation counts as characters. Meaning you can write more code if you don't bother formatting it. This is counter intuitive to have easy to read and accessible comments.

The resolution should be to implement a robust code formatter and not count formatting instructions in the sum of how many characters a user can write.

UPDATE All answers up till now has been misleading. Please follow the links and check the support page. It might also help to read the comment discussed to see why it's relevant and can not be inline.

marked as duplicate by Martijn Pieters, Danubian Sailor, Aziz Shaikh, hims056, Antony Jan 21 '14 at 12:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This is the actual text: <!-- language: lang-xml --> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" xmlns="w3.org/2000/svg" xmlns:xlink="w3.org/1999/xlink" xmlns:xhtml="w3.org/1999/xhtml"> <title>De mægtige vikinger</title> <defs> <xhtml:link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> </defs> </svg> – dotnetCarpenter Jan 21 '14 at 10:57
  • Where is it stated that comments support full markdown? The comment helptext is quite clear that it only supports a limited subset of markdown. Multi-line comments, let alone code in comments, is not supported. – Martijn Pieters Jan 21 '14 at 11:00
  • Code is meant to be in posts (questions and answers) rather than in comments. – Jerry Jan 21 '14 at 11:00
  • @MartijnPieters when you click help (next to the comment text area) and then Learn more... you get to the help page I linked to. If this is wrong - it should be fixed. – dotnetCarpenter Jan 21 '14 at 11:07
  • @dotnetCarpenter: The small help text starts with: Comments use mini-Markdown formatting. The 'Learn more...' page starts with Comments support only bold, italic, code and links followed with samples for all four of those types of formatting. The code sample uses ` backticks. – Martijn Pieters Jan 21 '14 at 11:09
  • @dotnetCarpenter When I click learn more on a comment I get sent to this link: stackoverflow.com/editing-help#comment-formatting, which is correct. I don't get sent to the quoted link – Richard Tingle Jan 21 '14 at 11:10
  • You're right. I misread the information as it's on the same page. Changing this to feature request. – dotnetCarpenter Jan 21 '14 at 11:14
  • @dotnetCarpenter Its usually best to ask a whole new question if you want to fundamentally change it – Richard Tingle Jan 21 '14 at 11:16
  • I've just updated the question. @RichardTingle Do you think it's fundamentally changed? – dotnetCarpenter Jan 21 '14 at 11:23
  • @dotnetCarpenter Well all the answers are now no longer applicable so I would say yes it has – Richard Tingle Jan 21 '14 at 11:24
  • @RichardTingle I see your point. I'll create a new question. – dotnetCarpenter Jan 21 '14 at 11:30
  • @dotnetCarpenter I think thats the best way forward, that way you get a clean slate to make your case. I've rolled this back to its previous version in that case – Richard Tingle Jan 21 '14 at 11:37
  • @RichardTingle How do I get my update text so I don't have to write it all again? – dotnetCarpenter Jan 21 '14 at 12:05
  • @dotnetCarpenter Its all saved in the revision history. Which you can get to by clicking on "edited 31 minutes ago", or by following this link. Clicking edit on your revision gives you the exact markdown it had at the time – Richard Tingle Jan 21 '14 at 12:08
  • @RichardTingle as a side note: Because this question had a <!-- language: lang-xml -->, the code is hidden. It kinda makes it difficult to see what the question is about. – dotnetCarpenter Jan 21 '14 at 12:10
5

Comments support only some markdown

Because comments do not support new lines they also don't support indentation. You can get limited code formatting using mini markdown and the backtick code format:

This comment has code: `int a=0;`, the variable `a` is set to 0

Becomes

This comment has code: int a=0;, the variable a is set to 0.

Code in comments shouldn't be overused

However, significant amounts of code should not be found in comments, since comments are to request clarification/critique to existing posts, not to offer solutions

Where to find more information

In addition to the formatting help document you quote the comments come with their own help, which you can access when adding a new comment (see below).

enter image description here

  • This comment has code: int a=0;, the variable a is set to 0 – Richard Tingle Jan 21 '14 at 10:59
  • The code in the comment is the minimum required to ask why the answer did not work. Inline code is too restrictive. In general markup languages just requires more text, than programming language. – dotnetCarpenter Jan 21 '14 at 11:05
2

Click 'show help' next to the comment box for a guide to mini-markdown formatting in comments:

Show Help

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