Copy/Pasting Code Snippets from Roam Fails

Steps to reproduce

  1. Copy paste multiple lines from Roam which include a code block.

Something like:

  • Left: (.*)\.received\.(.*)
  • Right: $1\.approved\.$2

image

Does not fail if you just copy the text inside one line.

  1. Paste this into Obsidian (without holding Ctrl)

Expected result

The text is pastes correctly.

Actual result

The text is pasted without the code block.

  • Left:
  • Right:

Environment

  • Operating system: Kubuntu 20.04
  • Obsidian version: v0.12.10

Additional information

Pasting while holding Ctrl makes this work. Though there is no warning that some data has been lost, so I am sure I have encountered this error before while migrating my data manually and never knew. Thus I’ve probably lost some data already :slightly_frowning_face:

Also, copying the correct result in Obsidian and pasting that back into Obsidian works :thinking: I looked to see if there was a difference in ASCII characters, but it does not seem there is.

Can you examine the contents of your clipboard before pasting in Obsidian?

Examine in what way?

In Kubuntu I can view the Clipboard History, and even edit the contents. But copying in Roam or Obsidian look exactly the same.

image

It’s just that pasting in Obsidian fails after copying from Roam.

I meant the raw contents i.e. so you can see the copied html from roam. In Linux you can use xclip. I don’t know about Windows.

Using xclip I can see the contents of my clipboard are as expected.

image

The following text pastes in Obsidian as:
- Test

Unless I hold Shift, then it pastes correct.

Alright, then I think that’s our answer! Since it’s copying the “raw” text already, you’d need Ctrl+Shift + v. If it was copying the HTML version of this, you would be able to use “normal” copy and paste. Not sure if this could depend on your browser, but I guess you could also approach Roam and ask them to give you a way to copy HTML instead of raw text.

If you don’t paste from websites very often (or don’t care about pasting with formatting from them) then you can disable this in the settings so Ctrl+v always pastes the raw text.

I don’t understand. XClip gives me the same result, whether I copy it in Obsidian or Roam.

Where can I disable formatting on paste in the Obsidian settings?

In Settings > Editor, you’ll find this:

2 Likes

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