10
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ related: electronics.stackexchange.com/editing-help#syntax-highlighting \$\endgroup\$ – Nick Alexeev Jul 20 '16 at 19:42
  • 1
    \$\begingroup\$ I just use the PRE and /PRE tags. That seems to work. \$\endgroup\$ – Olin Lathrop Jul 20 '16 at 21:46
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Jul 21 '16 at 13:10
  • \$\begingroup\$ @ChrisStratton - yes, hence the question. \$\endgroup\$ – Scott Seidman Jul 21 '16 at 13:14
  • \$\begingroup\$ The answer is quite simple - do nothing, just use a proper code block. \$\endgroup\$ – Chris Stratton Jul 21 '16 at 13:16
  • 2
    \$\begingroup\$ ...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. \$\endgroup\$ – Scott Seidman Jul 21 '16 at 13:17
  • \$\begingroup\$ I have added the "C" tag to get language-appropriate highlighting, then another user helpfully removed it. Ah well. \$\endgroup\$ – markrages Jul 27 '16 at 1:07
4
\$\begingroup\$

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 .

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

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – gbulmer Jul 28 '16 at 20:41

You must log in to answer this question.

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