Extra characters when pasting from Apple Reminders or Notes

Steps to reproduce

  1. Go to either Apple Notes or Apple Reminders, and select some text to copy. For example, I created a reminder called “Test”, double-clicked to select the text of the reminder, and copied it to the clipboard.

  2. Switch to Obsidian and paste into a note.

Expected result

The text you copied will be pasted.

Actual result

Additional characters are inserted before the text. For example, when I copied a reminder called “Test” from Apple Reminders and pasted into Obsidian, the following characters were inserted:

      

Test

(there are six spaces on that first line, then an additional blank line, and then finally the text I copied from Reminders).

Environment

  • Operating system: Mac OS X 11.1 (Big Sur)
  • Obsidian version: 0.12.13

Additional information

This is definitely an issue with Obsidian itself – I’ve tried copying and pasting text from both Apple Notes and Apple Reminders into other applications, and none of them show these additional characters. I tried Vim, TextEdit, and even the JavaScript console in Chrome, but none of these show additional characters when pasting text – it only happens in Obsidian for some reason.

I also tried copying a reminder, pasting it into Vim, and then copying that text and pasting into Obsidian. No additional characters are inserted.

This seems to be some weird sort of interaction between Apple Reminders (and Notes) and Obsidian.

1 Like

Have you tried pasting in Word? I think your copying html and text and obsidian is pasting the html.

Have you tried pasting with cmd-shift-v?

Thanks for those clues, @WhiteNoise.

I tried pasting in word. It works like every other application I’ve tried other than Obsidian, pasting just the word “Test”.

Interestingly, command-shift-V does indeed just paste the text itself without the added characters.

It might be that Apple Reminders etc are somehow copying the text of the reminder in HTML format…but why would pasting HTML-formatted text cause additional characters to appear in front of the text itself?

I tried creating an empty note and pasting the text into it. It’s definitely just getting six additional spaces and two newlines in front of the word “Test”:

% hexdump test-paste.md 
0000000 20 20 20 20 20 20 0a 0a 54 65 73 74            
000000c

I’m beginning to suspect that the problem may be with the way Obsidian pastes HTML into a MD document.

#############

Update: I managed to get the same thing happening in text from other applications. I went to TextEdit and created some formatted text there, and copied it. This would, I figure, copy HTML formatted text to the clipboard. I created the following:

This is a test.
This isn’t boldfaced.

I then copied and pasted this text into Obsidian…the boldfacing came across nicely, but once again there were an additional six spaces and two newlines added to the front of the text:

      


**This is a test.**

This isn't boldfaced.

because the html clipboard are processed by the html to markdown converter.

I am not a mac user but if a clipboard analyzer for mac exists you will see the html version of what is copied and there you will find the extra spaces or perhaps an instruction to create a new paragraph

I found a clipboard analyser program for the Mac, and can see the raw contents of the clipboard that is being pasted. There’s no HTML format, but there is an RTF format, and I’m guessing that’s what’s being used. Here’s what the RTF clipboard contents look like:

{\rtf1\ansi\ansicpg1252\cocoartf2577
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 .AppleSystemUIFontRounded-Regular;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0\c84706\cname labelColor;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0

\f0\fs26 \cf2 Test}

Aside from RTF, there just the plain text in both UTF-8 and UTF-16 format. So I’m pretty sure Obsidian is somehow trying to import the RTF formatted clipboard data, and it’s getting confused somehow.

Anyway, there are no extra spaces or paragraphs that I can see in the RTF…and pasting this into other applications work as expected. It’s just Obsidian that seems to have trouble with this RTF-format clipboard.

Obsidian doesn’t parse RTF. I think there is paragraph there and even tabs.

Obsidian doesn’t parse RTF. I think there is paragraph there and even tabs.

Interesting – here are the different data types on the clipboard when copying that “Test” string:

The first two formats are both RTF, public.utf8-plain-text and NSStringPboardType are both plain text with just the four bytes on the clipboard, one for each character in the text I pasted, and the remaining two are both UTF-16 format strings.

Those UTF-16 format strings do look weird, but I’m no expert on that format. Here’s the clipboard contents for UTF-16, in hex:

ff fe 54 00 65 00 73 00 74 00

Any ideas? Perhaps Obsidian is trying to parse the UTF-16 clipboard contents and getting it wrong somehow? If it was parsing the UTF-8 contents, it wouldn’t be inserting any extra characters as they only contain the text itself:

54 65 73 74

Option+Shift+Command+V to paste text without any formatting

Option+Shift+Command+V to paste text without any formatting

Yes, that is a workaround, but the point is that there is no formatting applied to the text – it’s just plain text copied from another app. All other apps I paste that text into into handled it without a problem, but something is weird with Obsidian and it inserts extra characters that weren’t in the original text. So this is definitely a bug and should probably be fixed.

My guess is that this will be where the problem lies.

I don’t know that I’d interpret it this way. Have you tried pasting into other electron apps? Do any other programs give rise to similar problems in Obsidian or is it only Apple Notes and Reminders?

But whatever it is, it looks like something very particular and fiddly to diagnose and fix whichever side is causing the problems.

From the plist of the Notes app on a Mac:

			<string>Notes rich text pasteboard data</string>
			<key>UTTypeIconFiles</key>
			<array/>
			<key>UTTypeIdentifier</key>
			<string>com.apple.notes.richtext</string>

I believe Notes and Reminders use an Apple derivative of RTF, not plain text.

https://developer.apple.com/forums/thread/113322

Angel

I’d suggest testing with Zettlr. It’s also Electron and Codemirror based. Not sure of what it does with UTF. Or RTF.

Thanks, guys – I’ll try installing another Electron/CodeMirror app like Zettlr and test it there too.

I am gonna repeat, this is an html-to-md problem. The extra stuff is probably there in the RTF or the HTML generated from the RTF by apple/electron.

At the end of the day, it doesn’t matter if the problem is with UTF, RTF or HTML. Since paste text without formatting does work, we can deduce that there’s extra formatting being picked up by the ordinary Obsidian paste.

The issue is that some programs understand what they are being given and interpret it correctly and Obsidian doesn’t. I’m more than willing to see it as an issue at the Apple end, but if other apps with a similar stack to Obsidian can get it as intended, which we don’t know yet, then there a possibility of it being solved at the Obsidian end anyway. I can’t imagine Apple being willing to accept it as an issue that they will address.

It’s not that clear cut. The clipboard (on macOS anyway) is actually multiple clipboards with differently formatted versions. Pasting into an RTF based field is different to pasting into a plain text field.

In addition, Obsidian is also helpfully converting what’s pasted into MD so the results should be different to pasting into other apps.

Zettlr converts HTML to markdown using the Showdown library iirc (I don’t know what Obsidian uses), so I’d hope it would be a reasonable comparison with Obsidian.

I certainly don’t see it as simple and personally prefer to paste without formatting when I hit a problem between programs - trying to work out whether it’s a problem with clipboard, target or translation can become unproductive very quickly. I doubt it’s a bug in Obsidian itself, which is the original claim. The problem is likely to be somewhere upstream, and if no-one has spotted what it is by examining the clipboard content then the only way forward I see is testing for the boundaries of problem occurrence. The OP started, but it seems to need to become much finer grained.

I’m a bit surprised that other Apple Notes users haven’t reported similar issues, but don’t remember seeing them.

I finally had the chance to try Zettlr, and the behaviour there is even worse – pasting the string “Test” from Apple Reminders causes the following to be pasted:

  p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px '.AppleSystemUIFontRounded'; color: #000000; color: rgba(0, 0, 0, 0.85)} 

Test

Exactly the same thing happens when using the “Paste Without Styles” command in Zettlr, for some reason.

Anyway, I still say this is an issue with Obsidian as the end user’s experience of this makes it seem that Obsidian is buggy – pasting into LibreOffice, for example, doesn’t cause any additional characters to be inserted, and ditto for TextEdit, Bear, Google Docs, OmniGraffle, Apple Notes, Pages, Slack, Trello, etc (these are just the apps I happen to have on my computer).

Interestingly, DynaList also inserts an extra character when pasting from Apple Reminders, so something is amiss in Obsidian’s sister project too.

I also tried copying and pasting text from other apps into Obsidian:

  • Copying text from a code block in Slack, for example, causes extra newlines to appear, which again don’t appear in apps other than Obsidian.
  • Copying text from LibraOffice again causes those extra spaces and newlines to be inserted when pasting into Obsidian.
  • Pasting from Google Docs into Obsidian causes other weird characters to be inserted – in this case extra newlines and pairs of asterisks (and no, the original text wasn’t boldfaced).
  • Pasting from Omnigraffle also causes extra newlines and spaces to be inserted.

Basically, the interoperability of Obsidian with other apps on Mac leaves a lot to be desired, unfortunately…yes, you can work around it by remembering to use command-shift-V to paste without formatting, but most users won’t remember that and will (like I did) get annoyed at Obsidian’s inability to play nice with other apps in the Mac ecosystem…

You can use 3rd party apps to export data from Apple Notes

http://writeapp.net/notesexporter/

Let me know your results! Exporter may be the way to go

I’m not yet ready to migrate as I’m yet setting up my environment in Obsidian

Obsidian is still in its infancy, we didn’t reach version 1.0 yet.
Also, it’s open source and multi platform, i assume the developers didn’t have the time to focus on OS specific integration, like the integration with Macs services, or the build-in dictionaries. Finally, an integration with Applescript would be a dream!

Since a ton of people use Mac to run Obsidian, a later integration with Mac specific features should be on the horizon, imo.

1 Like