What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 122 Stack Exchange communities.

Sometimes, it can be useful to quote a different language to the one used in the question. For example, one might be interested in the C source code of a language interpreter in order to understand how it works and to find an answer to ones original question.

See This answer as an example.

An override syntax has been proposed. When will it be implemented? Will it fit this use case?

share|improve this question
    
Keep in mind that this only works on sites for which it has been enabled. If it's not active on your site, ask for it on your meta. –  jcolebrand Sep 29 '11 at 2:17
add comment

1 Answer

up vote 25 down vote accepted

This is now implemented. In addition to tag inference (a recent change), you can manually specify the language as a hint to Google Code Prettify.

The spec is:

<!-- language: lang-or-tag-here -->

    code goes here

<!-- language: lang-or-tag-here -->

    code goes here

You may use either a tag or a prettify language code to specify, though prettify language codes are always guaranteed to work regardless of what language the tag happens to be set to.

The complete list of supported prettify code languages is:

  • lang-none
  • lang-default
  • lang-bsh
  • lang-c
  • lang-cpp
  • lang-cs
  • lang-csh
  • lang-css
  • lang-hs
  • lang-html
  • lang-java
  • lang-js
  • lang-lisp
  • lang-lua
  • lang-ml
  • lang-perl
  • lang-php
  • lang-proto
  • lang-py
  • lang-rb
  • lang-scala
  • lang-sh
  • lang-sql
  • lang-vb
  • lang-xml
share|improve this answer
1  
this does not seem to be working for me for "none" see stackoverflow.com/questions/5187607/… –  Ian Ringrose Mar 7 '11 at 12:52
    
cs or csh is c#? –  TDaver Mar 7 '11 at 13:00
1  
@TDaver: I believe it is cs. csh would be the shell I would think. –  Jeff Mercado Mar 8 '11 at 1:18
    
@JeffAtwood: could you please add one for Java's property files? lang-sh seemed appropriate but doesn't do anything. It should highlight the "=" and use a different colour for "#"-comments. –  sjngm Mar 16 '11 at 8:23
    
@JeffAtwood: I tried <!-- language: lang-sh --> here, but it didn't work. –  sjngm Mar 16 '11 at 8:27
    
+1 for the language none! Comes in handy.. when you don't want highlighted stuff to be color coded! –  gideon Mar 20 '11 at 10:18
    
@sjngm did you put one blank line between the <!-- language ... --> and the code block itself? –  Shadow Wizard Mar 22 '11 at 12:20
    
@ShadowWizard: I had it without one and just tried with one, but it only colours the numbers differently. –  sjngm Mar 23 '11 at 8:16
    
@sjngm that's right... but it's not in our hands, that's how the external tool is coloring that language. You can mess around with this in the sandbox: meta.stackoverflow.com/questions/3122/formatting-sandbox/… –  Shadow Wizard Mar 23 '11 at 9:10
3  
@Jeff what's the best way to contribute a new language to that list? I'm mainly interested in pascal like syntax highlighting, and I'm willing to make the contribution myself. –  jachguate Mar 23 '11 at 14:33
1  
@jach do it at code.google.com/p/google-code-prettify –  Jeff Atwood Mar 23 '11 at 22:39
add comment

You must log in to answer this question.

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