I have a teams customer requesting inline code blocks that stand out more. Right now whether you are in dark mode or light mode the code block is not very different in color from other text. Could we change the text color by default in Discourse so a different color is used that stands out more, e.g. red?
I know for most customers this is not a big issue because they can customize the theme to change the CSS on their site, but for Discourse for Teams this level of customization is not possible. Meanwhile for teams discussing code it matters a great deal that it stand out as very different from the other text.
Thanks Tobias. For the record I’m the customer and I want to emphasis that I’m talking exclusively about inline blocks. I don’t have any concerns with multiline.
For the record, if you are an html noob like me (I had to search for it):
Fancy! is made with <kbd>Fancy!</kbd>
Ohhhh! is made with <ins>Ohhhh!</ins>
It’s useful to know, thanks @tobiaseigen.
I still think it would make sense to tweak the CSS for this so. We have some technical posts that are using backticks a lot, and using the 2 alternatives is definitely not as user friendly.
Oh, there is a third way to highlight that is nice too that I keep forgetting. It looks like this and is done using this html markup <mark>text</mark>. There’s a community contributed theme component (not available in Teams) that lets you use ==text== instead which is quite handy. Not finding it immediately for some reason.
But anyway, I will discuss with my colleagues about updating the default styling of code blocks so they are more obvious. Maybe even just making the code block background color more distinctive will be sufficient.
Inline code has always looked like regular code, in a code (monospace) font. Anything really bright and jarring would be highly dependent on the community, and definitely not consistent with the way I see code used in most places on the web.
The issue of syntax highlighting is different; you’d need multiple lines of code to determine which syntax you’re dealing with. Perhaps that was the root of the issue – if you want syntax highlighting you need a block of code, e.g.
var x, y, z; // Declare 3 variables
x = 5; // Assign the value 5 to x
y = 6; // Assign the value 6 to y
z = x + y; // Assign the sum of x and y to z
document.getElementById("demo").innerHTML =
"The value of z is " + z + ".";
A single code element is divorced from all context necessary to do syntax highlighting. You could do a single line of JavaScript though:
"the value of z is " + z + ".";
Which looks like
``` javascript
"the value of z is " + z + ".";
```
So I guess this is about blocks of code versus a word of code.
I guess @jordan-vidrine there are marching orders here. Just to go ahead and do a full revert of the change. Maybe make a theme component for “alternative code styles” it can go full Slack on inline code and make it red being a component an all.
I think the ask here really was for a quick and easy way to highlight text in discussions. Many people (myself included) have taken to using backticks to highlight text because it’s super easy… you don’t even have to press shift, and it’s discoverable on the menu. But it’s not very distinct from the rest of the text in the para.
Bold and italics are also on the menu and also do not stand out very much. Other ways to highlight text inline take more keystrokes. Also they are not prominently documented so also require insider knowledge.
As far as I know these are the best ones:
Button<kbd>Button</kbd>
Green underline <ins>Green underline</ins> Red strikethrough<del>Red strikethrough</del>
Highlight <mark>Highlight</mark> Strikethrough<strike>Strikethrough</strike>
I found the plugin that does this randomly today when scrolling through the plugin category… funny how in some cases you just can’t think of the right keyword to find a plugin.
I would argue that both green underline and highlight have the exact opposite problem with unnecessary super high contrast but that’s more about taste than a UX problem.
What about implementing the github approach with a darker gray background and some padding?
Where this gets complicated is advocating for a huge change on every single Discourse instance many of which are used to the current mild styling. This is a major cheese move.
The workaround of just adding CSS already exists for most installs.