"Copy for Forum (Markdown)" adds a "cpp" after the opening backticks

@ptillisch - (should this be its own topic?) Something has happened to this function in IDE 2.3.3... when IDE >> EDIT >> COPY FOR FORUM is used, the open-triple-tick is followed immediately by "cpp" on the same line, demonstrated here (I had to add an extra triple-tick to make is show)...

```cpp
void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

Hi @xfpd. This is intended. The language identifier tells the Markdown renderer the language contained in the code block so that it can apply the appropriate syntax highlighting.

You won't notice a difference here on the forum because the forum software is configured to assume that the contents of a code block are C++ unless told otherwise, but on other platforms (e.g., GitHub, Stack Exchange), syntax highlighting is only performed (or guaranteed in the case of Stack Exchange, which does attempt to infer the language) if you add the language identifier. So it is best practices to always add it.

@xfpd
In case you did not know, GitHub - jincheng9/markdown_supported_languages: Markdown supported languages for syntax highlighting

This is the subset of languages supported by the forum's configuration (the Discourse forum framework supports more, but they recommend only enabling the ones you are likely to use for performance reasons):

  • arduino
  • armasm
  • avrasm
  • bash
  • c
  • cpp
  • css
  • diff
  • go
  • http
  • java
  • javascript
  • json
  • makefile
  • markdown
  • plaintext
  • powershell
  • python
  • python-repl
  • shell
  • sql
  • typescript
  • xml
  • yaml

In addition to the primary identifiers listed above, you can also use aliases as identifiers for some of these languages, which are documented under the "Aliases" column here:

(Highlight.js is the package Discourse uses for syntax highlighting)

For example, I like to use text instead of plaintext to disable highlighting in code blocks that contain non-code content such as compiler output.

I did not know this identifier existed. Thank you.

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