Several blogging systems now includes an optional syntax highlighting scheme for most common languages, including Python, Perl, Ruby, R, Matlab, etc. Code chuncks are post-processed using CodeRay, or Pygments, for example. Using Markdown language, we just have to indicate one of the available lexers and we get a nice rendering of the code. There are also javascript alternatives. This may also be used to automatically tag the different languages that are circulating on the SE. However, one potential drawback is that it may rely on users goodwill.

Another idea for larger snippets of code would be to put them on GitHub, as Gist. Again, on some blogging systems or CMS, giving the Gist URL allows to directly embed the code in the web page, as seen below.

alt text

What is your opinion about this possibility, especially with respect to language auto-tagging?

  • $\begingroup$ Great suggestion! @mbq has emailed the stack exchange team regarding this issue. $\endgroup$ Sep 6 '10 at 7:56

completed, but I don't know how well Google Prettify handles R code.

  • 1
    $\begingroup$ Thanks Jeff. It actually works pretty well on R code because of some similarities with C and use of the familiar # for comments. We could improve it if someone wrote an R extension as discussed at google-code-prettify.googlecode.com/svn/trunk/README.html $\endgroup$ Sep 6 '10 at 9:52
  • $\begingroup$ Has this feature been deprecated? R code chunks still seem to be "flat"? $\endgroup$
    – AdamO
    Dec 23 '18 at 14:09

You must log in to answer this question.

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