Paste while preserving formatting on Anki 2.1

Florian's Avatar

Florian

08 Oct, 2019 08:07 AM

Hi,
I am still stuck with Anki 2.0 because there is one feature I cannot find in Anki 2.1: Paste while preserving formatting. I created most of my cards by copy & pasting parts of Wikipedia entries. They look nice and I want new cards to look like them. I know about ctrl+shift+v, which preserves links but not the actual formatting.

Is it still possible in Anki 2.1? If not, is there at least some kind of "hacky" way of being able to create cards with the formatting preserved - just in case if, e.g., syncing stops working at some point in time (because Anki 2.0 is discontinued).

Thanks and greetings,

Florian

  1. Support Staff 1 Posted by Damien Elmes on 09 Oct, 2019 03:03 AM

    Damien Elmes's Avatar

    Improving the paste filtering is on the todo list. Please provide a link or two, and indicate the parts of the formatting you're trying to preserve.

  2. 2 Posted by Florian on 16 Oct, 2019 09:12 AM

    Florian's Avatar

    Hi,
    Anki 2.0 simply preserves everything, which is pretty good. I provide an example in the screenshots. The example is from the article on general relativity on Wikipedia.
    I have attached the version as shown in the browser I am copying from (chrome.png), the result in Anki 2.0 (Anki2.0.png), the "normal" (Ctrl+V) pasting in Anki 2.1 (Anki2.1png), and the result obtained when also pressing shift in Anki 2.1 (Anki2.1withShift.png).
    A result without any filters would work fine for me. If you are asking what I am precisely missing (I exclude the base font because I think that can be changed easily in the card properties), then it is that figures cannot be beside the text. And the boxes get lost, making the caption harder to associate with the image. (Pasting formulas with MathJax also does not work anymore, but by switching to png they can at least be copied).

    Anyways, if it is some change in philosophy that pure html should not be pastable anymore, then I accept that. It is not necessary that these specific features are implemented in some filter. I merely wanted to ask if I am missing something because it sounded as it Anki 2.1 should now succeed Anki 2.0, so I thought it may have the feature but may have moved somewhere else.

    If anybody else misses this feature. Installing Anki 2.0 as 32 bit Version and Anki 2.1 in 64 bit simultaneously works fine for me. So one can have Anki 2.1 by default and use 2.0 for adding cards.

  3. Support Staff 3 Posted by Damien Elmes on 16 Oct, 2019 11:21 AM

    Damien Elmes's Avatar

    Thanks for those examples Florian, I'll give this some thought.

  4. 4 Posted by Ben on 29 Nov, 2019 01:53 PM

    Ben's Avatar

    Hi Florian, I too very much miss the option to preserve formatting. I found a "hacky" way to paste with formatting for the time being and thought it might help others who may be in an urgent situation like me. The hack is to locate editor.js under ${Anki_Installation_folder}/web/ then comment out the line "html = filterHTML(html, internal, extendedMode);". I am not sure whether there are other unforeseeable consequences but for now it meets my needs and I will try to survive using it before an official solution is available.

  5. 5 Posted by Florian on 30 Nov, 2019 07:51 AM

    Florian's Avatar

    Hi Ben, works like a charm! Thanks a lot for this solution. (If there are no side effects, a checkbox to enable/disable that line would be great, so it does not have to be redone when updating Anki).
    Now I can finally use Anki 2.1, which will surely be the state of the art for many years to come ;).

    Greetings,
    Florian

  6. Support Staff 6 Posted by Damien Elmes on 30 Nov, 2019 08:06 AM

    Damien Elmes's Avatar

    Turning off filtering is not ideal, because some sources included a huge amount of superfluous formatting, which can easily inflate storage requirements a hundred fold. If you're only pasting from websites with relatively clean HTML you may be ok, but adding a switch is not the best general solution.

  7. 7 Posted by Ben on 30 Nov, 2019 04:10 PM

    Ben's Avatar

    Hi Damien,
    Thanks for the insight! I agree that completing turning off filtering is not an ideal solution to the problem, especially considering the storage space. Luckily the amount of information I paste in my flashcard is relatively small and the html contents are relatively clean. I will try to use it only for the time being and consider other options such as adding a css file for html from some fixed-format sources if the html tags can be somehow preserved after filtering.

    Best wishes,
    Ben

  8. 8 Posted by Elizabeth on 05 Dec, 2019 11:27 PM

    Elizabeth's Avatar

    Hi Ben,

    I'm not very good with computers. Can you explain what this means?:
    The hack is to locate editor.js under ${Anki_Installation_folder}/web/ then comment out the line "html = filterHTML(html, internal, extendedMode);

    I'm also having problems because when I have some highlighted in Word but when I try to copy-paste it into Anki 2.1 all formatting gets stripped.

    Thank you,
    Elizabeth

  9. Support Staff 9 Posted by Damien Elmes on 06 Dec, 2019 05:56 AM

    Damien Elmes's Avatar

    I don't recommend you do that, as Word's unfiltered output is extremely verbose. I suggest you try the beta that has just been released, as it should preserve the text foreground and background color when pasting.

    https://apps.ankiweb.net/docs/beta.html

  10. 10 Posted by Elizabeth on 06 Dec, 2019 06:03 AM

    Elizabeth's Avatar

    I have windows. I think there are 4 versions, is the a noticeable difference between them?
    anki-2.1.16beta1-2eb7560-windows-alternate.exe
    anki-2.1.16beta1-2eb7560-windows.exe
    anki-2.1.16beta2-bceb4feb-windows-alternate.exe
    anki-2.1.16beta2-bceb4feb-windows.exe

  11. Support Staff 11 Posted by Damien Elmes on 06 Dec, 2019 06:08 AM

    Damien Elmes's Avatar

    The one you probably want is anki-2.1.16beta2-bceb4feb-windows.exe

  12. 12 Posted by Elizabeth on 06 Dec, 2019 06:14 AM

    Elizabeth's Avatar

    OMG thank you so much! That worked!!

  13. 13 Posted by Elizabeth on 06 Dec, 2019 03:50 PM

    Elizabeth's Avatar

    Update: I am unable to paste an outline with bullets from Word into Anki 2.1. The text pastes into Anki with all the text at the left (instead of keeping the indents).

    Is there a way to keep the outline format? I've tried changing word doc to PDF and it it still doesn't keep the formatting when pasting into Anki. There was a way I got around this in 2.0 but I forget how I did it.

    Thank you SO much!

  14. Support Staff 14 Posted by Damien Elmes on 06 Dec, 2019 10:26 PM

    Damien Elmes's Avatar

    Word doesn't use a standard way to represent lists, so they come out looking a bit strange. If you open your documents in the free LibreOffice program instead and paste from there, the lists should come out looking better.

Reply to this discussion

Internal reply

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

Attaching KB article:

»

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