Updates to Anki IR Plugin

Another day of improving the Anki Incremental Reading plugin. It's starting to get more solid now.

New "features": more solid extraction highlighting and automatic jumping to previous reading position (more precisely, last extracted section)

I've fought hard against Qt, as it continuously subverted my efforts to highlight the extracted sections. Technically, when you select a region I switch the card to editable and paste a replacement code right into the place of your selection (just like using Ctrl+V). However, pasting HTML code into another HTML document via Qt results in lots of strange things happening. In the end, it boiled down to distinguishing two cases of what was selected and either pasting the highlighting contained in a div or span. Using only one or the other, or even always pasting both, never worked consistently, but now it worked fine for the cases I tried.

But the really nice feature is the addition of a small (Last Extract) text, before the selected section. This includes an HTML anchor that the view will jump to the next time you load that card. In other words: In a large article, once you made a few extractions and finish for the day, you can reload the document the next day and start off right where you left. I've also notified more people now who have previously shown interest in IR for Anki to try out the plugin.

I'll wait for some more feedback on this early version, before announcing it on the Anki mailinglist and eventually making it available as a shared plugin. So if you're reading this now and going to try out the plugin, leave me a comment of your experience with it.

Latest version available here.


Hi, it looks good! That's great you keep improving it.

The only problem I've noticed is that the hotkeys are missing. When I do the incremental reading, I select texts to extract and add them as new items without any editing, and keep reading. Only later do I review the selected extracts and edit them. It would be great to be able to make an extract from selected text with one keystroke, as in the previous version.

One more comment, I noticed that the extracted items don't get the incremental_reading tag. I think they should, since sometimes you just extract a bigger chunk of text to read it later (and extract smaller items from it).

Thanks for the feedback.

As I didn't stay up to date on all the changes Damien made and hence rewrote it from scratch, I just left out the hotkeys so far. But they'll definitely be added again, though I can't give any ETA.

As for the tagging: I suggest a deck specific to IR, so by default all cards in there should be treated as if they had an incremental_reading tag. Personally, I instead mark extracted (or newly created) cards that have a traditional question-answer style with a special tag. I haven't decided yet, whether I'll add any work on the tagging, because Damien has some radical changes planned to the whole tag-system, which will likely break every tag-related feature I add now.

Hi Frank,

It's looking good on OSX too! Keep up the good work!

I needed to do a few extra steps to test it on my Mac. I ended up downloading the libxml2 source code tarball appropriate for my OS version (found via running "more /usr/lib/xml2Conf.sh"). I my case this was libxml2-2.7.3. I unpacked this, cded to the python subdirectory and ran "sudo python setup.py install" to install the python xml bindings. I then copied the libxml2 python extensions into my Anki installation using

cp /Library/Python/2.6/site-packages/libxml2.py /Applications/Anki.app/Contents/Resources/lib/python2.7/

cp /Library/Python/2.6/site-packages/libxml2mod.so /Applications/Anki.app/Contents/Resources/lib/python2.7/

I then removed libxml2.py and the libxmlmods directory from the plugins directory and the IR plugin worked on my Mac install. Obviously once the libxml2 python bindings come bunded with Anki I wont need to do this :)

I did find a minor bug when I first started the plugin. For an empty deck, the "Add url for IR" doesn't appear to pickup the clipboard entry when it comes from another application. I could work around this by clicking on "add items" pasting the url into the create card window, copying it again and then retrying the "Add url for IR". The plugin then picks up the url and downloads the web page as expected. This problem only occurs with an empty deck, once there are cards in the deck it operates as expected.


It doesn't seem to work at all on Ubuntu...

I haven't tested it on Ubuntu yet. I'll try to do so and update it when I can identify any problems. Thanks for the info.

Update: This should be fixed.

Very good work done with this plugin!  Keep it up! :))

Hi Frank, 

Love love your plugin.  Unfortunately it stopped working on my windows 7 computer and I get this error:


An error occurred in a plugin. Please contact the plugin author.
Please do not file a bug report with Anki.

Traceback (most recent call last):

File "C:\cygwin\home\dae\Home\anki\win\build\pyi.win32\anki\outPYZ1.pyz/ankiqt.ui.main", line 2679, in loadPlugins

File "c:\pyi\iu.py", line 439, in importHook

File "c:\pyi\iu.py", line 524, in doimport

File "C:\Users\Luke\AppData\Roaming\.anki\plugins\AnkiIR.py", line 33, in

import libxml2, urllib2, tempfile

File "c:\pyi\iu.py", line 458, in importHook

ImportError: No module named libxml2

It should work on Win7 principally (that's what I'm using here anyways). Make sure you copied all the files contained in the .zip to your plugins order (if you used an older version, please download the latest again). If that isn't helping, try to download and copy the appropriate libxml2 python bindings for your system.

Belay--my last.  I was missing libxml2.  Thanks again for making this!


Best, Luke

Great post.


I love your blog.. very nice colors & theme. Did you make this website yourself or did you hire someone to do it for you? Plz reply as I’m looking to create my own blog and would like to know where u got this from. cheers

Thanks. I made the theme myself, but the basic website considering features, database backend, etc. is Drupal.