Automatic code highlighting, do you want it or not

Moderators can, trust level 4 users as well.

I meant to say that I like the automatic code highlighting...
...especially now it is not there anymore...

2 Likes

That would be good...
Who is in trust level 4?

I think this badge indicates it: Leader badge on Arduino Forum

That is a pretty short list. And at least half of them are not very active (maybe in the italian forum).

NO, in the Italian forum ... I'm alone ... :confused:

Guglielmo

Well, around 10 people were given the badge in March. Not for their many contributions to the forum...

1 Like

Is it possible to allow regular users to turn it on or off on a per post basis? Default being one or the other.

1 Like

A number of them are Arduino employees; note the arduino logo in their user icon.

Please, can we stop messing about and turn code highlighting back on. New users will not care, but may gain some advantage from it. Experienced users can choose to edit the language specifier out of the code block if they really want to

As to nonsensical highlighting of compilation of output, again, new users won't care (assuming that they even use code tags) and experienced users will understand

I am afraid that there is not a definitive solution to this and some other options of the forum software, and the last thing that we should do is to impose more rules on new users

4 Likes

3 posts were split to a new topic: Proposal - no more proposals to change the forumw

This would require a user to re-post the edited code in order to see the results in the thread… correct?

Can we please stick to the subject of this topic?

Make it a user option ?

@dax1 is that an option ?

1 Like

No

When you add code tags by using the < CODE/ > icon or by using Copy for forum in the IDE and paste code into a reply it is immediately obvious whether the language specifier is present or not
and the effect can be seen in the preview pane

Sorry, I meant that if I as a forum user would like to add language highlighting to code posted by another user, I would have to repost that code with the appropriate language specifier... yes/no? Obviously I could paste it into my favorite code editor but I'm wondering if I can change its appearance to me in the forum.

Let me try an example. This is Python code and it defaults to no language highlighting. Can e.g. @Ballscrewbob choose to view the code with Python language highlighting without reposting?

from machine import Pin, ADC
import time, math

wind_direction = Pin(26, Pin.IN)        # this is needed to turn input to high impedance       
wind_direction = ADC(Pin(0))
conversion_factor = 3.3 / 65536

direction = (('None','None'),('0', 'N'), ('22.5', 'NNE'), ('45', 'NE'), ('67.5', 'ENE'), ('90', 'E'),
    ('112.5', 'ESE'), ('135', 'SE'), ('157.5', 'SSE'), ('180', 'S'),
    ('202.5', 'SSW'), ('225', 'SW'), ('247.5', 'WSW'), ('270', 'W'),
    ('292.5', 'WNW'), ('315', 'NW'), ('337.5', 'NNW'))

v = (0.0,2.55,1.32,1.51,0.29,0.32,0.22,0.61,
    0.42,0.95,0.81,2.06,1.96,3.05,2.69,2.87,2.29)

def direction_lookup(adc, vtuple, tol):
    for item in range(len(vtuple)):
        if (math.isclose(adc,vtuple[item],abs_tol = tol/100.0 * adc)):
            return item
    return 0

A lowly user can awkwardly quote the code, add the python tag and see it highlighted in the preview window prior to committing post:

From the markdown reference on "fenced code blocks" I see you can also use triple tildes to quote triple backticks and vice versa:

~~~
```python
import timetravel
```
~~~

gives:

```python
import timetravel
```

and vice versa gives:

~~~python
import timetravel
~~~

...which, when un-backticked renders with code highlighting:

import timetravel
1 Like

Ah, okay, that's a way. Not the convenient solution I was looking for. A toggle up in the righthand corner of the code area would be nice.

2 Likes

It's based on trust level. I can e.g. edit your post and add the language specifier. But you need to be at TL4 (leader) or a moderator/admin; see posts #43 and #46.

I selected the code in your post #62 and it gives me the option to either quote or edit.

. And there are other ways to edit a post if needed, this one just is to show.