Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept: Move flash card context into distinct field #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

putzwasser
Copy link
Contributor

This is a proof of concept for #146 It moves the cards context into an additional/distinct flash card anki field.

This allows easy and independent styling of flashcards.

To test this, you must:

  1. Fork/apply this PR
  2. Sync Anki between your devices
  3. Edit your anki cards and add an extra field Context to it. (this needs a force sync, hence step 2)
  4. Edit your flash card templates e.g. for the Obsidian-cloze-source
<div id="context" style="padding:1em;background-color:#444"><small><i>{{Context}}</i></small></div>
{{cloze:Text}}

<script>
    var tagEl = document.querySelector('.tags');
    var tags = tagEl.innerHTML.split(' ');
    var html = '';
    tags.forEach(function(tag) {
	if (tag) {
	    var newTag = '<span class="tag">' + tag + '</span>';
           html += newTag;
    	    tagEl.innerHTML = html;
	}
    });
    
</script>
<script>
	// Hide the Context field if it's empty
	const context = '{{Context}}'
	var contextEl = document.querySelector('#context');
	if (!context) {
		contextEl.style.display="none";
	}
</script>
  1. Create a new flash card note
Flas==card== Test

New flash==card==

# Context Headline 1
## CTC HDL 2
fl==ash==

test ==cloze==
  • The first two flash cards don't have context. It won't be shown in anki, because of the JS, which hides an empty context
  • The last two flash cards have context. It will be shown a bit separated from the card itself. In my opinion this makes it easier to tell, which part of the question is the context and which is the actual question asked.
  • It makes the contextAware setting more or less obsolete, as users could just delete the <div id="context" style="padding:1em;background-color:#444"><small><i>{{Context}}</i></small></div> line from their templates.

This PR is a proof of concept because:

  • I have no idea if there's something I'm missing
  • Someone with more experience would have to change the anki card models to reflect these changes and add the Context field to it
  • I don't know if existing users would have to add the Context field manually, as I did or if it is possible to add it "silently"
    • (I don't know if silently works because of the needed hard sync in step 2)

Please feel free to build upon this PR and/or use the code and create your own PR to implement this feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant