anki icon indicating copy to clipboard operation
anki copied to clipboard

How to stop text inclusion in Anki card?

Open sophyphile opened this issue 3 years ago • 9 comments

Hi guys, apologies if this is a stupid question, I'm new to VS Code.

I want to add an Anki card, and then have some sort of closing operator, so that the text I write after it is not part of the Anki card. How can I do this? Is it possible with this software?

sophyphile avatar May 29 '21 21:05 sophyphile

Hi @sophyphile sorry for the delayed response. I will have to try and add that as currently it’s not possible.

do you have an example to show which may help me fix this?

jasonwilliams avatar Jul 25 '21 16:07 jasonwilliams

Hi @jasonwilliams I have an a similar issue:

I have a case here:

# Topic header
Description of topic, notes etc.

first card:

## card 1
front1

%

back 1


# Topic header 2
Description of topic, notes etc.

## Card 2

front

%

back

Here the topic header 2 is included in the first card, which is naturally not the goal. One option would be to add a stop token (e.g. ## or \n\n)

KennethEnevoldsen avatar Nov 21 '21 17:11 KennethEnevoldsen

Hmm yeah I wonder if stopping on a H1 would help? It already stops if it sees another h2 I believe. I’m open to ideas

jasonwilliams avatar Nov 21 '21 18:11 jasonwilliams

Stopping on H1 would help in my case. But adding an optional stopping token using regex would also be an option.

Another option would be to change the regex for detecting the card to instead of detecting the start of the card (##) use the regex to find the entire card e.g. the regex ^##((.|\n)*)## would match from ## to the next ##. If you don't want to include the ## then (?<=##)((.|\n)*?)(?=##)should also work.

KennethEnevoldsen avatar Nov 21 '21 18:11 KennethEnevoldsen

It seems it might be relevant to also remove ignore comment i.e. <!-- markdown comment -->.

KennethEnevoldsen avatar Nov 21 '21 19:11 KennethEnevoldsen

https://github.com/jasonwilliams/anki/issues/10#issuecomment-678828123 Uses <!— Card —> maybe that’s an options

jasonwilliams avatar Nov 21 '21 21:11 jasonwilliams

Sure. However, do believe that a field with a regex for extracting the card whether it be HTML comments or using another syntax would be ideal. This would allow the user to customize to their needs

KennethEnevoldsen avatar Nov 22 '21 08:11 KennethEnevoldsen

Yes we should offer an option for that. I’m just thinking of the most reasonable default

jasonwilliams avatar Nov 22 '21 08:11 jasonwilliams

I Think HTML comment is a poor default though as it is also a comment thus I would expect it to ignore it in markdown documents potentially one of these from the anki integration with obsidian: https://github.com/Pseudonium/Obsidian_to_Anki

KennethEnevoldsen avatar Nov 22 '21 08:11 KennethEnevoldsen