szhorvat
(Szabolcs)
9 במרץ, 2023, 9:17am
1
Consecutive spaces in inline code get collapsed. Here’s an example.
Markdown:
- `o o` no connection
- `o --> o` unidirectional connection
- `o <-> o` bidirectional connection
Rendering:
o o
no connection
o --> o
unidirectional connection
o <-> o
bidirectional connection
Screenshot of rendering:
It’s unclear to me whether this is intentional or a bug, but if it’s intentional, I do not really see the point. As you can see above, it can be counterproductive. If one does not want extra spaces, it is easy to delete them manually. The point of code blocks (whether inline or separate) is to include verbatim text with a fixed-width font.
5 לייקים
Canapin
(Coin-coin le Canapin)
9 במרץ, 2023, 10:30am
2
Hi Szabolcs!
Thanks for the report. I understand the issue, and it’s not strictly a Discourse bug. Discourse uses markdown-it , and this is its standard behavior.
You can see the same behavior on the official demo: https://markdown-it.github.io .
If you need spaces not to be collapsed between backticks, you can add this CSS to your forum:
code {
white-space: pre-wrap;
}
3 לייקים
mattdm
(Matthew Miller)
9 במרץ, 2023, 10:58am
4
Looks like it this isn’t compliant with CommonMark. Not that it has to be, but maybe they could be convinced to change to match?
https://spec.commonmark.org/0.30/#code-spans
Depending on purpose that can be even worse, because it can cause copy / paste confusion.
3 לייקים
Canapin
(Coin-coin le Canapin)
9 במרץ, 2023, 11:00am
5
You’re right, I didn’t think about that, I’ve removed this tricky advice
לייק 1
Canapin
(Coin-coin le Canapin)
9 במרץ, 2023, 11:06am
6
I’m not familiar with this kind of stuff, but I guess this is the part you’re talking about?
Note that browsers will typically collapse consecutive spaces when rendering <code>
elements, so it is recommended that the following CSS be used:
code{white-space: pre-wrap;}
mattdm
(Matthew Miller)
9 במרץ, 2023, 11:07am
7
For what it’s worth, it appears that Non-Breaking Space is not collapsed (o o
), so if you must use a weird one, that’s probably the best choice.
Edit: see below for sad news!
mattdm
(Matthew Miller)
9 במרץ, 2023, 11:08am
8
The line above that one: “Interior spaces are not collapsed".
לייק 1
Canapin
(Coin-coin le Canapin)
9 במרץ, 2023, 11:08am
9
Non-regular spaces can appear non-collapsed in the composer preview, but are when the post is processed.
לייק 1
mattdm
(Matthew Miller)
9 במרץ, 2023, 11:09am
10
Welllllll that’s unfortunate.
szhorvat
(Szabolcs)
9 במרץ, 2023, 12:37pm
11
Coin-coin le Canapin:
If you need spaces not to be collapsed between backticks, you can add this CSS to your forum:
code {
white-space: pre-wrap;
}
Thank you for the tip!
Do you happen to know if setting custom CSS is available for sites hosted on discourse.group? I wasn’t able to find the setting immediately.
Canapin
(Coin-coin le Canapin)
9 במרץ, 2023, 12:40pm
12
Discourse pricing | Discourse - Civilized Discussion tells that Custom themes and components is enabled only starting from the standard plan.
szhorvat
(Szabolcs)
9 במרץ, 2023, 12:45pm
13
Thank you. I finally found the setting and it works perfectly well
We use the free hosting offered for open source projects, https://free.discourse.group/
3 לייקים
sam
(Sam Saffron)
9 במרץ, 2023, 11:17pm
14
I am moving this to ux , this is working as designed there was a deliberate decision by the design team to collapse the spaces in the ui, the markdown itself is correct.
לייק 1