15

Is there a reason that inline-code (with ``, of course) in answers is excluded from the prettify-process?

Sometimes a piece of code is a bit too small to be blessed with its own blockquote, and so it's merely streamed inline with the rest of a paragraph, but having syntax-highlighting on it would still help to break up the different parts of the code.

(For the record, I don't think this should be included in comments — which has already been discussed here.)

Or does there already exist a way to prettify inline code? (The language of code blocks can be explicitly set with <!-- language: ... -->; could this also be allowed for inline code?)

1

5 Answers 5

4

It's the difference between this:

SuperFunction()

System.DoesItWork

and this:

SuperFunction() System.DoesItWork

The former is (or should be coloured) the latter isn't.

BTW - I vacillate when it comes to this question. Sometimes I'm happy with the way it looks, but other times I wish is was coloured. I think it has to do with the actual words I'm using. If the keywords are normal English then I want them to stand out more. If they're obviously code then I'm happy.

1
  • 3
    This answer doesn't actually answer the question, which is "Is there a reason that inline-code ... is excluded from the prettify-process?" This answer just restates the question's problem.
    – Max Nanasy
    Nov 8, 2013 at 20:26
7

I think that the thing with inline code is that it is usually too short a snippet to need syntax highlighting. With long code snippets, this is often useful, since the snippets can be several lines long. However, with inline code, it is often for short keywords or short snippets that, as you say, are too small to be put in their own blockquote.

Normally I use inline snippets for variable names or class names, for instance, and they don't really need colouring as they are only one or two words. If it is hard to read the code and it needs to be broken up to better understand it, then it's probably better to put it on its own line anyway.

1
  • 1
    I used the ternary operator the other day - would have loved some color-coding there :)
    – Sampson
    Jul 6, 2009 at 13:28
3

Foreground coloration for syntax on inline code would be okay (I lived without out it just fine), but I really hate the background coloration. Inline code is inline because it's supposed to flow with the enclosing text. Changing the background color destroys that continuity and impairs readability.

I agree with Perspx: inline code isn't really for "code", at least not for code complex enough to benefit from syntactic analysis. It's just to set apart keywords, identifiers, and options from surrounding text. If it's more complex than that, make it a block quote.

3
  • 2
    many, including Jon Skeet, felt the font alone was not enough to distinguish the inline code. Oct 2, 2009 at 5:01
  • Argument from authority?
    – erickson
    Aug 31, 2011 at 0:39
  • Jeff's style of arguing. But in all seriousness, there's a social hierarchy put in place, simulated with rep that weights users contribution. Which means that naturally higher rep people have more say in how the site works. The privileges are spoken, but there are also unspoken privileges as well. Oct 5, 2012 at 13:12
0

Hmm, this could help differentiate inline code from regular text, especially in block quotes..

-3

If I am not mistaken you -can- do syntax highlighting on code in a paragraph (example, I cam now going to call my SuperFunction() right now). All I did was select my little bit of code and hit the code button and it will perform syntax highlighting on it.

Here is another example, this time using my System.DoesItWork value.

Note: This can be achieved by putting backticks on both ends of your little code sample.

If you are speaking of actual color-specific items (like certain parts of code showing red, others blue, etc.) then I could see your point.

3
  • No - it's not come out coloured for me.
    – ChrisF Mod
    Jul 6, 2009 at 13:09
  • Not colored for me either.
    – Sampson
    Jul 6, 2009 at 13:10
  • 3
    Yeah, I'm referring to actual coloring of the different parts. Distinguish $foo from "bar".
    – Sampson
    Jul 6, 2009 at 13:37

You must log in to answer this question.

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