Wasting a tag to properly format code

I just added a "c" tag to make sure the code blocks are properly shown. STM32 Sleep Mode: Interrupt gets executed but the CPU stays in WFI. In this case, there was plenty of room for tags, but in some cases there isn't. Also, users simply don't know that if they specify the language as a tag, their blocks will read better-- so they don't.

Is there not a better way to format code blocks that don't require us to waste a tag to specify the language. I can understand the need to specify language as a tag in a programming stack, but not here, where programming is usually a secondary issue.

• Jul 20, 2016 at 19:42
• I just use the PRE and /PRE tags. That seems to work. Jul 20, 2016 at 21:46
• You really shouldn't add tags for that purpose. Tags are for what a question is about, not what it contains. You do not need language specific identification to properly represent code. Seriously, if you cannot read code as easily without color highlighting as with, you are in the wrong business. Jul 21, 2016 at 13:10
• @ChrisStratton - yes, hence the question. Jul 21, 2016 at 13:14
• The answer is quite simple - do nothing, just use a proper code block. Jul 21, 2016 at 13:16
• ...and it's much more than highlighting, it's a full prettify, and it's pretty good. I'm not ashamed to say I find properly indented code much easier to read and correct. Jul 21, 2016 at 13:17
• I have added the "C" tag to get language-appropriate highlighting, then another user helpfully removed it. Ah well. Jul 27, 2016 at 1:07

2 Answers

This brings back memories....

As always, @dim makes good points as to how to explicitly set the code formatting language.

However, I will also add that if you can identify a tag where a lot of coding is involved in a dominant language, you can always bring it up on Meta.EE. At that point, we (the mods) can set the default code language for a tag. Lets be sensible here, meaning no code tags for .

• How about making the default language for all the microcontroller platform tags c or cpp? Jul 21, 2016 at 9:16
• @ScottSeidman Done for the first 10 pages of tags (or tags with >100 posts)
– W5VO
Jul 21, 2016 at 16:46
• Thanks! I can't see many negatives. Jul 21, 2016 at 18:34
• ti.com/ww/en/bobpease/assets/… Jul 27, 2016 at 1:10

Well first, I must say you just taught me something: I did not know the tag associated to a question was used by SE to guess which programming language is used and how to format/highlight code blocks. Thanks.

So I made some more research and found that: What is syntax highlighting and how does it work?. It explains that it is possible to explicitly override the highlighting defined by the tags by specifying a language hint above the code block:

<!-- language: lang-or-tag-here -->

code goes here


More info here.

• I think your answer is a very useful piece of digging/research. It might help a tiny bit more if you also point at the list of supported languages, e.g. How do I specify the language of my code?. It also says how to add line numbers which might help the community when there is code in a question. Jul 28, 2016 at 20:41