Obsidian_to_Anki v3.4.0 - a feature-rich plugin that allows you to add notes from Obsidian to Anki

Hello, how exactly do I put my notes in a specific sub-deck?
Let’s say that I have a main deck of: Molecular Bio and a sub-deck of: A. Homeostasis Regulation
If I a make a target deck of A. Homeostasis Regulation, it just creates another main deck of A. Homeostasis Regulation that is outside of Molecular Bio.

Have you tried the format “Parent Deck :: Child Deck”. You have to create this Deck in Anki first. Here is what I tried and it worked.

image

1 Like

Hello, thank you. It’s now working. Is this in the wiki somewhere?

Well, I fumbled my way to the very tiny edit that allows this to work. Hope it is helpful to others!

  1. the string to use the above method is ^# Q:((?:.+\n)*)\n*## A:(.+(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)
  • a flashcard will only be generated if a space occurs after/on the same line as the Q: and A:
  • it supports nested questions and answers, embedded images.
  • The end of the flashcard is at the point of any white space in the answer. It will also not run if there is white space in the question. Can someone please help adjust the code so that it traverses across white space? thanks.
  1. Use Espanso for template hotkey
  • I found that Obsidian to Anki was trying to make a flashcard out of my flashcard template.md
    image

how can I get the Regex script to pick up all the new lines within the answer until the next flashcard?
image

Regex script: ^# Q:((?:.+\n)*)\n*## A:(.+(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)

Hi, I am quite new to regex. When I saw your question, I wanted to use it as an opportunity to apply the little regex knowledge I have and have been trying to understand the regex used in Q&A since yesterday. I have understood it just enough to provide some pointers for you. I am yet to understand how the negative lookbehind works (which eliminates the ID tag from the answer). But here is something I have tried - please see whether this would help you to move forward.

What I have done is to to add this portion inside the capture group bracket:
.* - match any char 0 or more times
\n* - match any number of new lines
together, they would allow the regex to have some lines, followed by some empty lines, followed by lines, followed by empty lines, etc.

Please check whether this works for you.

I am trying to comment out the Q&A regex - here is what I have now along with some questions I am trying to find answers to. Any help from anyone with experience in regex would be greatly appreciated.

^Q: 				# Literal
	(				# Capture Question content
		(?:.+\n) 	# Match one or more characters followed by newline
	*)				# Match group can occur 0 or more times - so, there can be no content after Question?
	\n*				# one or more new lines
A: 					# Literal
	(				# Capture Answer content
		.+ 			# Same as question - 1+ char 
		(?:\n		# Match new line
			(?:^.{1,3}$	|	^.{4} 	# Match 1 to 4 chars. why?
				(?<!<!--)			# negative lookbehind. I don't understand it yet
			 .*)					# 0 or more chars
		 )
	 *)				# capture the pattern 0 or more times

Here is a site which I have found to be very useful

here if you hover over the different parts of the regex, it provides an explanation which I have found to very helpful for me as a beginner.

here is another helpful site - debuggex.com

1 Like

It is Anki knowledge. I have found this video to be very comprehensive in covering Anki and how to make it work with Obsidian

Is there a way to just to link audios and images online in the notes and they get downloaded into anki at the time of syncing? such automation would be very time saving

Wow, thanks. I haven’t watched the video yet, but it seems like I have a lot to go through

I have a problem when using Hint to cover a text, eventho it works for adding the field it also added the content for this field to the one before it (adds it twice). I think it is a bug. Does anyone have the same problem?

P.S.: Nevermind, the cause is the problem with regenerate button not working and updating fields again. sometimes it works and sometimes it doesn’t. hope the devs fix this one soon. I can’t use this plugin like this.

I’m frequently getting errors syncing this plugin, with this error thrown

VM141:667 Uncaught (in promise) TypeError: this.field_names is not iterable

It went away for a while, and now is back. Anyone experienced this/got a solution?

The same error is thrown when trying to regenerate the note type table.

Edit: upon further inspection, from what I can see the plugin doesn’t update its note types properly when you change the name of note type in Anki.

Found the issue already reported in github with a workaround: Renaming note-types breaks them · Issue #177 · Pseudonium/Obsidian_to_Anki · GitHub

2 Likes

It is a weird bug, as it works sometimes but doesn’t most of the times

Hey! Is there any regex that supports empty line? EG:

This is the question? #flashcard
This line is included

This line is not included when using any regex;

I want to include these lines aswell

And its the similar story with Q/A regex. So i searched the github issues, and found this regex that includes empty lines and stops when 2 empty lines are found:
^Q: ((?:[^\n][\n]?)+)\n+A: ([\s\S]*?(?=\n{3,}))
But the problem with that is when the Question/answer is modified, it creates a new card instead of updating the new one.

Does anyone have a regex that works with empty lines?

Is using hidden paragraph supported? The below format works, but will it be supported in the future, I don’t want to redo everything after a minor update breaks everything.

<p hidden>
START
Basic
question
Back: </p>

Answer

<p hidden>
END</p>

Thus only “Answer” is visible in preview mode.

1 Like

I try to setup Obsidian to Anki , I am on Linux, It says that it connect without a problem, but when I want to add dummy card

# Overall point

## Subheading 1

## Subheading 2

START
Basic
This is a test.
Back: Test successful!
Tags: Testing
END

the extension says that it connects and is adding all media but nothing appears in the anki deck that I choose in the settings. This might be a bug or I am doing something wrong? I am on anki 2.1.42

I like the hidden approach. I created a css snippet which will probably also work in the future CSS for Obsidian to Anki

Is there a way to tell this plugin not update certain fields to anki? Or make it updated from anki so that when I sync agian it doesn’t delete all the things I’ve added to that note in anki?
RIght know the only way I can think of, is to delete the note in obsidian after the first sync

have you solved the problem? I’m having the same one with Windows

UPDATE: The note type in my version of Anki (2.1.43 (0fbae6bc)⁩ is not <, but is <<Basic (optional reverse order)>>. If I use that value, the process works.

START
Basic (optional reversed card)
Front message
Back:
Back message
END


I’m having the same problem on Mac

1 Like