Moderators can set the default syntax highlighter on tags by selecting a value from a drop-down list:
The community maintains a list of supported languages by inspecting the Highlight.js code file served by Stack Exchange: What is syntax highlighting and how does it work?
You would expect the dropdown list and supported languages to be in sync.
It turns out that is not the case, first observed by Cody Gray on Request to set the TOML tag to default syntax highlighting to lang-toml.
Here is the comparison between the values selectable by moderators and the supported language according to the FAQ post.
Moderator option missing, and syntax highlighting is available
Mod option | Syntax highlighting |
---|---|
lang-atom | |
lang-cc | |
lang-cjs | |
lang-cl | |
lang-clojure | |
lang-coffeescript | |
lang-console | |
lang-csharp | |
lang-cson | |
lang-cv | |
lang-cxx | |
lang-cyc | |
lang-delphi | |
lang-dfm | |
lang-dpr | |
lang-el | |
lang-erl | |
lang-fs | |
lang-gemspec | |
lang-go | |
lang-gyp | |
lang-h | |
lang-haskell | |
lang-hh | |
lang-hpp | |
lang-http | |
lang-https | |
lang-hxx | |
lang-iced | |
lang-ini | |
lang-ipython | |
lang-irb | |
lang-javascript | |
lang-json | |
lang-jsp | |
lang-jsx | |
lang-kt | |
lang-kts | |
lang-less | |
lang-lsp | |
lang-m | |
lang-mak | |
lang-make | |
lang-makefile | |
lang-mathematica | |
lang-md | |
lang-mjs | |
lang-mk | |
lang-mkd | |
lang-mkdown | |
lang-mm | |
lang-mma | |
lang-none | |
lang-objc | |
lang-ocaml | |
lang-pas | |
lang-pl | |
lang-plaintext | |
lang-plist | |
lang-pm | |
lang-podspec | |
lang-protobuf | |
lang-python | |
lang-rc | |
lang-rkt | |
lang-rs | |
lang-rss | |
lang-ruby | |
lang-s | |
lang-scheme | |
lang-scm | |
lang-scss | |
lang-shell | |
lang-shellsession | |
lang-ss | |
lang-svg | |
lang-tex | |
lang-text | |
lang-thor | |
lang-toml | |
lang-ts | |
lang-tsx | |
lang-txt | |
lang-typescript | |
lang-vbnet | |
lang-vbs | |
lang-vhd | |
lang-wl | |
lang-wsf | |
lang-xhtml | |
lang-xjb | |
lang-xsd | |
lang-xsl | |
lang-yml |
Moderator option available, but no available syntax highlighting
(I can't easily check if a moderator ever selected those two options, but if they did, I consider this now a data error. This might need fixing as well, preferable by adding highlighters for proto and regex, but if that is too much of a stretch then I propose to remove the language setting from those tags.)
Mod option | Syntax highlighting |
---|---|
lang-proto | |
lang-regex |
Moderator option matches available syntax highlighting
Mod option | Syntax highlighting |
---|---|
lang-bsh | lang-bsh |
lang-c | lang-c |
lang-clj | lang-clj |
lang-coffee | lang-coffee |
lang-cpp | lang-cpp |
lang-cs | lang-cs |
lang-csh | lang-csh |
lang-css | lang-css |
lang-dart | lang-dart |
lang-erlang | lang-erlang |
lang-golang | lang-golang |
lang-hs | lang-hs |
lang-html | lang-html |
lang-java | lang-java |
lang-js | lang-js |
lang-kotlin | lang-kotlin |
lang-latex | lang-latex |
lang-lisp | lang-lisp |
lang-lua | lang-lua |
lang-markdown | lang-markdown |
lang-matlab | lang-matlab |
lang-ml | lang-ml |
lang-objectivec | lang-objectivec |
lang-pascal | lang-pascal |
lang-perl | lang-perl |
lang-php | lang-php |
lang-py | lang-py |
lang-r | lang-r |
lang-rb | lang-rb |
lang-rust | lang-rust |
lang-scala | lang-scala |
lang-sh | lang-sh |
lang-sql | lang-sql |
lang-swift | lang-swift |
lang-vb | lang-vb |
lang-vhdl | lang-vhdl |
lang-xml | lang-xml |
lang-yaml | lang-yaml |
I would prefer if the first two tables would have no entries and all available combinations were matched in the last table.
Can you update and align both the Highlight.js code and the option list of the select input with id lang-class-value
?
Here is the code used to produce the three tables:
void Main()
{
var modOptionSet = GetValues(new Regex("\"(lang-\\w+)\""), GetModOptions());
var highlightSet = GetValues(new Regex("`(lang-\\w+)`"), GetHighlightJSLang());
highlightSet.Remove("lang-code"); // lang-code is used as an example
OutputSet("Mod option missing", highlightSet.Except(modOptionSet), "| | {0}");
OutputSet("Highligthing is missing", modOptionSet.Except(highlightSet), "| {0} |");
OutputSet("Okay", modOptionSet.Intersect(highlightSet), "| {0} | {0}");
}
private void OutputSet(string title, IEnumerable<string> items, string format)
{
Console.WriteLine(title);
Console.WriteLine("| Mod option | Syntax highlighting");
Console.WriteLine("|-|-");
foreach(var item in items) {
Console.WriteLine(format, item);
}
Console.WriteLine();
}
private HashSet<string> GetValues(Regex regex, string value)
{
var list = new HashSet<string>();
foreach(Match match in regex.Matches(value))
{
list.Add(match.Groups[1].Value);
}
return list;
}
private string GetModOptions() {
return new HttpClient().DownloadString(@"https://pastebin.com/raw/hKudvBMq");
}
private string GetHighlightJSLang() {
return new HttpClient().DownloadString(@"https://api.stackexchange.com/2.3/posts/184109?order=desc&sort=activity&site=meta&filter=!)qCrPFKQawtVrr(YU3kc");
}
class HttpClient:WebClient
{
static HttpClient() {
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
protected override WebRequest GetWebRequest(Uri uri)
{
var request = (HttpWebRequest) base.GetWebRequest(uri);
request.AutomaticDecompression = DecompressionMethods.GZip;
return request;
}
}