Skip to content

Add basic support for AnkiConnect (WIP)#16

Closed
MarkoSagadin wants to merge 1 commit into
Mochitto:mainfrom
MarkoSagadin:feature/ankiconnect_proto
Closed

Add basic support for AnkiConnect (WIP)#16
MarkoSagadin wants to merge 1 commit into
Mochitto:mainfrom
MarkoSagadin:feature/ankiconnect_proto

Conversation

@MarkoSagadin
Copy link
Copy Markdown
Collaborator

This is a prototype implementation.

In the current state the md2anki will:

  • Send processed cards to the Anki via 'addNote' API
  • Send images to the Anki via 'storeMediaFile' API
  • Display basic info when that is being done
  • Display error messages if any step fails

This feature is far from done:

  • deck name and note type are currently hardcoded, they should be provided by the caller for each card/note.
  • error handling and validation are missing.
  • code style will probably need to be adjusted.

There are several TODO comments that ask questions.

Related: #3

This is a prototype implementation.

In the current state the md2anki will:
- Send processed cards to the Anki via 'addNote' API
- Send images to the Anki via 'storeMediaFile' API
- Display basic info when that is being done
- Display error messages if any step fails

This feature is far from done:
- deck name and note type are currently hardcoded, they should be
  provided by the caller for each card/note.
- error handling and validation are missing.
- code style will probably need to be adjusted.

There are several TODO comments that ask questions.

Related: Mochitto#3
@MarkoSagadin
Copy link
Copy Markdown
Collaborator Author

I should add that I was testing the AnkiConnect functionality with this example markdown text.

It works as expected, everything is sent over to the Anki.

@Mochitto
Copy link
Copy Markdown
Owner

Integration of this PR:

@Mochitto
Copy link
Copy Markdown
Owner

Mochitto commented Jan 22, 2024

Steps needed to implement the feature:

  • Update the flow of the app to check for anki-connect; if there is none, throw an error
  • Send a demo card to anki (mvp)
  • Fetch decks and note types from anki (or expose specific note types)
  • Process possible metadata coming from cards and create the data-structure to send all the metadata to anki
  • When processing a card, check if the note type/deck exists else write error to card and dump it to "bad cards", else send it to anki
  • Add support for sending images
  • Isolate the process that creates CSV files as a fall-back for when users do not have AnkiConnect (or prefer files for any reason), signed as "legacy" in the config
  • Add CSV/AnkiConnect option in the config file
  • Add ankiConnect's url to the config (for users that set it up to be a remote connection/something other than the default)
  • Handle edge cases (connection errors, anki connect errors, duplicate cards)

MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Feb 16, 2025
This commit adds for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy feature, it is by
default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Feb 22, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3
@MarkoSagadin
Copy link
Copy Markdown
Collaborator Author

Closing this PR in favor of #29.

MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Mar 3, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Mar 3, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Mar 3, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3, Mochitto#21
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Mar 23, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3, Mochitto#21
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Mar 23, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3, Mochitto#21
MarkoSagadin added a commit to MarkoSagadin/Markdown2Anki that referenced this pull request Dec 3, 2025
This commit adds support for uploading cards via AnkiConnect plugin.
Generated cards are now by default uploaded to the Anki via the plugin.
The accompanying images references in the cards are also uploaded via
the plugin.

The addition of the AnkiConnect support means that frontmatter block is
mandatory, since some of the fields are required by the plugin to
upload the cards to the correct Anki deck, to use the correct note type,
etc.

The mandatory formatter fields are:
- deck_name
- note_type_basic
- note_type_cloze

The tags field is optional.

The generation of Anki cards in CSV format is now marked as a legacy
feature, it is by default turned off.

User can also change the default URL of the AnkiConnect server via the
.ini config file.

Future work:
- The code currently skips when trying to upload a card duplicate. In
  the future there an update system could be implemented. This would
  support a usecase where users would like to fix the already uploaded
  card via the markdown input file.
- Currently the users need to provide the images file to the md2anki
  config file. This is not really needed, as the information about the
  image location is in the input markdown document itself. So that could
  be removed and thus UX would be a bit better, since that would be one
  less config option to carry about.
- Currently the images must be local, there is no support for providing
  URL image links. Support for that could be added.

Related: Mochitto#16
Closes: Mochitto#3, Mochitto#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants