What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

I saw on another question that mods have access to a nice pick-list for languages in certain scenarios (this one was about setting the default language for tags):

enter image description here

I'd love to be able to use such a pick-list when formulating a question or answer, so that I can set all code samples in my post to a specific language (regardless of the default language for the overriding tag). This way I don't have to remember this list above when manually typing in my own <!-- language: ... or <!-- language-all: ... HTML comment/entity. Ideally it would be a list in the WYSIWYG editor, and it would insert the chosen language complete with the surrounding entity syntax, but I'd be perfectly happy with just seeing the list of valid languages instead of having to memorize them.

Note, of course, that I'm not asking at all for the ability of peons to change the default language associated with a tag. Just for the ability to pick the formatting for my post using a nice convenient list instead of trying to remember the syntax.

In addition to addressing my laziness and forgetfulness, I also think this would make such ability much more visible to less experienced users, who might not know that they even have the possibility of setting the language and/or aren't aware that the syntax highlighting behaves differently at all for different languages. I often see SQL code that's highlighted for C# and vice-versa, and I don't always have the motivation to fix it for precisely these reasons.

As an aside, I'm not sure this list is complete. I'm fairly certain I used PowerShell recently.

share|improve this question
+1 I have to google this every time I want to show some fixed-width output and mark it language-none. –  Jonathon Reinhart Jul 18 '12 at 23:01
Related: meta.stackexchange.com/q/72082/147645 –  JimmyPena Jul 18 '12 at 23:12

1 Answer 1

FWIW, GitHub makes this incredibly simple. Search http://github.github.com/github-flavored-markdown/ for 'Syntax Highlighting'. Just specify the language name at the top of the code fence.

for i in {1..10}  
  echo "hello $i world"  

Boom. Bash syntax highlighting.

Maybe not as simple as a dropdown picker (Is it js? javascript? ecmascript‽) but certainly you can type a few ideas in and watch the live preview suddenly colorize when you get it right.

share|improve this answer
Here you just need <!-- language: lang-‹tag› --> See this answer as well in the Q above. And this approach doesn't work with the normal approach of four space indent for code. –  Richard Jul 19 '12 at 7:17
IMO ```bsh or similar would be a MAJOR improvement over <!-- language: lang-bsh -->, +1, although only slightly related to the question asked –  Marijn Jul 19 '12 at 10:36
```bsh could go instead of <!-- language: lang-‹tag› -->, I suppose? –  Marijn Jul 19 '12 at 10:39

You must log in to answer this question.

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