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

Make the revealed text blue and change font weight to bold #7

Closed
An-png opened this issue May 23, 2020 · 4 comments
Closed

Make the revealed text blue and change font weight to bold #7

An-png opened this issue May 23, 2020 · 4 comments

Comments

@An-png
Copy link

An-png commented May 23, 2020

One simple change that can be done to replicate anki's built in clozes is to add font-weight:bold; to current cloze.

Another problem is when the cloze is revealed, it isn't blue. I couldn't find how to change this.
For example,

result = result.fontcolor("blue");
return result

in the expContent.replace function thinggy doesn't work, it makes every cloze blue. I assume this is because the sole purpose of that function is to strip the ((c1::)) off the text.

Is there a way to make the current cloze reveal blue?

@matthayes
Copy link
Owner

Thanks for the tip regarding the font-weight. I'll make that change.

Yes this is possible with a slight modification. I was actually recently working on improving that. I'll be merging it into master soon, but here's how you do it.

Replace this part:

     if (isBack) {
       // For the back card we need to strip out the surrounding characters used to mark those
       // we are keeping.
       result = strip_keep_chars(content);
     }

With this:

    if (isBack) {
      // For the back card we need to strip out the surrounding characters used to mark those
      // we are keeping.  We also wrap in a span in case we want to add styling.
      if (clozeNum == currentClozeNum) {
        result = wrap_span(strip_keep_chars(content), "current-cloze");
      }
      else {
        result = strip_keep_chars(content);
      }
    }

With this change, the text for the current cloze that is revealed on the back side will be colored the same way as the front side.

You can also add a CSS rule to color the back side clozed text differently. For example, this would make it green on the back side:

#back .current-cloze { color: green; }

@An-png
Copy link
Author

An-png commented May 27, 2020

Thank you!

It seems like the #back ID doesn't work unless you implement the new code

@matthayes
Copy link
Owner

Yea you need the replacement code I showed above. What the wrap_span function does is wrap a <span class="current-cloze">...</span> around the content so that you can apply a CSS rule like the example I gave. For now you can just update your template with the replacement. I'll probably be merging in this code soon and releasing it. Do you use the shared deck or did you set up the card templates using my instructions?

@matthayes
Copy link
Owner

I've merged the code into the master branch and released an updated version of the shared deck.

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

No branches or pull requests

2 participants