2

I think the title is pretty clear. I'm not a SE expert so I'm not sure whether this is normal thing for a private beta website. But it's often helpful, especially since many of the questions on the site involve code.

2

syntax highlighting is now turned on.

0

Add the line <!-- language: <language_string> --> (where <language_string> is the string identifying the language) before the start of the code, and make sure that the code itself has an empty line before it:

<!-- language: <language_string> -->

    ...
    <line 1>
    <line 2>
    <line 3>
    ...

*<language_string> = string identifying the language

As suggested by muru, if you want to prevent the code from being formatted instead, you can add the line <!-- language: none -->:

<!-- language: none -->

    # ...
    echo This snippet will not be nicely formatted when copy-pasted inside a post
    # ...

bash example:

<!-- language: bash -->

    # ...
    echo This snippet will be nicely formatted when copy-pasted inside a post
    # ...

Courtesy of terdon, here's the list of the currently supported languages along with their identifying string (most of the languages listed won't need the lang- prefix):

none:      none
bash:      lang-bash OR lang-bsh
c:         lang-c
clj:       lang-clj
coffee:    lang-coffee
cpp:       lang-cpp
cs:        lang-cs
csh:       lang-csh
css:       lang-css
dart:      lang-dart
erlang:    lang-erlang
go:        lang-go
hs:        lang-hs
html:      lang-html
java:      lang-java
js:        lang-js
latex:     lang-latex
lisp:      lang-lisp
lua:       lang-lua
ml:        lang-ml
pascal:    lang-pascal
perl:      lang-perl
php:       lang-php
proto:     lang-proto
py:        lang-py
r:         lang-r
rb:        lang-rb
regex:     lang-regex
rust:      lang-rust
scala:     lang-scala
sh:        lang-sh
sql:       lang-sql
vb:        lang-vb
vhdl:      lang-vhdl
xml:       lang-xml

Finally, if the question is tagged with , , or - any of the ones listed above in fact, it will automatically format it. Example: https://askubuntu.com/questions/612100/help-me-with-if-condition

  • Yeah, thanks for that but the questions was actually "why" it doesn't work not "how" it works. – Kareem Apr 25 '15 at 20:21
  • Ahh okay, my mistake. – Tim Apr 25 '15 at 20:25
  • 1
    I've noticed the last few days that code seems to have highlighting now. Did this get implemented on the site recently? – Cliff B Jul 7 '15 at 21:29

You must log in to answer this question.

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