I've seen some posts that include code (Python, Q# (see Are questions about Q# on topic?)):

The question is: Do we need code highlighting on this site to improve the code readability?


As an extension to this, to make it more up to date, there have since been other questions where it could potentially be useful, specifically using the tag:

As well as a few other examples that use a smaller amount of code

  • $\begingroup$ Is there code-highlighting on other sites on SE? $\endgroup$ Commented Mar 29, 2018 at 11:37
  • $\begingroup$ @Discretelizard Stack Overflow, Code Review, Super User, maybe some other. $\endgroup$
    – user609
    Commented Mar 29, 2018 at 15:53
  • $\begingroup$ While (in my opinion) it would be nice, it's very likely that Prettify (what SE uses for this) doesn't have full Q# highlighting, so we'd be limited to standard C# syntax highlighting $\endgroup$
    – Mithrandir24601 Mod
    Commented Mar 30, 2018 at 9:24
  • 1
    $\begingroup$ @Mithrandir24601 Actually, Q# syntax resembles F# a lot more than C#. $\endgroup$
    – Pavel
    Commented May 7, 2018 at 16:50
  • $\begingroup$ I've edited the title to more clearly reflect the request being made. $\endgroup$
    – V2Blast
    Commented Dec 23, 2022 at 18:21

4 Answers 4

  • StackOverflow has syntax highlighting, but does not have $\LaTeX$, that makes it difficult to reason about the code in terms of $|quantum\rangle \otimes |states\rangle$.

  • This community has $\LaTeX$ but does not yet offer syntax highlighting, that everyone has got used to these days.

A community that gets both would be a perfect place for Q&A on quantum computing libraries/languages.

Moreover, the libraries/languages that implement quantum computing concepts have become essential tools for quantum computing researchers.

So, I vote for syntax highlighting.


The feedback below has historical significance ever since we changed from the Google Prettyfier to : "Goodbye, Prettify. Hello highlight.js! Swapping out our Syntax Highlighter", see here for more information: "What is syntax highlighting and how does it work?".

Even if it was enabled, its support for Quantum Computing languages is little or next to none; since using an incorrect hint can provide partial highlighting in some instances. There are no 3rd party projects implementing any Quantum Computing languages, and even when languages are supported they are not always enabled.

Requests that affect a single site are usually declined, but for a workaround the highlighting for another language can be substituted.

Historical Feedback:

We might want Highlighting in the future, the FAQ (Markdown Help) shows that it adds useful features. It will be a question of how much code there will be, which languages, and how much BTS we can help with.

The SE sites use Google Code Prettify only.

In the Meta.SE post Changes to syntax highlighting it is written:

"(all specific languages must be in the set that prettify supports, obviously)

bsh, c, cc, cpp, cs, csh, cyc, cv, htm, html, java, js, m, mxml, perl, pl, pm, py, rb, sh, xhtml, xml, xsl.

extensions available are

apollo, css, go, hs, lisp, lua, ml, proto, scala, sql, vb, vhdl, wiki, yaml".

Posted by: Jeff Atwood, Locked by: Shog9.

Glimmer of hope: Diamond moderators can now change syntax highlighting on a per-tag per-site basis. We're also looking at an in-source override syntax soon. – Jeff Atwood Feb 21 '11 at 22:27

Google Prettify FAQ

  • For which languages does it work?

The comments in prettify.js are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, JavaScript, Makefile, and Rust.

It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and Ruby, but because of commenting conventions, doesn't work on Smalltalk, OCaml, etc. without a language extension.

Other languages are supported via extensions:

Apollo; Basic; Clojure; CSS; Dart; Erlang; Go; Haskell; Lasso; Lisp, Scheme; LLVM; Logtalk; Lua; MATLAB; MLs: F#, Ocaml,SML; Mumps; Nemerle; Pascal; Protocol buffers; R, S; RD; Rust; Scala; SQL; Swift; TCL; LaTeX; Visual Basic; VHDL; Wiki; XQ; YAML

If you'd like to add an extension for your favorite language, please look at src/lang-lisp.js and submit a pull request.

So ...

Step 1: Write the extension for each language we are going to support.

Step 2: Submit your extension.

Step 3: Convince SE to activate Highlighting here, and use your extensions.

Note: Here is a question that features Highlighting: "PyObject_CallMethod Returns Null, Simple Example Provided", nothing is clickable nor does it have a run button. For the work involved getting Highlighting here we might just work on a MathJaxifier Script that highlights the code offline for copy/pasting.


Syntax highlighting is now enabled on your site. Note that there is no default language currently selected, so site moderators will need to select one on a per-tag basis.

Mods: Not a super hard process. Go to any tag's page, click "Learn more..." and you should see the options there.

Circled "learn more" on a tag page.

And the controls...

Circled the default syntax highlight language controls on the per-tag page.


In only one of the pages referenced, we have a rather large codeblock and even that one is perfectly readable without syntax highlighting.

I don't think there are going to be much questions or answers with large codeblocks and hence I don't think that syntax highlighting is required (it most certainly isn't as essential as $\LaTeX$ support)


You must log in to answer this question.