reuseman / flashcards-obsidian

🎴 An Anki plugin for Obsidian.md
MIT License
897 stars 87 forks source link

Support for note types in Anki #63

Closed digitall-it closed 2 years ago

digitall-it commented 2 years ago

Is your feature request related to a problem? Please describe. Ciao da Ischia, Napoli. In Anki you can have note types with more fields. For example the note type Element could have a Name, Symbol, Type, Group, Period, and based on that multiple cards can be generated. That allows you to form the cards questions in Anki based on the data. This plugin created some basic note types in Anki and fixed the fields to Front and Back but doesn't allow seem to allow you to change it, so you have to manually create all the questions.

Describe the solution you'd like The plugin Dataview uses the frontmatter as a data source which is already there in YAML format. The cards-deck: tag is already supported, you just need the cards-type: tag. The generated cards reference IDs could be automatically added as a tag, like cards-ID: ####, ####, ####.

Describe alternatives you've considered Consulted the documentation but found none. Also tried another plugin but doesn't seem to help out.

Additional context

Example frontmatter

---
tags: element
Number: 16
Symbol: S
Series: Non metals
Group: 16
Period: 3
cards-deck: Chemistry
cards-type: Element
---

and once saving it becomes (preferred form)

---
tags: element
Number: 16
Symbol: S
Series: Non metals
Group: 16
Period: 3
cards-deck: Chemistry
cards-type: Element
cards-ID: 156198198, 1981951561, 156162132
---

or (unfavored form)

^156198198

^1981951561

^156162132
github-actions[bot] commented 2 years ago

Thank you for taking the time to report the issue and help me to make the project better! 🙂

reuseman commented 2 years ago

Ciao @digitall-it !

It's a great proposal, and it totally makes sense, but it takes for sure a big rewrite in terms of code that for the time being I cannot invest on. The cards-ID in the front matter are a nice way to remove pollution from the main body, even though in preview mode they are not shown. The only problem it could be the number of cards is huge, then the pollution is moved from the body to the front matter. Moreover, it's trickier to understand whether what is marked with #card it has actually been inserted in Anki or not, but probably it's a minor thing.

digitall-it commented 2 years ago

Grazie @reuseman,

actually I am using another plugin that has the implementation that I wanted,

---
tags: elementi, lezione/1
Numero: 51
Simbolo: Sb
Serie: Semimetalli
Gruppo: 15
Periodo: 5
---

%% Inizio carta
Elemento
Nome: Antomonio
Numero: 51
Simbolo:  Sb
Serie:  Semimetalli
<!--ID: 1636047477512-->
Fine carta %%

The %% Inizio carta and Fine carta %% strings can be configured (the defaults are a bit naïve, START and END, and in this way I actually hide the data, that is already in the front matter), and the plugin caches the Anki card templates list on first init (it means that if you change a Anki template vars or add a new Anki template you'll have to uninstall it, reinstall it and reconfigure it from scratch), and also you will have to duplicate the data that is already in the front matter and that I use to populate the dataview here:

```dataview
table Numero as "N", Simbolo, Serie, Gruppo, Periodo
from #elementi
where Numero
sort Numero asc
``` -

So, it is not perfect by any means, and also has its limits, but doesn't seem to impose a template (the last dash is to not trigger Github code view mode).

Actually, you can show what's on the front matter in Obsidian by using the "Show front matter" option).

image

If needed, Dataview allows to add data inside the note itself, in the format Field name :: Value.

I understand that this would mean a huge rewrite of the code, and probably is overkill to many Anki users that want a more basic implementation (it takes time to understand the other plugin and has some quirks) that seems to work in a more stable way, so my last drop of information for anyone else that may read my comment is, if you want those other features, you may need the other plugin, so follow the link I gave at the start, but be prepared as it may take some time and not be as stable and straightforward as this one, that goes as far as creating Anki templates for you prefilled with expected var names (and that I suppose you can also customize after the creation).