jasonwilliams / anki

Anki VSCode Plugin
MIT License
281 stars 31 forks source link

Need rewrite deck card! #31

Closed snake89322 closed 2 months ago

snake89322 commented 3 years ago

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?

jasonwilliams commented 3 years ago

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.

fletchermoore commented 3 years ago

@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 commented 3 years ago

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:

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.

snake89322 commented 3 years ago

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~

searene commented 3 years ago

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.

jasonwilliams commented 3 years ago

@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

memeplex commented 2 years ago

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
jasonwilliams commented 2 years ago

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?

memeplex commented 2 years ago

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--> ?

benjamin-weller commented 2 years ago

@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?

jasonwilliams commented 2 years ago

@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

benjamin-weller commented 1 year ago

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

jasonwilliams commented 1 year ago

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

jasonwilliams commented 4 months ago

I'm wondering if this issue still needs to be open, now that updating cards is now possible https://github.com/jasonwilliams/anki?tab=readme-ov-file#update-cards-beta

benjamin-weller commented 2 months ago

Yeah FFT close

On Sun, Jun 30, 2024 at 7:35 AM Jason Williams @.***> wrote:

I'm wondering if this issue still needs to be open, now that updating cards is now possible https://github.com/jasonwilliams/anki?tab=readme-ov-file#update-cards-beta

— Reply to this email directly, view it on GitHub https://github.com/jasonwilliams/anki/issues/31#issuecomment-2198583026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMCR52YBRHCTOCA45KA653ZKAJS3AVCNFSM6AAAAABKEFCBN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGU4DGMBSGY . You are receiving this because you were mentioned.Message ID: @.***>