Replies: 7 comments
-
|
Our plan is to replace newlines with We also want to see if we can disable the markdown-it's paragraph rule. |
Beta Was this translation helpful? Give feedback.
-
|
Discourse's TextCleaner will change all whitespace to regular spaces, which markdown/html then trims/truncates. Noted here: What I was working on before coming here was to disable this function in the text cleaner, and then (somehow) change replace normal spaces with non-breaking spaces, which would then be passed to markdown. - I was pretty excited to see that this setup with BBob was already doing this with newlines. I've just posted my code as a plugin here: https://github.com/Rhababo/discourse_normalize_whitespace But the core functionality is really just: in the "after_initialize do" block BTW: I had found this documentation on discourse really useful in figuring out how to override this: So with this function, if we replaced the spaces with nonbreaking spaces in BBob, those spaces should persist through markdown. |
Beta Was this translation helpful? Give feedback.
-
|
Oh! I didn't realize that's where it's from. I've been staring at the markdown-it engine this whole time thinking it was caused by the paragraph tag generation. Non breaking whitespace should work, but hoping to see if we can do without text replacement. Any luck with disabling it? |
Beta Was this translation helpful? Give feedback.
-
|
I think that markdown actually retains the whitespace, but just puts in in a
Markdown is kind of lazy that way Bbob already does whitespace checks when building its tree, I don't know if it would be that inefficient to inject a character replacement during those checks. But it would require modifying a custom fork of Bbob...or maybe some kind of special plugin format (I'm still getting familiar with the Bbob code). We could try injecting a
So I went to test this in discourse: This also works on the markdown-it demo page Not sure how this is processed exactly yet. |
Beta Was this translation helpful? Give feedback.
-
|
A plugin be preferred over a custom fork of bbob, but I could be convinced. |
Beta Was this translation helpful? Give feedback.
-
|
Having looked at how the Bbob tree is parsed, I think a plugin for this issue would be fine. We'd only need to check for nodes that are just multiple spaces and replace those characters since nodes that are single spaces will be retained anyway. Interestingly, the parser treats a nonbreaking whitespace (U+00A0) as a normal character, so you can get array nodes that " |
Beta Was this translation helpful? Give feedback.
-
|
Huh, interesting. A plugin should work fine in this case. If not, you can brute force it with a bit of client side js that just does a regex check for multiple spaces. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
We currently replace newlines with
<br/>, which solves the issue of truncating blank lines.Do we want it to also replace blank spaces (U+0020) with non-breaking spaces (U+00A0) or
?edit: forgot to put my
<br/>in a code block, but you caught it!Beta Was this translation helpful? Give feedback.
All reactions