Spaces are sometimes lost when you paste text from the clipboard.

undercat's Avatar

undercat

22 Feb, 2019 02:53 PM

Hi,

I've just upgraded to Anki 2.1.x and faced a vague regression when pasting text from online sources where under certain circumstances the last word of one line will be merged together with the first word on the next line.

To illustrate, try going to The Free Dictionary, e.g. https://idioms.thefreedictionary.com/leave+off and copy-pasting a word definition.
As you can see in the attached pictures, newlines in the HTML text (html.png) get removed instead of being replaced with whitespaces (pasted text.png). This is undesirable because it breaks formatting.

The problem seems to originate from jQuery's parseHTML() function called from doPaste() located in file editor.py.

  1. 1 Posted by undercat on 23 Feb, 2019 04:56 PM

    undercat's Avatar

    I looked into it a bit further, and it seems like a Chrome bug(?) because when Anki imports data from the clipboard, it already comes without spaces in between lines. I guess it didn't show up in the 2.0.x branch because it treated clipboard pastes as plaintext.
    Curious if anyone's already reported this here, seems like it should be a fairly common problem.
    At any rate I'll try to see if it can be fixed in Chrome. As a workaround, one can use Firefox.

  2. Support Staff 2 Posted by Damien Elmes on 24 Feb, 2019 04:19 AM

    Damien Elmes's Avatar

    I'm not seeing such missing spaces when pasting with the latest Chrome on Anki 2.1.9 on macOS.

  3. 3 Posted by undercat on 24 Feb, 2019 09:10 AM

    undercat's Avatar

    Interesting. Perhaps it's a Linux-specific issue, hmm.

  4. 4 Posted by undercat on 24 Feb, 2019 12:39 PM

    undercat's Avatar

    Seems like I've hit this Chrome bug. I guess the issue can be closed as it doesn't have anything directly to do with Anki.

  5. 5 Posted by Ridi on 24 Feb, 2019 04:32 PM

    Ridi's Avatar

    This comment was split into a new discussion: Adding pictures

    How do i add pictures in the card?

  6. 6 Posted by undercat on 24 Feb, 2019 05:34 PM

    undercat's Avatar

    Hi Ridi, I think you should ask your question in a new discussion to make it more visible and avoid notification clutter.

  7. 7 Posted by mark.c.johnston on 13 Nov, 2019 03:16 AM

    mark.c.johnston's Avatar

    I am having this issue with the latest version of Anki - when I copy text from a website and paste it into a note, most if not all line breaks/paragraph breaks are deleted.

    I'm using Linux - Ubuntu

    This happens in both Chrome and Firefox. Thus, for me, it seems not to be the Chrome bug mentioned above.

    If I paste into the text editor, the breaks are preserved. If I copy that and paste into Anki, the breaks are preserved ... but, what a pain!

    Hints - thoughts - suggestions? My workaround with the text editor is going to be rather clunky, and otherwise this bug makes it impossible for me to make Anki cards.

    thx for your help

  8. Support Staff 8 Posted by Damien Elmes on 13 Nov, 2019 08:28 AM

    Damien Elmes's Avatar

    Have you tried pasting with ctrl+shift+v?

  9. 9 Posted by mark.c.johnston on 13 Nov, 2019 02:29 PM

    mark.c.johnston's Avatar

    Ah- thank you. That is a huge improvement ... though now, too much formatting is preserved, at least I now have useful text. :-)

    Suggestion - there should be something in the right-click drop down menu that indicates this option.

  10. Support Staff 10 Posted by Damien Elmes on 13 Nov, 2019 10:29 PM

    Damien Elmes's Avatar

    Thanks Mark, I'll look into doing that in a future update.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • html.png 48.5 KB
  • pasted_text.png 18.5 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac