31

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.

3
  • 3
    +1 I have to google this every time I want to show some fixed-width output and mark it language-none. Commented Jul 18, 2012 at 23:01
  • Related: meta.stackexchange.com/q/72082/147645
    – JimmyPena
    Commented Jul 18, 2012 at 23:12
  • Splendid idea! I think people are having trouble finding this request. I can think of no other reason why there aren't hundreds of upvotes yet. I myself just stumbled across it. Please implement this!! I'm constantly editing the code of others to insert language tags. This would make it much easier. ;)
    – Chiramisu
    Commented Jan 18, 2018 at 22:56

1 Answer 1

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.

```bash  
for i in {1..10}  
do  
  echo "hello $i world"  
done  
```

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.

3
  • 2
    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
    Commented Jul 19, 2012 at 7:17
  • 1
    IMO ```bsh or similar would be a MAJOR improvement over <!-- language: lang-bsh -->, +1, although only slightly related to the question asked
    – Marijn
    Commented Jul 19, 2012 at 10:36
  • ```bsh could go instead of <!-- language: lang-‹tag› -->, I suppose?
    – Marijn
    Commented Jul 19, 2012 at 10:39

You must log in to answer this question.

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