Copy/paste can introduce foriegn charachters

Bug report

When copying text from a terminal or some web pages, the resulting paste is not identical to what was copied.

Copied text: curl -H "Authorization: $MY_CREDS" https://example.com
Pasted text: curl -H "Authorization: $MY\_CREDS" <https://example.com>

It is not limited to only the those characters that are escaped/transformed. There also appears to be other characters escaped (i.e. : and ~) i.e. ~ https://example.com\~ https\://example.com

This behavior is new and happens consistently and is isolated to Inkdrop.

Environment

  • Platform: macOS
  • Platform version: Tested on 13.6 and 14.1.1
  • App Version: 5.6.0

How to reproduce

Copy the text from gist:1de986efa8d54f11da397d9d58c30432 · GitHub into Inkdrop to see the issue. Weirdly, if you use the raw version https://gist.githubusercontent.com/jakelandis/1de986efa8d54f11da397d9d58c30432/raw/e109f19ac73d06c0f050f46fe8087386d82b91d8/gistfile1.txt there are no issue.

Type any any commands that have _, :, or URL’s from mac’s built in terminal and try to copy them into Inkdrop.

Hi Jake,

Text is always copied as HTML on a webpage.
v5.6.0 converts HTML into a valid Markdown automatically when pasting HTML clipboard data.
That’s why you get some escape characters.
To let it paste as plain text, you can press Cmd + Alt + Shift + V or select Edit → Paste as Plain Text.

Hope that helps.

I think it should be disabled if the cursor is inside a codeblock or an inline codeblock like:

```sh
|
```

or

`|`

Thanks for the reply, and I can confirm Cmd + Alt + Shift + V does indeed resolve the issue. Is it possible to have an option to set that as the default paste mode ?

As a software developer this is a show stopper that my technical notes are effectively corrupted any time if forget to special paste. The vast majority of my notes are copy/pasting technical resources from the web, an IDE, or a console window. All of which now require me to remember use 4 fingers to paste. It sounds trivial, but changing years of muscle memory and dealing with the times i forget is an exercise in frustration. I imagine that I am not alone and there are many other technical users would want to your app for technical notes and would be equally confused/frustrated.

I really like Inkdrop and fully appreciate how much effort has gone into making it such an awesome application. Please take my feedback as my desire to keep using it all day everyday and not nitpicking a tiny feature.

I have also customized the keyboard shortcuts for inserting text. (Customizing Keybindings)

This can be done, for example, with this configuration in the keymap.json

{
    "body": {
        "ctrl-v": "core:paste-as-plain-text",
        "ctrl-shift-V": "core:paste"
    }
}
2 Likes

Thanks for the feedback.
Yeah, I’m kinda feeling the same sometimes when pasting a code snippet from the web.
On the other hand, it would still be useful to paste paragraphs including some emphasis, links, etc.
So, the discussion is, how could I resolve this while having the advantage of this feature? :thinking:
In your case, the clipboard has:

<meta charset='utf-8'>
<span style="color: rgb(230, 237, 243); font-family: ui-monospace, SFMono-Regular, &quot;SF Mono&quot;, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: pre; background-color: rgb(13, 17, 23); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">
  curl -H "Authorization: $MY_CREDS" https://example.com
</span>

So, it’d be nice not to convert into Markdown only if it has any links, bolds, italics, lists, codeblocks, etc :thinking:
I think that should work.

So, it’d be nice not to convert into Markdown only if it has any links, bolds, italics, lists, codeblocks, etc

I think any transformation of the source text is problematic for my use-case of technical notes. I choose to use an application like this in large part because other rich editors are too smart, and I am too dumb for the likes of Vim/Emacs. Markdown support is important, but only at specific times which might be difficult to capture with a reg-ex like rule.

While some of my notes come from the web, many others are just useful commands or source code I wish to save for later. For example, I have been working with kubectl lately and taking a lot of notes (with some text sourced from terminal) with context for how to do specific tasks. Sometimes it comes from the web, sometimes it just type them out, sometimes I copy from the terminal, sometimes I copy from an IDE, sometimes there are URLs, other times they may include underscores and colons. I think it would be hard to define a rule set to consistently apply markdown transformation or not. I would find it confusing if sometimes it pasted as-is and other times it escaped some characters. Overtime, I would learn to not trust my notes if those commands were sometimes broken due to escaped/transformed text.

For my use case I only care about markdown formatting when I am producing text (i.e. writing) in the editor. When consuming text (i.e. pasting) I want to consume as-is for re-use later (without special paste or need to be inside code blocks). I think (for text) there should be all or nothing to determine if markdown is applied and IMO it should not be applied as be the default behavior. I will try Lukas’s keybinding workaround but if this was the default a couple months ago when I was evaluating new note application this could have swayed my opinion before I committed.

Thanks for listening and keep up the good work !

Thanks for sharing your workflow!

The transformation only happens when you copy HTML or rich text. Copying text from the terminal won’t trigger it.
This forum is built with Discourse, which works similarly and I find it useful.
Let me try my idea if it works first.
If it is still problematic, I’d be happy to revert it.

@Lukas @jake_landis Can you try this patch?

https://inkdrop-dist.s3.ap-northeast-1.amazonaws.com/tmp/Inkdrop-5.6.1-arm64-Mac_nightly-1.zip

It doesn’t transform clipboard data into Markdown if:

  • The cursor is inside a codeblock or inline codeblock
  • The HTML data doesn’t have any markups like bold, italic, table, list, etc.

Hope it solves your issue!

Hi!
I’m happy to test, but could you provide me with a Windows or Linux version?

Sure! I’ll roll out a beta ver soon

Rolled out v5.6.2-beta.0🙌 @Lukas Can you please try it?

2 Likes

I updated the beta versions. Looks great !

In retrospect my main issue was with copying from the mac terminal. Here is how it looked in 5.6.1 after pasting (screen shot from Inkdrop)


and here is how it looks in 5.6.2-beta.0
image

I wonder now if my use of https://ohmyz.sh/ influenced this behavior.

Also, I didn’t see any changes when experimenting with copy and pasting from the web. However, I did realize that if the webpage properly formats the commands in code like blocks then the paste is also in code like blocks which does not transform the text. Most technical documentation does format it correctly so the gist provided is not a fair example of technical documentation. Side note - I also noticed some other really cool support for copying tables and other rich text from web pages which is also nice and intuitive.

1 Like

Thanks for trying it!
Yeah, most note apps support this feature and I wanted to support it out of the box as well.
I’m glad we could resolve this while taking advantage of the plain-text editor :raised_hands:

v5.6.2 has been released :partying_face: Thanks again for reporting.