My code is now posted in monochrome

When I try to post code using code tags, the output does not have the normal colours, but is entirely monochrome.


int beats;

void setup() 
{
  Serial.begin(19200);
  // from 'Tools' choose "Serial Plotter" (NOT Serial Monitor)
  // and make sure the baud/bps match
}

void loop() 
{
  beats = analogRead(A0);
  Serial.println(beats);
  delay(10);    // try faster -- or no delay

}

Does anyone know why?

Is there a setting I have inadvertently changed?
It has only started doing this today.

Do you mean that it should look like this ?

int beats;

void setup() 
{
  Serial.begin(19200);
  // from 'Tools' choose "Serial Plotter" (NOT Serial Monitor)
  // and make sure the baud/bps match
}

void loop() 
{
  beats = analogRead(A0);
  Serial.println(beats);
  delay(10);    // try faster -- or no delay

}

How are you copy/pasting the code from the IDE and which version of the IDE are you using ?

UKHeliBob,
Yes that is what I was expecting it to look like.

Use ```cpp instead of ``` to start the code section

Still end with ```

2 Likes

In order for the forum to recognise some keywords and colour them it need to know what programming language you are using, hence my question about how you were copy/pasting the code

1 Like

CPP or any of these : Automatic code highlighting, do you want it or not - #13 by pert

1 Like

I originally copied it from another topic on the website (it was runaway_pancake's code).

But I have also tried copying it from the IDE (Version 1.8.19) - It shows up correctly in the IDE.

The 'example' in post #1 was from the IDE.

Did you use "copy for forum" in the IDE?

I suspected that that would become a problem after the change but could not properly test it yet. Also. if you copy/quote a piece of a post, the forum does not seem to maintain to language option of the code tags.

Just quoting a part of @UKHeliBob's post. Syntax highlighting gone.

1 Like

Yes, I used the 'Ctrl + Shift + C' shortcut for "copy for forum".

Which version of the IDE are you using ?

I'm using Version 1.8.19 of the IDE

If I add the 'cpp' as suggested by sterretje in post #4, I can see the code in the preview window change as I type the first 'c ' .

Now that I know this, I think we can consider the matter solved.

Thank you all for your assistance on my first question after 9 years posting.

2 Likes

UKHeliBob, I don't think it is a problem with the IDE at all, it is due to a feature of the forum that </> pert has only just turned off.

https://forum.arduino.cc/t/automatic-code-highlighting-do-you-want-it-or-not/868319/12

I never suggested that it was a problem with the IDE, apart from the fact that IDE 1.x does not add the language specifier when doing "Copy for Forum" whereas ID 2 does

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.