Skip to content

Question answer style

Rubaiyat Khondaker edited this page Dec 14, 2020 · 4 revisions

Usage

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

Example usage:

  1. Create a file called test.md
  2. Paste the following contents into the file:
Q: How do you use this style?
A: Just like this.

Q: Can the question
run over multiple lines?
A: Yes, and
So can the answer

Q: Does the answer need to be immediately after the question?


A: No, and preceding whitespace will be ignored.

Q: How is this possible?
A: The 'magic' of regular expressions!

Obsidian Plugin users

  1. In the plugin settings, paste the Regex line into the 'Custom Regexps' field associated with 'Basic'
  2. Ensure that the 'Regex' option is checked
  3. Click the Anki icon on the ribbon to run the plugin

Python Script users

  1. Run the script, and check 'Config' to open up the config file:
    GUI
  2. Navigate to the "Custom Regexps" section
  3. Change the line
Basic =

to

Basic = ^Q: ((?:.+\n)*)\n*A: (.+(?:\n(?:^.{1,3}$|^.{4}(?<!<!--).*))*)
  1. Save the config file
  2. Run the script on the file, with 'Regex' checked:
    GUI

All users

  1. You should see these cards in Anki:
    question_1
    question_2
    question_3
    question_4
Clone this wiki locally