Automatic code highlighting, do you want it or not

Based on below, a poll

The point is that auto-detecting a language is not always reliable.

  • If no language is specified with code tags, try to detect the language and apply syntax highlighting.
  • If no language is specified with code tags, don't apply syntax highlighting at all.
0 voters
1 Like

The votes are in :wink: I've now closed the poll.

An overwhelming majority is against automatic syntax highlighting if no language is specified.

@ArduinoTeam, please draw your conclusions.

I use Geany and it works great!

This topic is about automatic code highlighting here on the forum. Like this:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Looks pretty, right?

but sometimes we post things that aren't code in code blocks and they get detected as some random language and highlighted nonsensically:

exit status 1
'x' was not declared in this scope

I think, that is highlighted nicely. Maybe except for "this". The Arduino IDE should do that instead of orange-on-black. :slight_smile:

2 Likes
Maybe we need a new poll to see whether we want "universal highlighting"
for all text on the forum?
1 Like

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

I'd like to revisit this proposal and see what the community thinks about it now. The autohighlight all code feature was never disabled despite the poll results.

I still don't have a strong preference either way, but if the community wants it turned off I'm happy to do so.

If needed, the poll can be re-opened.

2 Likes

As I got one love for the idea of re-opening, I have re-opened the poll. I will close it in two weeks time.

Currently

image

1 Like

How about a "preferred language" dropdown in the user profile with those settings and a list of the languages the autoformatter understands. I only post C++ because that's what Arduino mostly runs on.
Maybe have an override option if suddenly i want to post, say, APL (which is non ASCII).

Two weeks have passed. Even though we didn't receive any new feedback, the feedback we did receive indicates that forced highlighting is not wanted by the community so I have disabled it.

If you want highlighting of your code blocks, make sure to add the language identifier suffix on the opening code fencing markup:

```cpp
// some C++ code
```

The enabled language identifiers:

Language/etc. Identifier
Arduino arduino, ino
ARM Assembly armasm
AVR Assembly avrasm
Bash bash
C c
C++ cpp
CSS css
diff diff
Go go
HTTP http
Java java
JavaScript javascript
JSON json
makefile makefile
Markdown markdown
POSIX shell sh
PowerShell) powershell
Python python
Python REPL python-repl
SQL sql
text plaintext
TypeScript typescript
XML xml
YAML yaml

If we later receive feedback from the community that they miss the forced highlighting, I am happy to turn it back on.

Can you default to C++ if nothing else is selected?

1 Like

That was the previous behavior, which 80% of respondents opposed.

Not behind a PC at the moment. Does IDE 2.x add just the backticks or does it add the cpp after it as well?

Yes:

1 Like

My point is that not everything that is posted in code tags is code. Tables with numbers, serial output etc. That's why the suggestion was made.

1 Like

VS "ASC" for general ascii monospaced Courier 10 text
Have you noticed that a single ` gives monospace font?

I did not pay much attention; only use it for inline code.