Skip to content

Instantly share code, notes, and snippets.

@TakuanPickle
Last active October 14, 2023 21:53
Show Gist options
  • Save TakuanPickle/e3ef3e2743bd813ade41733ec11c7ada to your computer and use it in GitHub Desktop.
Save TakuanPickle/e3ef3e2743bd813ade41733ec11c7ada to your computer and use it in GitHub Desktop.
A sample workflow for creating links to vocabulary notes in a transcription with prompts for fields.

Vocab Note Workflow

I created a quick way to make flashcards and vocab notes for my Japanese learning. I had been struggling with how slow making Anki cards can be and found myself more likely to actually review cards if they were all in Obisidian, which I always have open, rather than opening Anki.

Required Plugins

  1. Templater
  2. QuickAdd
  3. Spaced Repetition
  4. Dataview
  5. Supercharged Links (Optional)

Template Setup

I am by no means a Templater wizard but managed to trial and error my way into getting the Javascript stuff working. Everything within the <%* %> sections is pretty much just saying "if X field doesn't exist, prompt for the value of X field then put a Dataview field in front of it." It will output field:: value inputed in prompt At any point you can rename the title of each prompt by changing the value in quotation marks of tp.system.prompt(" ") in the template. You can also add new fields and prompts by copying an existing one:

<%* 
  let example = tp.frontmatter.example
    if (example = "undefined") {
    example = await tp.system.prompt("Example");
  }
  tR += "example::"
%> <%* tR += example %>

and replacing all the instances of the word that occurs after let with a new value. In the above example you would replace example with a new field, e.g. potato:

<%* 
  let potato = tp.frontmatter.potato
    if (potato = "undefined") {
    potato = await tp.system.prompt("Potato");
  }
  tR += "potato::"
%> <%* tR += potato %>

the <%* tR += %> allows you to insert the field anywhere. You'll notice that in the Flashcard section of the not that it utilises this to duplicate the fields in varying configurations for flashcards formatted for the Spaced Repetition plugin.

The reading field will probably not be relevant unless you're learning a language that uses a non latin script. Feel free to delete that section.

Steps

  1. Download the attached template (vocabulary template.md) below and add it to the template folder of your vault.
  2. Rename the template whatever you like, but remember its location and name.
  3. In the QuickAdd settings click Manage Macros
  4. In the Macro Name box at the bottom, input a name for your macro e.g. Vocab. Then hit Add Macro
  5. Hit Configure on your new macro then add a Template choice.
  6. In the Template Path field, point it to the vocabulary template.md file in your vault (or whatever you renamed it to).
  7. Turn on Append Link. All other settings adjust to your taste, I have my notes created in a new folder and open in a new pane so I can check it all inputed okay.
  8. Return to the main QuickAdd settings window and choose Template from the dropdown menu in the bottom right corner, add a name for your choice and hit Add Choice. This name will end up appearing in your command palette.
  9. Click the lightnining bolt button to add a command to the command palette. Click the cog and select your vocab macro from the dropdown menu.
  10. Go to the Hotkeys section of the main Obsidian settings and search for whatever you called your QuickAdd choice. (or just search for QuickAdd). Bind your QuickAdd choice to a hotkey, I use alt + V.
  11. Exit settings.

Optional Styling

Using Supercharged Links (which now has a very easy to use way to style links without having to use css) you can colour your links based on fields or tags. I give my vocab a specific tag, and then style it so the link shows green in my transcription note. I have a similar template for grammar which shows orange in my transcript note.

Spaced Repetition

I think this is set up fine out of the box. You just need to make sure your version of the template has the same Flashcard tags as specified in the settings for Spaced Repetition so it automatically makes the card okay.

Card Format

I have two cards. The first:

<%* tR += title %>
?
<%* tR += reading %>
<%* tR += definition %>
<%* tR += example %>

This has the word on the front and the reading (for Japanese Kanji), definition, and an example on the back.

The second:

<%* tR += definition %>
?
<%* tR += reading %>
<%* tR += title %>
<%* tR += example %>

Has the definition on the front, then reading, title, and example on the back.

Using the template

The result of all this is you should be able to highlight a word in a source text in Obsidian, hit your hotkey (e.g. alt + V) and a new note will be created in a location that you specified and prompt you for things you want to appear in your flashcards. You can then choose Spaced Repetition: Review flashcards from all notes/in this note to see the cards you created!

The only slight annoyance in this workflow is that it requires that you copy the sentence you want to use as an example (from your transcript) before hitting your hotkey and creting a new template otherwise you're stuck typing it out into the field.

This is my first walk-through so please let me know if there's anything missing or coudl do with some more clarification. Enjoy!

<%* let title = tp.file.title if (title.startsWith("Untitled")) { title = await tp.system.prompt("Title"); await tp.file.rename(title); } tR += "---" %> title: <%* tR += title %> created: '[[<% tp.date.now ( ) %>]]' tags:

  • flashcard aliases:

[[<%* tR += title %>]]

<%* let reading = tp.frontmatter.reading if (reading = "undefined") { reading = await tp.system.prompt("Reading"); } tR += "reading::" %> <%* tR += reading %>


Definition

<%* let definition = tp.frontmatter.definition if (definition = "undefined") { definition = await tp.system.prompt("Definition"); } tR += "definition::" %> <%* tR += definition %>


Examples

<%* let example = tp.frontmatter.example if (example = "undefined") { example = await tp.system.prompt("Example"); } tR += "example::" %> <%* tR += example %>


Flashcard

<%* tR += title %> ? <%* tR += reading %> <%* tR += definition %> <%* tR += example %>

<%* tR += definition %> ? <%* tR += reading %> <%* tR += title %> <%* tR += example %>


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment