~brhiggins/anki-display-peers

Anki addon - display a note's tag peers in card templates
Add configurable tag filter regex
Add feature to save resolved tag sets to field
Add README.md and LICENSE

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~brhiggins/anki-display-peers
read/write
git@git.sr.ht:~brhiggins/anki-display-peers

You can also use your local clone with git send-email.

#Anki display peers

A simple addon which, when invoked, will add to a configured field a list of all peer cards that have the same tag, so that they can be displayed in card templates.

This can help your brain connect various related topics when reviewing.

Screenshot

#Instructions

  • Create fields on your note type and configure in the config JSON
    • 'peers_field' will be filled with the sort field of peer notes
    • 'tag_sets_field' will be filled with the tag sets used to determine peers
    • Both fields are optional
  • Ensure your tag hierarchy reflects the desired results (see below)
  • Add the field to your card templates (would probably benefit from some HTML styling)
  • Select notes in the browser and click 'Notes > Add peers'

#Selection

A note is considered a peer if it shares the same tag at the same level in the hierarchy. Tags lower or higher in the hierarchy are not considered peers. If a note has multiple tags in the same hierarchy, it will be considered to be only in the highest.

#Output

The peers output is a div containing a list of the sort fields of peer notes. The tags sets output is a list of resolved tag sets.

You can just put these fields on your cards as-is, but you would likely benefit from applying some HTML styling. That is beyond the scope of this addon.

#Peer text filtering

You can configure a regular expression in the config file which will be used to filter the text from the peers. If the regular expression returns nothing, the peer is ignored: otherwise, the script expects there to be a single capture group containing the desired text.

The 'strip' option in the config file controls whether to strip HTML from the peer fields. True by default; if set to false, HTML will not be stripped.

Regex matching occurs before HTML stripping, if enabled. If you have HTML in your peer fields, you will need to account for this if you edit the regular expression.

#Tag filtering

You can specify a regular expression in the config file to filter tags by: tags that don't match will be ignored.