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

Markdown input as folder or file #12

Open
Mochitto opened this issue May 29, 2023 · 2 comments
Open

Markdown input as folder or file #12

Mochitto opened this issue May 29, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Mochitto
Copy link
Owner

Mochitto commented May 29, 2023

When using markdown to anki, it's likely to create different templates for different decks.
As #11 turns markdown files in "templates" or "note types", it's likely that users will have a main folder where all of the templates live.

As of now, the configuration only expects a file as input, but it would be useful if it could also accept a folder and automatically iterate and process all files.

This would require also a slightly different interface (UI) that reflects which file is being processed, as well as thinking how to handle bad cards (maybe they can be written to the original file after clearing it?)

Steps

  • Update the config interface to reflect the change
  • Update the config validation to allow for directories
  • Add a conditional statement checking if it's a directory or a file
  • Use os to find and iterate through all .md files
  • Add for loop to process all files
  • Update logging to reflect what file is being processed
@Mochitto Mochitto added the enhancement New feature or request label May 29, 2023
@Mochitto Mochitto assigned Mochitto and unassigned Mochitto May 29, 2023
@Mochitto Mochitto moved this from Backlog to Todo in Markdown2Anki Sep 2, 2023
@MarkoSagadin
Copy link
Collaborator

I would like to have this feature, would be happy to implement it.

One question though about this: what if user has a folder if markdown files where not all files are "Markdown2Anki" files and shouldn't be processed by the md2anki?

I can see this happening for the Obsidian users, where they could keep the usual markdown about some topic and then the "Markdown2Anki" file with questions and answers.

What would be the suitable filtering system in this case? A specific filename convention? Usage of mandatory field in the frontmatter, like md2anki: true?

In this case the UI should also show which (or just how many) MD files it found, and how many are even valid to be considered for processing.

What do you think?

@Mochitto
Copy link
Owner Author

Mochitto commented Feb 25, 2025

I would like to have this feature, would be happy to implement it.

One question though about this: what if user has a folder if markdown files where not all files are "Markdown2Anki" files and shouldn't be processed by the md2anki?

I can see this happening for the Obsidian users, where they could keep the usual markdown about some topic and then the "Markdown2Anki" file with questions and answers.

What would be the suitable filtering system in this case? A specific filename convention? Usage of mandatory field in the frontmatter, like md2anki: true?

In this case the UI should also show which (or just how many) MD files it found, and how many are even valid to be considered for processing.

What do you think?

We can either make users add the flag or enforce having only markdown2anki template files in the folder.

Enforcing filenames is pretty much the same as enforcing users to have a special folder that only holds md2anki files and is not very flexible I think.

I think the enforcing only markdown2anki files in a folder is hard...
Since there's not really an easy way to run pre-processing to ensure files are valid markdown2anki inputs, so I'd go with the first option and make it required only if users are using the folder input.

Example

  1. Users uses the input folder option -> only files with "md2anki: true" in the frontmatter will be selected for processing
  2. User uses a file input -> the flag is not required, since we don't need to filters files to know which one to process

CLI UX

As for the user feedback in the CLI, I think saying "📚 X md2anki files found! Starting to process them..." and "📖 processing: ..." would be enough.

Bad cards

What puzzles me a bit would be how to handle "bad cards" with multiple files. It's easy if the "clear file" option is set to true, since we can just replace the inserted cards with the bad ones, but I'm not sure how to handle them when users want to keep their input...

Let me know if you agree and have ideas on this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants