7
\$\begingroup\$

Recently I had quite a few edits to include the correct syntax-highlighting for C# questions:

<!-- language: lang-csharp -->

That's needless editing for a thing that could also be done via machine.

I suggest defaulting to lang-csharp for questions asked with .

Update:

Example question:

The above question highlights differently with lang-cs vs. lang-csharp (with lang-csharp being superior).

Issues:

  1. lang-csharp is not documented to exist
  2. it is not available in the tag-wiki syntax editor
\$\endgroup\$
0

2 Answers 2

7
\$\begingroup\$

I looked into what does the SE version of prettify.js actually do. Turns out, its list of C# keywords starts like this (only with minified names):

var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
  "as,base,by,checked,decimal,delegate,descending,dynamic,event," + …

This list is from an old version of prettify, the current version starts like this (the relevant change was made in June 2013):

var CSHARP_KEYWORDS = [COMMON_KEYWORDS,
  "abstract,as,base,bool,by,byte,checked,decimal,delegate,descending," + …

The reason why lang-csharp looks like it works, is because that's considered an unknown language and so it uses ALL_KEYWORDS, which includes bool through CPP_KEYWORDS. This also means that something like lang-nonsense would have worked the same way.

The fix should be to make SE update prettify to its current version.

\$\endgroup\$
1
0
\$\begingroup\$

lang-csharp is not available as a syntax for tags:

enter image description here

The current language for is lang-cs which is.... from here: C# ...

Are you sure you have the syntax right?


UPDATE:

Example question:

The above question highlights differently with lang-cs vs. lang-csharp (with lang-csharp being superior).

Issues:

  1. lang-csharp is not documented to exist
  2. it is not available in the tag-wiki syntax editor
\$\endgroup\$
6
  • \$\begingroup\$ relatively sure. For one I know that the current default syntax highlight doesn't go for bool, but lang-csharp does. \$\endgroup\$
    – Vogel612
    Aug 14, 2014 at 14:51
  • \$\begingroup\$ For the record I edited this question \$\endgroup\$
    – Vogel612
    Aug 14, 2014 at 15:01
  • 1
    \$\begingroup\$ The code highlighter is set to the "default" on all posts - if there is an override, it will use that (if it can't recognize a valid override). Which is a heuristic best effort highlight. \$\endgroup\$
    – Oded
    Aug 14, 2014 at 15:38
  • 2
    \$\begingroup\$ @Oded - FYI: meta.codereview.stackexchange.com/a/2279/31503 - lang-cs is out of date \$\endgroup\$
    – rolfl
    Aug 15, 2014 at 11:05
  • 1
    \$\begingroup\$ @rolfl - thanks for that. Will look getting it updated. \$\endgroup\$
    – Oded
    Aug 15, 2014 at 11:08
  • \$\begingroup\$ @rolfl - latest release is from March 2013 and is the one we are using. The changes highlighted are from June 2013 and have seen no release... yet. \$\endgroup\$
    – Oded
    Aug 15, 2014 at 15:35

You must log in to answer this question.

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