Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore syntax highlighting language in multi-line code blocks #150

Open
felipe19930 opened this issue Feb 4, 2025 · 2 comments
Open

Ignore syntax highlighting language in multi-line code blocks #150

felipe19930 opened this issue Feb 4, 2025 · 2 comments

Comments

@felipe19930
Copy link

Hi,

As you might know, in multi-line code blocks, we are able to specify the syntax highlighting language to use.

For example, if you receive a message in Discord with the following content (a JSON snippet):

```json
{
  "hello": "world"
}
```

It gets displayed like this in the official client:

Image

However, in "dm" (i.e. your client), the json part (i.e. the syntax highlighting language) is also displayed at the top of the code block:

Image

Please note that I'm not talking about the lack of syntax highlighting here, I'm simply asking not to display the language directly in the code block.

Perhaps it doesn't have to be removed completely, but put elsewhere as a hint for the person reading it...

Thank you!

@iProgramMC
Copy link
Contributor

I'll think about it. It would require me to detect whether or not the first word is a language, which means I might need to add a list of all the languages that the official discord client supports highlighting for.

@felipe19930
Copy link
Author

Nice, thanks!

It would require me to detect whether or not the first word is a language

Perhaps that shouldn't be really needed? Especially if you don't intend to actually implement syntax highlighting in dm?

I think that if you detect that a code block is multi-line (i.e., it has line breaks), you can then check if that line block has a syntax highlighting language specified by simply checking if there's a string right after the first three backticks (```). If there is, you can remove it from the code block to prevent it from being displayed.

Now of course that's easier said than done, but at least I think the logic is correct...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants