7

When I enter a "preformatted" code block in a body of Q or A, I have the option to specify the language of this code like this:

```bash
#!/bin/bash
echo "something"
sleep 10
exit
```

so that the code block is colored (syntax highlighted) appropriately:

syntax highlighted code

I think the system can also color the code automatically by "guessing" about the contents of the code (I may be wrong about this).

Is there a complete list of all the "languages" (like bash, c, python, etc.) supported in AskUbuntu? There are cases where I do not want any coloring, like a simple text data; how can I indicate this?

3
  • 1
    have a look at highlightjs.org That is what is used. Use "none" for no formatting and the system looks at the tags used.
    – Rinzwind
    Apr 20, 2023 at 13:07
  • note to readers: syntax highlighting doesn't work on meta, making this post slightly less easy to understand than it ought to be!
    – Zanna Mod
    Apr 20, 2023 at 17:20
  • 1
    +3 to Rinzwind's comment - in particular, none is the most useful specifier of all!
    – Zanna Mod
    Apr 20, 2023 at 17:23

1 Answer 1

6

The answer is here: What is syntax highlighting and how does it work?

Note that lang-plaintext or lang-none explicitly disables syntax highlighting.

Quote from post edited 30 Aug, 2022.

Language codes currently available on Stack Exchange

This is a complete list of every identifier that you can use in a language hint for syntax highlighting. All the language identifiers in each group point to the same highlighter. Other language aliases set by highlight.js (in brackets) should work, but only identifiers before them are officially supported by Stack Exchange.

Format: Language name: lang-code, custom Stack Exchange aliases, (other Highlight.js aliases)

  • Plain text: lang-plaintext, lang-none, (lang-text, lang-txt) (explicitly disables syntax highlighting)
  • Bash and other shell scripts: lang-bash, lang-bsh, lang-csh, lang-sh
  • C and C-likes: lang-c, lang-cyc, lang-m, lang-c-like, (lang-h)
  • Clojure: lang-clojure, lang-clj
  • CoffeeScript: lang-coffeescript, lang-coffee, (lang-cson, lang-iced)
  • C++: lang-cpp, lang-cc, lang-cxx, (lang-c++, lang-h++, lang-hpp, lang-hh, lang-hxx)
  • C#: lang-csharp, lang-cs, (lang-c#)
  • CSS: lang-css
  • Dart: lang-dart
  • Delphi, Pascal: lang-delphi, (lang-dpr, lang-dfm, lang-pas, lang-pascal)
  • Erlang: lang-erlang, lang-erl
  • Go: lang-go, (lang-golang)
  • Haskell: lang-haskell, lang-hs
  • HTTP request/​response: lang-http, (lang-https)
  • INI, TOML: lang-ini, (lang-toml)
  • Java: lang-java, (lang-jsp)
  • JavaScript: lang-javascript, lang-js, (lang-jsx, lang-mjs, lang-cjs)
  • JSON: lang-json
  • Kotlin: lang-kotlin, (lang-kt, lang-kts)
  • LaTeX, TeX: lang-latex, lang-tex
  • Less: lang-less
  • Lisp: lang-lisp, lang-cl, lang-el, lang-lsp
  • Lua: lang-lua
  • Makefile: lang-makefile, (lang-mk, lang-mak, lang-make)
  • Markdown: lang-markdown, (lang-md, lang-mkdown, lang-mkd)
  • Mathematica / Wolfram Language: lang-mathematica, lang-mma, (lang-wl) (Mathematica SE only)
  • MATLAB: lang-matlab
  • Objective-C: lang-objectivec, (lang-mm, lang-objc, lang-obj-c, lang-obj-c++, lang-objective-c++)
  • OCaml, F#, SML and other ML-family languages: lang-ocaml, lang-fs, lang-ml
  • Perl: lang-perl, lang-pl, (lang-pm)
  • PHP: lang-php
  • PHP template (HTML+PHP): lang-php-template
  • Protocol Buffers: lang-protobuf
  • Python: lang-python, lang-py, lang-cv, (lang-gyp, lang-ipython)
  • R, S: lang-r, lang-s
  • Ruby: lang-ruby, lang-rb, (lang-gemspec, lang-podspec, lang-thor, lang-irb)
  • Rust: lang-rust, lang-rc, lang-rs
  • Scala: lang-scala
  • Scheme, Racket: lang-scheme, lang-scm, lang-ss, lang-rkt
  • SCSS: lang-scss
  • Shell session: lang-shell, (lang-console, lang-shellsession)
  • SQL: lang-sql
  • Swift: lang-swift
  • TypeScript: lang-typescript, (lang-ts, lang-tsx)
  • Visual Basic (.NET), VBScript: lang-vbnet, lang-vb, lang-vbs
  • VHDL: lang-vhdl, lang-vhd
  • XML, HTML and their derivatives: lang-xml, lang-html, lang-xsl, (lang-xhtml, lang-rss, lang-atom, lang-xjb, lang-xsd, lang-plist, lang-wsf, lang-svg)
  • YAML: lang-yaml, (lang-yml)
4

You must log in to answer this question.

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