Some discussion about formatting code blocks in posts

Along with cpp you can also use other language hints (e.g.html, java, …) and depending on whichever you use code highliting might reflect the actual types of expressions better than others.
If you don’t provide a hint to the rendering engine, the highlighting may look better for one statement but get confusing for another.
So it’s up to preference and as a rule of thumb, after submitting the post checking how it turned out should become a habit and if you are not satisfied, you can always edit/tweak your own posts to better reflect your intent.

For example

// with cpp
int i = 10;
Serial.printlnf("some literal with number %d", i);
if (someCondition == true) 
  someCondition = false;

or

// with text
int i = 10;
Serial.printlnf("some literal with number %d", i);
if (someCondition == true) 
  someCondition = false;

or

// without but due to the content the engine makes a good educated guess 
//   but you never know beforehand ;-)
int i = 10;
Serial.printlnf("some literal with number %d", i);
if (someCondition == true) 
  someCondition = false;

(note Serial is now rendered differently than before with only one line provided)


I have now split this discussion off the original topic since it didn’t contribute to the original problem of
Electron reading digital pin state help request (novice)

5 Likes