When I include code sampleswithin a phrase of one of my answers, I find it hard to see that code from the rest of the phrase.
Because of this, I like to put quotes around code, like this: 'code sample', or this: "code sample".

Since we already have a shortcut for making text a code sample (CTRL+K), I would like to reuse that shortcut in order to put quotes around it.

That would mean the following phrase:

my clever answer with a code sample function() call in it

would become, with 'code sample function()' highlighted:

firstCTRL+K:

my clever answer with a code sample function() call in it

(just like today)

secondCTRL+K:

my clever answer with a "code sample function()" call in it

(oh! I see now you function() call)

thirdCTRL+K:

my clever answer with a 'code sample function()' call in it

(a more subtle way to signal the code sample part of the phrase)

fourthCTRL+K:

my clever answer with a code sample function() call in it

(back to normal, no more <code> around the text, just like today, and you can then repeat the cycle)

I have tested this feature in my own version of WMD and it works great (see my answer below).
But before bugging Dana.E.Robinson with a patch, I would like to see what the community thinks about this proposition.

I'm not sure why you have said in several comments that color or border is not possible. It would be a simple CSS rule. I've created a Greasemonkey script that does this, actually: meta.stackexchange.com/questions/15429/…
–
KipAug 19 '09 at 13:18

1

Blast from the past :) Im tagging this status-status completed, since we eventually went with Jon's suggestion a long time ago. It doesn't fulfill your request as stated, but it solves your issue.
–
balpha♦Sep 13 '12 at 7:24

Tell me about it. The "we" in my comment is actually a lie. Back in those days, I was just a smartass running around on Meta. I still am, but these days I get payed for it ;)
–
balpha♦Sep 13 '12 at 9:51

4 Answers
4

I have a different preference for how code-in-text could be formatted: change the background colour for that section of the text too. That's a lot clearer than quotes in my view, as well as not interfering with code which uses quotes.

If the html code allowing this is supported, it can be coded following the same principle I describe in my patch.
–
VonCJul 5 '09 at 20:06

> as well as not interfering with code which uses quotes. That is why I propose double or simple quotes. Now if your code uses both... it should be isolated in its own section, not within a phrase ;)
–
VonCJul 5 '09 at 20:08

But even if it does only use one type of quote, introducing the other one makes it more confusing to read, IMO. Background colour is visually orthogonal to the characters being displayed, which is why I think it would work well.
–
Jon SkeetJul 5 '09 at 20:09

It would just be a matter of either accepting the relevant attribute for <code>, I expect. Anyway, given that this is a feature request I think it's reasonable to request the feature we (well I) think would look best, rather than one which is just a bit easier :)
–
Jon SkeetJul 5 '09 at 20:24

i agree with skeet here, i suggested the same thing on UV a while back and it was closed with no explanation.
–
KipJul 5 '09 at 20:27

++ for this suggestion. I hate seeing quoted code, and will actively edit it out in preference to backtick / <code> quoting. IMHO, it only leads to problems...
–
Shog9♦Jul 5 '09 at 20:51

@Shog9: I assume you mean in terms of whole statements/expressions? I use backticks mostly to refer to just method/class names (usually with links). Do you mind those as well?
–
Jon SkeetJul 5 '09 at 21:19

Sorry, i meant that i like backtick-quoted code - it's fairly easy to read, select, copy. I don't care for "" or '' quoted code; it makes a paragraph look cluttered, and tends to be more difficult to select without catching the quotes (and as you note, can lead to confusion if the code itself contains quotes). I don't really draw a distinction between inline expressions and inline functions/symbols when formatting.
–
Shog9♦Jul 5 '09 at 23:06

@Jon, @Shog9: the only reason I propose quotes or double quotes is because this is the ONLY possible addition currently possible which will not be stripped from the end result HTML. Color or border are better... but impossible for the moment. My theory is: you do not have to copy paste inline code that much anyway (so quotes do not get in the way). Code to be copied should be in its own section. Again, if color or border are possible, I would drop the quotes immediately in favor of those solutions.
–
VonCJul 6 '09 at 5:44

Yes, if it's not readable simply the stylesheet should be changed.
–
sthJul 5 '09 at 23:32

I like that style. Simple, not intrusive, yet stands out just that extra little bit.
–
lc.Jul 6 '09 at 4:57

@dbr: the only reason I propose quotes or double quotes is because this is the ONLY possible addition currently possible which will not be stripped from the end result HTML. Color or border are better... but impossible for the moment.
–
VonCJul 6 '09 at 5:38

I've noticed that inline code (using either the code tag or backticks) is hard to differentiate from regular text. Can you add a light background-color to code tags so that they stand out a little more?

@Kip: the only reason I propose quotes or double quotes is because this is the ONLY possible addition currently possible which will not be stripped from the end result HTML. Color or border are better... but impossible for the moment.
–
VonCJul 6 '09 at 5:41

I said color or border are impossible at the moment because any style HTML directive added during the redaction of a question/answer are stripped. As for changing the CSS stylesheet... your greasemonkey script is there to illustrate that, but I would not hold my breath.
–
VonCAug 19 '09 at 16:47