13
$\begingroup$

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?


Edit:

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

$\endgroup$
  • 2
    $\begingroup$ Yes, we do need code highlighting. $\endgroup$ – pyramids Mar 29 '18 at 8:38
  • $\begingroup$ Is there code-highlighting on other sites on SE? $\endgroup$ – Discrete lizard Mar 29 '18 at 11:37
  • $\begingroup$ @Discretelizard Stack Overflow, Code Review, Super User, maybe some other. $\endgroup$ – u32i64 Mar 29 '18 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 Mar 30 '18 at 9:24
  • 1
    $\begingroup$ @Mithrandir24601 Actually, Q# syntax resembles F# a lot more than C#. $\endgroup$ – Pavel May 7 '18 at 16:50
9
$\begingroup$
  • 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.

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
-1
$\begingroup$

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)

$\endgroup$

You must log in to answer this question.

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