Thanks for the link to formatting, good stuff there even for folks who have been posting for a while.
One question, the instructions say you need to wrap code samples in three elipses and “cpp” but as you can see below, the cpp part does not seem to make a difference. Has the system changed since the original post was made or am I doing this wrong?
These are no ellipses (commonly written with three consecutive dots ...) but three consecutive accent grave
``` (as opposed to ...)
So done correctly your code would look like this
Serial.println("With ```cpp");
and
Serial.println("With only ```");
or
Serial.println("With ```text");
But you are actually using the correct symbols (accent grave) - the problem tho’ is that you also have extra text following the tag (i.e. a blank).
The special format tags need to be all alone on their line without any extra characters (visible or not) leading or trailing.
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 wasn’t saying - or at least didn’t mean - to put cpp on its own line but the grave accents and the cpp
Like
```cpp <-- nothing before and after these six characters (these six form the opening tag)
...
``` <-- nothing before and after these three characters (these three form the closing tag)
But yes I always tried to add the cpp like the top line and it always took multiple attempts to get it work correctly for some reason. Not much to mess up, it’s pretty simple.
Then I saw that just using the 3 slashes at the top and bottom also worked every time so I started using that instead but not I know the CPP adds more formatting features so I’ll stick with that.