133
votes
Accepted
What is syntax highlighting and how does it work?
What is syntax highlighting?
Syntax highlighting allows code in posts to be highlighted based on the language it's written in, to make it easier to read.
How does it work?
Stack Exchange does not have ...
Community wiki
79
votes
Please update the Google Prettify syntax-highlighting library
Stack Overflow should start its own fork of code-prettify, or move to a different solution.
Most pull requests don't get reviewed or merged in the Google repository anymore.
There are more missing C# ...
75
votes
Accepted
Should we approve suggested edits that change ``` to four spaces code formatting or vice versa?
No. Edits like those should be rejected for not making a meaningful improvement or making the post easier to read.
Edits that only change formatting are appropriate in very narrow circumstances, such ...
55
votes
Accepted
Is serially editing posts to include syntax highlighting helpful?
I'm strongly in favour of edits like this. Syntax highlighting, tab-size consistency and wrapping to avoid horizontal scrolling can make a significant difference to the legibility of a code sample — ...
52
votes
Accepted
Highlighting parts of code
It's possible with HTML
1) A code block
Emphasis on this
<pre><code>Emphasis on <b>this</b>
</code></pre>
2) Inline code: Emphasis on this
Inline code: <...
52
votes
How does the highlight.js change affect Stack Overflow specifically?
My recommendation: If you know the language, go ahead and explicitly set it.
Even on posts where the question includes exactly one language tag? So far, language tags overrode the heuristic for ...
51
votes
Accepted
Cannot get single block syntax highlighting to work
The comment has to be put on a separate line, with blank lines before and after (e.g. its own Markdown paragraph):
C source:
<!-- language: lang-c -->
int main(void)
{
return ...
29
votes
Should we approve suggested edits that change ``` to four spaces code formatting or vice versa?
No. These types of edits should be rejected, especially now that this type of formatting actually results in proper code formatting, and not half-broken formatting.
These types of edits make ...
27
votes
Accepted
New syntax highlighting just got me color blind
TL;DR - This was not an intended change. A build is being deployed now that corrects it.
This is the default prettify theme but not the one Stack Overflow has used for...well, pretty much always. ...
25
votes
C++ tag variants do not highlight syntax
Braiam is right: the solution here is to tag all questions with the c++ tag, and then you'll automatically get syntax highlighting appropriate for the C++ tag.
This is just another special case of ...
Cody GrayMod
- 231k
24
votes
Do you edit questions in order to provide syntax highlighting?
Yes, this is fine.
The "too minor" edit reject phenomenon is a disease to be wiped out. The Stack Exchange servers can handle multiple incremental edits being made rather than one big one, so ...
24
votes
Accepted
Why isn't there support for Visual Basic syntax?
There is support for VB syntax highlighting:
Dim text As String = "Hello, World" 'The text variable holds Hello, World
Questions where the only language tag is vb.net or vba should highlight ...
23
votes
New syntax highlighting just got me color blind
I completely agree.
I'm normally hanging about doing something or other with the python tag and I've certainly noticed the difference. Maybe we're just spoilt by highlighting - but to me, this is ...

Jon ClementsMod
- 132k
23
votes
Accepted
Revert new syntax highlighting
Based on this overwhelming feedback, I reverted the colors from the other day, though I did slightly brighten the previous "maroon" color that was being used just to help differentiate from black. The ...
23
votes
Accepted
What should we expect from syntax highlighting auto-detection?
There are 2 main parts to this:
When highlight.js is used to detect a language, if it is given no constraints on languages to choose from, it will choose the language that results in the most ...
22
votes
Accepted
'get' in a code tag does not render properly as a keyword
That is a bug in the Prettify highlighter, and unfortunately bugs should be reported on their GitHub project, as explained in What is Syntax highlighting and how does it work?. I went ahead and made ...
22
votes
Shell: make prompt # and $ uncopiable
Honestly, this is a terrible idea all-around. The devs would have to deal with questions like:
How would you tell that it's bash? In many languages, $ is usable in variable names and # means a ...
20
votes
Accepted
How to compose yellow background blockquote?
This is a standard blockquote.
The Markdown syntax is to precede the text with a >. You can achieve the same effect in the editor by highlighting the block of text and clicking the quotation-mark ...
Cody GrayMod
- 231k
20
votes
Accepted
Is the following HTML comment necessary?
This edit added syntax highlighting to the code blocks. (This makes different parts of the code change color based on its function: upper case words are one color, numbers another, and keywords a ...
19
votes
What is the default language for the syntax highlighter?
Note: Since Stack Overflow's migration to Highlight.JS, the default is based on Highlight's automatic language discovery and best-effort highlighting.
This answer is no longer applicable, but left ...
19
votes
How does the highlight.js change affect Stack Overflow specifically?
This has already been asked on MSE1 but I think it belongs here, given how important this is for SO:
What will the update cycle be?
I’m asking because the current status of highlight.js language ...
18
votes
SO renderer breaks Makefile syntax
There's a workaround, as per mbomb007's answer to the Meta Stack Exchange feature request. Writing this:
<pre><code>Hello!
This is a tab:	:bat a si sihT</code></pre>
...
17
votes
Accepted
Syntax Errors in Code Renderer?
The syntax highlighter didn't pick up that you wanted Java highlighting. Instead, it seems to be interpreted as HTML (probably because it begins with a <). HTML attributes are set to be colored red,...
17
votes
Accepted
Trailing backslash in strings breaks code formatting
The PowerShell tag is using lang-bsh as its prettifier.
There is an open issue over on GitHub with an initial commit for a PowerShell prettifier. I linked to that item in an answer I wrote over on ...
17
votes
Accepted
Do I remove syntax highlighting for sample input/output?
For data, input text, output text, and errors, use code formatting with no syntax highlighting. Syntax highlighting is only intended for use on the specific code language which it's highlighting. If ...

MakyenMod
- 29.7k
17
votes
Accepted
The revision history does not show the latest content correctly
A hotfix is now in place for this bug on both the /posts/{id}/revisions and /review/suggested-edits/{id} pages. Revisions will now be highlighted correctly in code blocks:
This is a problem with ...
15
votes
Enable JavaScript syntax highlighting for questions tagged with [meteor]
Please no. Those are special cases, and allowing some of them will only trigger more requests in the future (e.g. what about angularjs? why not do the same for python's highlighting to numpy questions?...
15
votes
Revert new syntax highlighting
In order to be constructive, I'll try to provide a couple of (subjective) propositions:
The color of types, properties and methods (#0096e2) is now very close indeed to the color of unvisited ...
14
votes
MATLAB syntax highlighting?
MATLAB syntax highlighting is now live!
Add syntax highlighting for the MATLAB language
This is the "lite" version of @Amro's prettify script which does not include complete keyword highlighting (...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
syntax-highlighting × 322feature-request × 148
bug × 88
support × 77
status-completed × 77
tags × 56
discussion × 46
code-formatting × 26
markdown × 12
design × 8
status-declined × 7
status-bydesign × 7
edits × 6
code × 5
suggested-edits × 4
stack-snippets × 4
editor × 4
markdown-rendering × 4
meta × 3
tag-wiki × 3
editing-help × 3
formatting × 3
specific-question × 2
status-deferred × 2
review × 1