Obsidian_to_Anki
Obsidian_to_Anki copied to clipboard
Fields not being properly recognized
Certain fields are not being recognized, and the information that should belong in those fields is being added to whatever field I put on the previous line in the .md file. Here is an example card in Obisidian:
START Drugs
Trade Name: Adenosine(2) Generic Name: Adenoncard
Indication: SVT
Contraindications: hypersensitivity drug induced tach bradycardia How it Works: Decreases electrical conduction through AV node Side effects: - light headedness - hypotension - nausea Adult 1st Dose: 6mg Adult 1st Dose: 12mg Adult 1st Dose: 12mg Pedi 1st Dose: Pedi 2nd Dose: Pedi 3rd Dose: Footnotes: Fast IV, followed w/flush END
And here is what I get in the "Side effects" field:
I've tried renaming the fields, ensuring the spelling is the same between Obsidian and Anki, and clearing the cache.
This happens with other fields as well.
Hello! For you and anyone else having problem with this, I got a workaround. I also cleared cache to everything and didn't fix my problem. After that I tried disabling and enabling the extension and now it recognized the fields it didn't before.
Just in case it makes any difference, my steps were: 1- I disabled the plugin and closed the app. 2- Closed the app. 3- Open the app the again 4- Enabled the plugin.
I don't know if closing the app is needed, I just did it by coincidence.
Possible reason
The issue had been bothering me for quite some time, and I did find some workaround that you can try. The reason why the fields are not being recognized is because the add-on identifies the note types and fields when it's first installed and enabled, and they're not modified automatically when changes are made in Anki.
As shown in the pics below, you can check note types and fields (FILE LINK FIELD) that are currently identified by clicking "Note Type Table" (which doesn't appear to be clickable I know 🥲). If the note types don't contain the targeted field names, which often occurs when they're added to Anki after installing Obsidian_to_Anki, then the targeted field syntax in notes will fail, and the content will be added to the previous field as described.


Temporary solution
The solution that works for me is actually pretty simple. I just uninstall, and install the add-on back for it to capture the note types and fields again. And check if the add-on successfully captures the note types and fields.
The uninstall-reinstall workaround by @TR-792sp5ly worked for me as well.
The uninstall-reinstall workaround by @TR-792sp5ly worked for me as well.
A workaround without having to reinstall (and lose your settings) is to edit the settings file for the plugin directly. Open the file vault/.obsidian/plugins/obsidian-to-anki-plugin/data.json
and scroll down to "fields_dict" to find your card type and fix the fields.
The problem is because generation of FILE_LINK_FIELDS
field in settings
of data.json
is only executed in the fresh install of this plugin:
for (let note_type of this.note_types) {
settings["CUSTOM_REGEXPS"][note_type] = "";
const field_names = await invoke('modelFieldNames', { modelName: note_type });
this.fields_dict[note_type] = field_names;
settings["FILE_LINK_FIELDS"][note_type] = field_names[0];
}
return settings;
To fix this, we need to add the code to Regenerate Note Type Table
button.
The problem is because generation of
FILE_LINK_FIELDS
field insettings
ofdata.json
is only executed in the fresh install of this plugin:for (let note_type of this.note_types) { settings["CUSTOM_REGEXPS"][note_type] = ""; const field_names = await invoke('modelFieldNames', { modelName: note_type }); this.fields_dict[note_type] = field_names; settings["FILE_LINK_FIELDS"][note_type] = field_names[0]; } return settings;
To fix this, we need to add the code to
Regenerate Note Type Table
button.
That's right, I desperately need to add a button like this.
Any update on this issues ? It was quite frustrating to find this out.
I fixed it for myself 2 years ago: #301 I used this fix for a year. I no longer use this plulgin. If you are motivated, you can test it and add automated tests on my PR. I don't have time to do that right now.