134

For github, like for displaying a mysql `table_name`, in regular text use \` (backslash backtick) For showing backticks inside inline codeblocks `table_name` use double backticks with extra spaces `` `table_name` `` around the inner single backticks. To show the previous example explanation in an inline codeblock: `` `table_name` ``, surround the whole in ...


103

Correct, they should be used for code (and code-like artifacts). If that's the only change, and it's wrongly applied, reject as "no improvement whatsoever" or "causes harm". I don't have a problem with filenames, paths, API methods, commands, etc.–those are computery "artifacts" that should be differentiated from expository text. Products, trademarks,...


85

Use <pre> formatting and HTML tags. <pre> sample <b>sample</b> sample </pre> Gives: sample sample sample Since you can use other HTML tags as well, this is nice for including inline documentation for commands or classes, etc.: <pre> <i><a href="http://manpages.ubuntu.com/manpages/dapper/man1/prename.1.html"&...


53

You can use an extra backtick at the start and end to make sure it escapes correctly: ``List`1`` When inline it will display as List`1. Markdown provides backslash escapes for the following characters: \ backslash ` backtick * asterisk _ underscore {} curly braces [] square brackets () parentheses # hash mark + plus sign - minus sign (...


44

You can use a html comment to separate them. Source: a html comment <!-- tsk --> to separate them.


26

Is it rude? Yes. Mostly because that brace style is ugly as sin, but also because you're imposing your personal preferences on someone else's writing without good cause. But yeah, mostly because that brace positioning style sucks. That said, if doing so helps you trim down a code block so that it can be read without scrolling... AND you're making other ...


26

Autocorrect of i to I is a feature of Internet Explorer 10 which is turned on by default. To turn it off, go to the Tool icon, then Manage add-Ons, then click Spelling Correction and then uncheck the Enable spelling correction checkbox that appears.


25

The edit was primarily in reducing the number of empty lines. Screen real estate is still something to consider and in my opinion the editor made a good edit - more of the code is visible and can be read together with the rest of the question. Too much whitespace is something that reduces readability.


23

You can do it using HTML >! <pre><code>def invisible_function(): >! print 'Eeek! I feel so naked!'</code></pre> This results in some extra padding, though.


22

Since the indentation of the code is, in and of itself, a part of the problem, I wouldn't edit the indentation at all. I don't know if I feel strongly enough to roll back an edit of someone else who changed the indentation, but I would make a point of keeping my own hands off and address the problem(s) in the answer (or comments, depending on whether or not ...


21

No, code blocks have to be separated from ordinary text by a blank line. It's by design.


20

Disclaimer: I do not condone this, I'm just pointing out a possibility (for the sake of completion) Markdown-only hack The basic idea is to apply bold/italic formatting to backtick-enclosed string (instead of applying within the backticks), then put the code spans side by side so that they render as a single code span. Formatting (bold and italic) in ...


19

For fenced code blocks, the prescription is more backticks. This Markdown ```` ``` Example of Markdown syntax for fenced code block with triple back ticks ``` ```` will be rendered like this ``` Example of Markdown syntax for fenced code block with triple back ticks ```


19

I believe that code tags should be used for actual code or code keywords. I would reject or revert such edits. One exception I make is for file names and paths, as I feel these should be offset, and I suppose the argument could be made that file system commands are code.


19

Add the words "Fixed code formatting" in the edit summary description, instead of relying on the canned "added x characters to body" description, and the rejections will go way down.


19

As nobody mentioned any existing conventions on the use of the inline code spans, I decided to post my own response. Though the other answer is good, I hope I can provide more details. The content of this response is just my personal opinion. It summarizers my experience. I hope someone will find it useful. When the inline code spans should be used Any ...


19

They aren't, it was a bug. When making this change, I swear did read the spec to check for side effects of the change, but somehow the phrase "Lines are broken at newline characters" was able to cross my brain unharmed. Fixed now. Newlines, that is, not my brain.


19

I have now dragged in the lang-r stuff and set it against the r tag; there may be some small delay while the cache expires etc, but you should be able to explicitly specify it via: <!-- language: lang-r --> Once the cache has cleared (i.e. when it picks it up implicitly from r) you should also be able to specify it (when there is ambiguity) via: <...


18

In my opinion, this is a great idea (if it is implemented as optional). Maybe add to the current formatting directives; something like: <!-- language:lang-c ln:true --> or as a new indicator: <!-- language:lang-c --> <!-- ln:true/yes/false/no/etc... -->


18

If you're wondering why this edit was rejected, it's just because another user with full editing privileges edited at the same time as you. However, most of your other edits do a lot more than formatting. They change the code (fixing errors in the code, adding more code, etc.), which shouldn't be done in an edit. Instead, comment and say: Hey, you need ...


17

This makes no sense to me. Assume for example that the maximum height is 25 lines. You're suggesting a tolerance of three lines, meaning you don't get scrollbars before 28 lines -- that's like just increasing the maximum to 28 in the first place. Or possibly -- depending on how precisely you suggest to do this -- making a 29-line codeblock (with scrollbars) ...


17

The code highlighter takes a hint from the tagging of the question - so, if you tag a question with C#, it will attempt to use C# highlighting, if you tag it with SQL, it will try SQL highlighting. You can also provide language hints in your post, using one of the existing options.


17

The highlighting hint only works when it's placed immediately before the code block. When the code block is inside a list or blockquote, the hint also needs to be inside that list or blockquote. However, it looks like our system doesn't properly parse the hint if it's the very first thing in the blockquote. So this will parse out the hint and incorrectly ...


16

If you are familiar with the language, and can split lines without breaking the code, DO SO! In fact, if you can edit out nonsense that isn't relevant to the situation... from this: <DataGrid Name="ThisNameHasNothingToDoWithTheQuestion" RenderTransform="{StaticResource ThisQuestionIsntAboutTransforms}" Click="ClickWhatThisQuestionIsAboutBinding" ...


16

You must not have blank space after the first backtick or before the last backtick. In your comment to that answer you do have space before the last backtick: Apparently the code filter in the comments is different and more "strict" than the filter in the posts but this explains this issue. Whether by design or a bug, only developer can tell. :)


16

I wrote a custom stylesheet. It works in Google Chrome and should also work in Safari. Feel free to improve and hipsterize further (i.e. needs more filters). .prettyprint { color: #839496; background: #002b36 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAOMUlEQVR4Xu3dL/...


15

Note that if your XML doesn't get recognized despite the code block, you can add <!-- language: lang-xml --> before the code block. This has been elaborated in this page and further in here. Feature was added in 2011 so I realize it was not available at the time the question and the other answers were placed.


15

One of the the design goals for Markdown is that the source as well as the rendered version should be in a readable style. For this reason it uses existing conventions for marking up plain text from things like email (such as using stars for bold/italics and using a footnote style notation for links.) I believe this is the reason why indentation is used for ...


15

I'm guessing that the issue was because you mixed a lot of code with English. For example: Remember this are bitfields and & is the "bit and" operator NOT the boolean && GDK_WINDOW_STATE_ICONIFIED =2 or 10 on binary and event->new_window_state is an int which second bit is active A Widget can be both maximized AND minimized at the same time, ...


15

Try inserting another line break between each heading and the start of its code snippet, so ### Layout XML ### <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> becomes ### Layout XML ### <LinearLayout android:layout_width="fill_parent" android:...


Only top voted, non community-wiki answers of a minimum length are eligible