debanjandhar12 / logseq-anki-sync

An logseq to anki syncing plugin with superpowers - image occlusion, card direction, incremental cards, and a lot more.
GNU Affero General Public License v3.0
421 stars 30 forks source link

Anki to Logseq Sync #34

Open 9s-l-s9 opened 2 years ago

9s-l-s9 commented 2 years ago

Describe the solution you'd like I want to import my existing Anki Cards in Logseq

Describe how it will help your workflow I (and probably many others) have used Anki for many years before Logseq and have a high amount of cards and decks. Is there any way to import or sync them with Logseq? I know that your plugin syncs in the other direction, but maybe you have some idea :)

Thank you for your amazing plugin.

danieltomasz commented 2 years ago

There is archived rudimentary python app to convert anki deck to markdown https://github.com/kevintruong/ankdown, but I think this is more suited for anki plugin, Obsidian community could be happy to have it too:)

thiswillbeyourgithub commented 2 years ago

Hi!

I'm struggling to understand why it is not possible to do two-way sync. This would be an incredible feature for me.

I have pretty in depth knowledge of anki dev and anki connect and don't see why it would be a problem : just fetch latest modification time of an anki card, compare to a stored value in logseq and take the most recent one.

I would be really interested in knowing why it has not been implemented. Is there an issue I'm not seeing ?

Thanks a lot!

debanjandhar12 commented 2 years ago

Hi!

I'm struggling to understand why it is not possible to do two-way sync. This would be an incredible feature for me.

I have pretty in depth knowledge of anki dev and anki connect and don't see why it would be a problem : just fetch latest modification time of an anki card, compare to a stored value in logseq and take the most recent one.

I would be really interested in knowing why it has not been implemented. Is there an issue I'm not seeing ?

Thanks a lot!

It's not impossible. It's just that I am not entirely sure if I should put in the plugin's development time in this feature. I mainly feel this as there are quite several concern in implementing this: 1) Logseq uses org/markdown. Anki uses HTML. How should the plugin import? Convert Html to Markdown? Hard cuz there can be many ways (and sometimes none) to represent something some HTML in markdown. 2) Conflict issues. (takes a lot of dev time to fix)

Also, I am not entirely sure of the use case of such a feature. Is the aim to import pre-existing Anki notes to logseq? If yes, there already exists some amazing Anki to markdown tools. Is it to edit anki notes generated by the plugin in Anki and see those changes reflected in logseq? This is something that can be made possible. However, again, I am not entirely sure if I should put in the plugin's development time in this feature.

thiswillbeyourgithub commented 2 years ago

Hi!

Thanks a lot for the quick reply.

My main issue with the current state is that it would force me to only edit cards in logseq instead of having the choice between using anki or Logseq.

For the context, I am a heavy user of anki (medical school) and am extremely interested in using PKM toolks such as Logseq. But I can't resort to add cards in a software (logseq) and be restricted to editing them only there (I very often need to edit cards during reviews, so in anki directly).

Regarding your concerns:

  1. Good point. Maybe it could be fixed by choosing the one with the smallest final diff (or levenstein distance etc) in the markdown output? And when two versions differ by more than a predefined threshold : ask to review the changes before accepting.

  2. Given that most cards are never edited, it seems totally acceptable to have to manually accept every change from anki to logseq. This would probably make it easier to develop and troubleshoot. This could be an opt in experimental feature as well.

My aim is not at all to convert my cards created in anki to logseq, but to have a fluid workflow between anki and logseq that allows me to edit cards where I'm most confortable doing it etc. I think logseq can be a superior tool than anki to dig a subject in depth but anki will always have the upper hand in terms of spaced repetition. The best of both world would then be a two way sync.

Writing my notes in logseq, turning some of them into anki flashcards but still being able to edit them in anki seems like a dream come true I must say! And I have to say, I am genuinely surprised to be among the first to request such a feature.

thiswillbeyourgithub commented 2 years ago

By the way : in the past I wrote extensive changes to anki connect in a PR and implemented a function to get ModTime of a card :

    @util.api()
    def cardsModTime(self, cards):
        result = []
        for cid in cards:
            try:
                card = self.getCard(cid)
                result.append({
                    'cardId': card.id,
                    'mod': card.mod,
                })
            except NotFoundError:
                # Anki will give a NotFoundError if the card ID does not exist.
                # Best behavior is probably to add an 'empty card' to the
                # returned result, so that the items of the input and return
                # lists correspond.
                result.append({})
        return result

This would be handy in this situation.

thiswillbeyourgithub commented 2 years ago

Any update ? How can I be the only one to want to use both anki and logseq without logseq overwriting anki :) ?!

edit : found some other people who get what I mean https://reddit.com/r/Anki/comments/p0wy73/anyone_interested_in_anki_to_markdownobsidian/

9s-l-s9 commented 2 years ago

Well @thiswillbeyourgithub, I opened this issue, so I am certainly interested. However, @debanjandhar12 has already provided good reasons, why it is not really pracitcal. I don't think levenstein distance is suitable for such a task.

zhanghaofg commented 2 years ago

你好,可以将anki中的卡片学习时候的#card去掉以及通过点击最上面那个可以回到logseq

Futur3r commented 1 year ago

+1 @thiswillbeyourgithub !

@debanjandhar12, I have the same issue as @thiswillbeyourgithub. No need to implement creation of card from Anki to Logseq. Just at least to be able to change a bit of text on Anki on cards synced from Logseq.

Most of the time I review my card using the free web interface of Anki on my phone and there is just a simple text editor. If I don't make the change on the spot I will forget and lose time.

navakelvin commented 3 months ago

Necessary +1.