Skip to content

Header paragraph style

Pseudonium edited this page Apr 27, 2024 · 5 revisions

Usage

Regex line: ^#+(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+)

  1. Create a file called test.md.
  2. Paste the following contents into the file:
# Style  
This style is suitable for having the header as the front, and the answer as the back
# Overall heading
## Subheading 1
You're allowed to nest headers within each other
## Subheading 2
It'll take the deepest level for the question
## Subheading 3
   
   
   
It'll even
Span over
Multiple lines, and ignore preceding whitespace

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 = ^#+(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+)
  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:
    header_1
    header_2
    header_3
    header_4

Subheader paragraph style

If you'd like the effect of the header paragraph style, but only want it to add cards below a certain subheading level (e.g. 3 # or more), use the following regex:

  • 2 or more - ^#{2,}(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+)
  • 3 or more - ^#{3,}(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+)
  • n or more - ^#{n,}(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+), where you replace {n,} with the value of the number n. E.g. if n was 4, it would read ^#{4,}(.+)\n*((?:\n(?:^[^\n#].{0,2}$|^[^\n#].{3}(?<!<!--).*))+)
Clone this wiki locally