tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.

Home Page:https://reprex.tidyverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discord Venue with Code Highlighting

mrcaseb opened this issue · comments

The default gh venue works mostly fine in discord except one minor detail:

Code highlighting only works if there is no blank space between the first three backticks and the language, i.e.

this won't get code highlighting

​``` r
message("Hello World")
​```

but this would get R code highlighting

​```r
message("Hello World")
​```

It would be great to have a venue that doesn't add that blank space. Thanks!

Given that we just used Discord as part of the remote experience for rstudio::conf(2022), I'm pretty interested in this.

I've replicated the behaviour, i.e. that the presence of the space between the backpacks and

I think this would be fairly simple to implement and would have a lot in common with the Slack venue.

Transferring some relevant URLs out of my browser tabs before I close them:

https://pandoc.org/MANUAL.html#extension-fenced_code_attributes

Optionally, you may attach attributes to fenced or backtick code block using this syntax: ... Some output formats can use this information to do syntax highlighting ... A shortcut form can also be used for specifying the language of the code block: ... If the fenced_code_attributes extension is disabled, but input contains class attribute(s) for the code block, the first class attribute will be printed after the opening fence as a bare word.

https://spec.commonmark.org/0.30/#fenced-code-blocks

A code fence is a sequence of at least three consecutive backtick characters (`) or tildes (~). (Tildes and backticks cannot be mixed.) A fenced code block begins with a code fence, preceded by up to three spaces of indentation.

The line with the opening code fence may optionally contain some text following the code fence; this is trimmed of leading and trailing spaces or tabs and called the info string.

It's pretty clear Discord does not hold itself to any sort of specific standard when it comes to markdown support. If it did, the presence of a space between the backticks and the language identifier would not have the effect of printing the specified language as a bare word. But this is good context re: venues that sort of want people to post code, but that don't adhere to a proper spec.

Discord seems to also need simplify_image_links(), as Slack does.