feat: add AnkiConnect plugin support#29
Conversation
Mochitto
left a comment
There was a problem hiding this comment.
Looks awesome! :))
Minor comments on documentation
README.md
Outdated
| Mandatory fields: | ||
| - `deck_name` - The name of the deck where the cards will be imported. | ||
| - `note_type_basic` - The name of the note type for basic cards. | ||
| - `note_type_clode` - The name of the note type for cards with clozes. |
| - Support for continuous integration with GitHub Actions. Backend and frontend will now build with every push to the `main` branch or to the opened PR. (@MarkoSagadin) | ||
| - Automated release process with GitHub Actions. A new release can now be manually triggered by providing the next version tag under the _Actions_ tab in the GitHub Web UI. (@MarkoSagadin) | ||
| - Added information on how to build the backend project for developers. | ||
| - Added first configuration option for frontmatter metadata blocks in the input markdown files! [Frontmatter blocks] allow you to configure options per single markdown file. The first added property is called `no_tabs`. When set to `True`, it disables tabs in generated cards. (@MarkoSagadin) |
There was a problem hiding this comment.
Missing notes on the other frontmatter options and ankiconnect support
| Images that are already present won't be added twice and will be skipped (based on filename). | ||
| If you prefer checking the images before importing them manually, you can point to another folder or leave the default one. | ||
| **Notice:** when images are copied, they lose their metadata: this is due to security, as others' could read your images metadata if you were to share your cards, and for how the python library that handles the copying process is implemented. | ||
| [legacy CSV file]: ./docs/legacy_importing_cards_with_csv.md |
There was a problem hiding this comment.
You can turn this into a markdown link [Legacy CSV imports]( ./docs/legacy_importing_cards_with_csv.md) and put them in-line instead of as a foot-note
There was a problem hiding this comment.
Actually this also a markdown link, it just uses a bit different syntax. Markdown footnotes are a bit different.
|
Oops I commented on the commits one by one here :') There seems to be conflicts 🙈 I think the changes are great and ready to be pushed to pypi; I'll do that as soon as the comments are solved :) Great job! |
Mochitto
left a comment
There was a problem hiding this comment.
I've also noticed that you've added some notes for future developments in one of the commit messages; you might like to open issues so that you can use the Markdown2Anki kanban to handle their development and track them :)
| deck_name: str, | ||
| note_type_basic: str, | ||
| note_type_cloze: str, | ||
| tags: list[str] | None = None, |
There was a problem hiding this comment.
It would be useful to add a md2anki tag to all cards made by markdown2anki by default, so that users can query them easily #21.
This should be easy to add as "default" and have the incoming list append to it
|
I have cleaned up the merge conflicts in the PRs below this one, I only need to add the |
2b8387e to
89bc314
Compare
|
Added the default |
89bc314 to
6d96014
Compare
6d96014 to
0fe3754
Compare
With this change is now possible to disable presence of tabs, by adding the below frontmatter snippet to the top of the markdown file: --- no_tabs: True --- If present then: - 'L', 'R', '-', '+' tab flags are ignored, only 'F' and 'B' matter. - Tab labels don't matter To avoid possible styling interference two new classes were created: body and body__content. They are a direct copy of the tab__body and tab__body_content classes, only that their display property is set to 'flex' instead of none. The python code now generates the html out of markdown as it would normally and wraps content in the above two mentioned containers. That way no tab-related styling is present. Finally, all the changes in the main.ts make the presence of the .tab_group selector optional. If not found then no extra logic is enabled and content is present on single page.
It is now expected that every markdown document contains frontmatter block with three required fields: - deck_name, - note_type_basic and - note_type_clozes tags and no_tabs fields are optional. Currently only no_tabs field is actually used. Closes: Mochitto#11
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
0fe3754 to
0bb71ac
Compare
This commit support 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:
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 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.
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.
URL image links. Support for that could be added.
Related: #16
Closes: #3
Note
This PR was branched out from #28 PR. #28 should be first merged, and then this PR will show valid changes.