It seems that language syntax highlighting is not working.
As I think we will have many answers involving small code fragments. Is it possible to enable this?
I used <!-- language: lang-... -->
to specify the language in both cases.
It seems that language syntax highlighting is not working.
As I think we will have many answers involving small code fragments. Is it possible to enable this?
I used <!-- language: lang-... -->
to specify the language in both cases.
I mentioned this to an SE employee and they implemented it today! We now have working syntax highlighting!
Tags can have a specific language syntax associated with them. This is something that mods can set up. So, for example, if we were to ever have a perl or, more likely a bioperl tag, the mods could set it up so that it is associated with Perl syntax highlighting.
If a question isn't tagged with a tag that is associated with any specific syntax highlighting, we can still enable it using HTML comments. The syntax is as follows (using perl
as an example):
<!-- language: lang-perl -->
Each code block you want to have highlighted must have a comment like the one above, an empty line, and then the code. For example, this:
<!-- language: lang-python -->
var="foo"
Will be rendered like this:
import foo
var="bar"
otherVar = None
Each code block in a question or answer needs its own HTML comment, and you need a blank line between the comment and the first line of code, as shown above. Here's the list of currently supported languages and their identifying string (the lang
prefix is not needed if a tag has the language associated with it, but it won't harm it and we're unlikely to have many such tags anyway):
none: none ## Useful for disabling syntax highlighting
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
function
and the 1E6
of log(1E6)
. The one you hadn't set explicitly wasn't colored because I hadn't associated the tag R
with a language for syntax highlighting. I have now done so, so any future posts won't need the explicit <!-- language: lang-r -->
anymore.
$\endgroup$