"Copy" for code blocks changes non breaking spaces to  

Steps to reproduce

For some code, when copying the code using Obsidian “Copy” button that appears on top right corner, spaces are copied as  

The file for testing:
Untitled.md (44 Bytes)

Paste:

import pandas as pd  
...

Paste when selecting by hand (either in reading, source or live preview):

import pandas as pd  
...

Did you follow the troubleshooting guide? [Y]

Expected result

All weys of copying should not replace spaces, whether non-breaking or breaking as code like  .
Copying should be consistent to make code being sharable and runnable!

Environment

Debug info
SYSTEM INFO:
	Obsidian version: v1.7.4
	Installer version: v1.5.3
	Operating system: Windows 10 Pro 10.0.19045
	Login status: logged in
	Language: en
	Catalyst license: insider
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 0
	Plugins enabled: 0

RECOMMENDATIONS:
	none

Related bug reports (probable)

I don’t understand this bug report. non breaking spaces are &nbsp.

What does it mean it changes non breaking spaces to &nbsp?

I mean that non-breaking spaces characters are replaced with “&nbsp” string when copying the code using the Copy button in Reading view.

I added the file into my original post for testing Untitled.md (44 Bytes)

Here’s a screen recording below to better illustrate.

20241022 - Obsidian code block copy nbsp

This is not wrong. The nbsp are present in Untitled.md.

The nbsp are placed as-is in the clipboard. In this case it’s notepad.exe that writes &nbsp

Yes they are, but not being replaced with some “&nbsp” string.
If you have a look at the screen recording, there’s definitely something inconsistent in the way this code block is handled.

It’s notepad.exe that does this replacing.
If you try vscode or notepad++ you will see the unicode char for nbsp.

I tried copying this code to VS code, slack and other software already, and they all behave the same

20241022 - Obsidian code block copy nbsp 2

ok, thanks you. I managed to reproduce.

1 Like

Will be fixed 1.8

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.