anki icon indicating copy to clipboard operation
anki copied to clipboard

Need rewrite deck card!

Open snake89322 opened this issue 4 years ago • 13 comments

new markdown and use “send to deck”, it's ok! but then I modify the markdown,same title,then “send to deck”,no changes in Anki.

## Foo

bar

send to deck - OK!


## Foo

bar change

send to deck - not changes!

How can I rewirte the same card?

snake89322 avatar Jan 18 '21 02:01 snake89322

Hi @snake89322 thanks for raising. Rewriting functionality currently doesn’t exist, what you’re seeing happen is the Anki extension preventing you from overwriting a card that already exists.

is your expectation that the title is the same so it should edit?

When I last attempted this it wasn’t easy, but I’ll leave this open as a feature request and take another look some time. For now you will have to delete it in Anki and send again.

jasonwilliams avatar Jan 18 '21 08:01 jasonwilliams

@snake89322

If this happens, would you expect the edited card to retain the spaced repetition information, supposing you already memorized it. Or would you expect to start memorizing it again as a new card?

Also, what do you expect should happen if you edit a card in Anki instead? Will the markdown replace that card if you send it again? Or should it add a new card to the deck?

fletchermoore avatar Feb 01 '21 01:02 fletchermoore

So I was about to send a pull for my allowOverwrite option. I have noticed more than one issue posted here that people want the ability to add duplicates. Since this functionality is contrasting allowOverwrite, they perhaps need to be an option menu.

Possible options would be: anki.send.duplicateBehavior:

  • Delete and replace if fronts match but backs do not (resets learning data)
  • Update in place, leaving learning metadata unchanged
  • Make the duplicates anyway
  • Leave things unchanged

If you change the front of a markdown card it will necessarily create a new card, since backs are not intended to be unique identifiers in Anki.

fletchermoore avatar Feb 08 '21 11:02 fletchermoore

I find new API anki-connect: updateNoteFields https://github.com/FooSoft/anki-connect/blob/master/actions/notes.md

it works, hopes add in new version soonly! 3ks~

snake89322 avatar Jun 07 '21 02:06 snake89322

It would be nice if I could update the front side of the card too. It requires attaching the Anki note id to the question when added:

## This is the question
:PROPERTY_ANKI_NOTE_ID: 134141234

This is the answer

Thus when I change the question or the answer, Anki For VSCode should notice that the card is already added before, the preferable behavior should then be update instead of create.

This is the idea behind anki-editor.el. However, anki-editor.el use the org-mode syntax, which allows attaching properties to headings. markdown doesn't have an official way to do it.

We sometimes do need to modify the question, but currently there's no simple way to do it. I don't have a solution, either. I'm just offering some ideas and hoping it can inspire someone to give a solution.

searene avatar Oct 04 '21 05:10 searene

@searene have a look at the https://github.com/jasonwilliams/anki/issues/33 issue which fleshes out the implementation a bit more and feel free to comment there

jasonwilliams avatar Oct 04 '21 12:10 jasonwilliams

Obsidian dataview and Logseq are using the property:: value syntax for metadata, see https://blacksmithgu.github.io/obsidian-dataview/data-annotation/. For example:

## Really?
anki-id:: 123

Yes

or

## Really? [anki-id:: 123]

Yes

memeplex avatar May 04 '22 03:05 memeplex

Hey @memeplex thanks for the suggestion, its useful to see how others are doing it. I wonder if frontmatter is the most standard way of doing it so that other markdown viewers don't show the data. Do you know if these inline fields will show up on markdown viewers/editors?

jasonwilliams avatar May 04 '22 09:05 jasonwilliams

Yes, they probably will, these are conventions more or less adopted by the PKM community, but just that.

The obsidian-spaced-repetition extension uses this syntax <!--SR:!2022-05-06,3,250-->. This probably is compatible with every markdown tool out there. Perhaps <!--ANKI:ID=123--> ?

memeplex avatar May 04 '22 19:05 memeplex

@jasonwilliams Would you be willing to accept a PR for this work? Any suggestions on how to get started working on developing this improvement for the extension?

benjamin-weller avatar Oct 05 '22 03:10 benjamin-weller

@benjamin-weller PRs are welcome, but I would be willing to hear how you plan to approach this fix too. Whether you want to explain that here or in the PR that’s fine.

As for contributing, you can just check this out and run the debugger in VSCode with Anki also loaded. That’s about it

jasonwilliams avatar Oct 05 '22 12:10 jasonwilliams

See my pull request for parsing note IDs.

I intend to further develop here such that you can automatically insert the created note ID beneath the ##/h2

benjamin-weller avatar Dec 23 '22 19:12 benjamin-weller

I also came across https://github.com/EvitanRelta/htmlarkdown which could be useful for converting the rendered HTML back to markdown

jasonwilliams avatar Jan 05 '23 20:01 jasonwilliams