Skip to content

Cloze Paragraph style

Pseudonium edited this page Apr 27, 2024 · 7 revisions

Usage

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

  1. Create a file called test.md
  2. Paste the following contents into the file:
The idea of {cloze paragraph style} is to be able to recognise any paragraphs that contain {cloze deletions}.

The script should ignore paragraphs that have math formatting like $\frac{3}{4}$ but no actual cloze deletions.

With {2:CurlyCloze} enabled, you can also use the {c1|easier cloze formatting},
but of course {{c3::Anki}}'s formatting is always an option.

Obsidian Plugin Users

  1. In the plugin settings, paste the Regex line into the 'Custom Regexps' field associated with 'Cloze'
  2. Ensure that the 'Regex' and 'CurlyCloze' options are checked
  3. Click the Anki icon on the ribbon to run the plugin

Python Script

  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
Cloze =  

to
Cloze = (.*{.*\n?)

  1. Also set CurlyCloze = True to have the above example work properly.
  2. Save the config file
  3. Run the script on the file, with 'Regex' checked:
    GUI

All users

  1. You should see these cards in Anki:
    Cloze 1
    Cloze 2

Highlight-cloze style (Obsidian Plugin only)

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

You can also use markdown highlights instead of curly braces in order to indicate cloze deletions - just use the above style, and also enable 'CurlyCloze - Highlights to Clozes'!