Hello.
I was just copying the source-code from one of my later projects and ran into an interesting problem.
Here, try this out:
Runs great, right ? But now click Code▼
click anywhere in the source-code field, press CTRL+A, then CTRL+C, then in a new Pico-8 boot, in the source-code editor, press CTRL+V.
cls() repeat るきるきpset(rnd(128),rnd(128),rnd(16)) るきるきflip() untilるきforever |
るきるき ⬅️
What is happening here ?
It looks like SPACES are being replaced by some other characters. This does not just appear for me but any code you try.
Clearly it's a bug of some kind.
It's because they're non-breakable spaces:
@zep, isn't there a better way to do this? I think having users copy/paste nbsp characters into other editors might cause many problems, not just in PICO-8.
I feel like you ought to be using <pre> blocks or something like that to force spaces to be kept as-is instead of collapsed. Or maybe there's another way that's more recent than the old <pre> method.
Also a reminder that tabs should also be kept as-is, using the css style "tab-size" to set them to 2 or 4 spaces maybe.
Follow-up, looks like you want to use the css "white-space" style to prevent spaces from collapsing or wrapping:
https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
If you set style="white-space: pre;"
, it's supposed to take the line as-is. No need for nbsp characters or seemingly even a <pre> block.
Edit: Yup, I used inspect to manually change the block above. You can basically use that style the same as <pre>. Doesn't even need you to use <br> for newlines.
Edit 2: If you want lines to wrap, you can use style="white-space: pre-wrap;"
. This is probably not the right choice for source code, though, IMO.
[Please log in to post a comment]