Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields not being properly recognized #252

Open
matthew3wilson opened this issue Jun 2, 2021 · 9 comments · May be fixed by #301
Open

Fields not being properly recognized #252

matthew3wilson opened this issue Jun 2, 2021 · 9 comments · May be fixed by #301

Comments

@matthew3wilson
Copy link

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:
image

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.

@erbara
Copy link

erbara commented Jun 23, 2021

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.

@TR-792sp5ly
Copy link

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.

Screen Shot 2021-07-06 at 17 35 37

Screen Shot 2021-07-06 at 17 36 09

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.

@andrewalseth
Copy link

The uninstall-reinstall workaround by @TR-792sp5ly worked for me as well.

1 similar comment
@digitall-it
Copy link

The uninstall-reinstall workaround by @TR-792sp5ly worked for me as well.

@MudcrabDev
Copy link

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.

@Leegenux
Copy link

Leegenux commented Sep 10, 2023

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.

@Leiyi548
Copy link

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.

That's right, I desperately need to add a button like this.

@gorbach
Copy link

gorbach commented Feb 17, 2024

Any update on this issues ? It was quite frustrating to find this out.

@tlgman
Copy link

tlgman commented Feb 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants