reuseman / flashcards-obsidian

🎴 An Anki plugin for Obsidian.md
MIT License
872 stars 86 forks source link

Fixes creating multipne `cards-deck` lines for newly created cards #145

Open putzwasser opened 1 year ago

putzwasser commented 1 year ago

Currently, if you add a new flash card and import it to anki, then flashcards-obsidian adds a new frontmatter line of

cards-deck: ${yourCardsDeckName}

to you file, which is unnecessary and annoying.

This tries to fix the creation of multiple cards-deck YAML/frontmatter lines during the process of adding new flash cards to anki.

This is more like a hotfix as I'm not sure if it solves the problem bug completely (or might lead to other problems).

bytewife commented 1 year ago

Hey @putzwasser,

I'm not sure I quite understand this change. You're saying you are having multiple cards-deck frontmatter fields added when generating a card, right? I'm unable to reproduce this bug. Could you provide an example where this bug occurs?

putzwasser commented 1 year ago

See this screencast (with spelling error :wink: )

screencast.webm

This happens every time a new card, i.e. new anki ID, is added to anki.

You can tell this behaviour from the updateFrontmatter function itself. It just checks if the frontmatter string is set. If so, add the cards-deck line, if not add a whole new/inital fontmatter block and add a cards-deck line there.

bytewife commented 1 year ago

I see. Yeah I can reproduce this error. However, the PR does not appear to fix the issue. Could you look into this?

bytewife commented 1 year ago

Also, could you link this PR to an Issue? Thank you!

putzwasser commented 1 year ago

However, the PR does not appear to fix the issue. Could you look into this?

Unfortunately, I can't as it fixed it for me.

Also, could you link this PR to an Issue? Thank you!

There's none.