hgiesel / closet

The Web Framework for Flashcards
https://closetengine.com
GNU General Public License v3.0
65 stars 6 forks source link

MathJax bug #34

Closed sandersantema closed 4 years ago

sandersantema commented 4 years ago

Describe the bug Other than the generated mathjax formula itself a piece of light gray text is shown. As can be seen here: image

Code used for note:

\(x^2\) [[c1::hallo]]

However after one review this grey text disappears: image

The gray text only reappears when stopping the reviewer i.e. exiting to the browse window.

More weird stuff happens when I include a mathjax formula in the cloze: image

Code used for note:

\(x^2\) [[c1::\(x^1\) hallo]]
[[c2::\(test\)]]
[[c3::\[test\] ]]

Debug information

Method 1

initCloset() fails, this doesn't make a whole load of sense though given that clozes without mathjax are working just fine. image

Method 2

(The file has an added .zip extension) test.apkg.zip

hgiesel commented 4 years ago

The "method 1" description was outdated. It is basically to ensure that you Closet is actually installed on that card type, which is definitely the case here.

I'm working on the MathJax support.

hgiesel commented 4 years ago

I just uploaded a new version v0.2.1, which supports MathJax to my best efforts. You need to reinsert Closet using Asset Manager again however.

hgiesel commented 4 years ago

I had to take back most of the MathJax support I added, because how flimsy MathJax behaves on mobile. Calling MathJax.Hub.Queue regularly crashed the pipeline, leaving the card in an unfinished (unrevealed) condition.

I will postpone the next attempt till after Anki updates to MathJax 3 which supports a more stable Promise API for synchronisation rather than building their own mechanisms. I have opened a PR for this.

sandersantema commented 4 years ago

Looks really good! If I desperately need mathjax anyways I'll probably just try the previous version out and otherwise I'll wait for more updates :)

hgiesel commented 4 years ago

I just updated to v0.2.3 which even works with MathJax of the current Anki version. There were actually some longstanding issues, which I simply never noticed, but are now fixed.

sandersantema commented 4 years ago

Fantastic! Thank you for the quick fixes.

sandersantema commented 4 years ago

Closet now seems to work with mathjax except for embedding mathjax into a closet cloze which renders the mathjax but doesn't render the cloze itself.

\(x^2\) [[c1::\(x^1\) hallo]] will show as: image

I'm using the latest anki beta, 2.1.36beta2. Is this the expected behaviour?

hgiesel commented 4 years ago

I cannot recreate this after the update.

Are you sure you actually updated it. You also need to reinsert Closet using Asset Manager, as some of the code on the template itself changed.

If then it still misbehaves, you could upload the offending card in a deck again.

sandersantema commented 4 years ago

Are you sure you actually updated it. You also need to reinsert Closet using Asset Manager, as some of the code on the template itself changed.

I have indeed reinserted Closet, which solved all of the other ways in which mathjax + closet wasn't working except for having mathjax formulas in a closet cloze.

I have a suspicion it might be something about my local setup although I can reproduce this bug using a fresh anki profile and with the closet script inserted into the default basic cards.

Maybe it has something to do with one of my installed plugins? image

hgiesel commented 4 years ago

You could try and start Anki while holding Shift, which will disable all add-ons temporarily. The template should still work however.

sandersantema commented 4 years ago

You could try and start Anki while holding Shift, which will disable all add-ons temporarily. The template should still work however.

Unfortunately still doesn't work, I'll try some other things and follow up if anything changes.

sandersantema commented 4 years ago

It seems like writing the template to a note type doesn't work anymore. Although it did seem to work a little while ago nothing gets written to the note now that I try.

UPDATE: Closet not being inserted was a mistake on my side, I didn't have enabled toggled on. However after correctly inserting the closet setup it's still not working with mathjax inside the clozes.

hgiesel commented 4 years ago

@sandersantema I have good news, I figured out the issue. I will push out a fix possibly tomorrow. For now, you can fix the issue (and this may sound crazy...) by making the whole MathJax expression (including \( to \)) italic or bold.

sandersantema commented 4 years ago

@sandersantema I have good news, I figured out the issue. I will push out a fix possibly tomorrow. For now, you can fix the issue (and this may sound crazy...) by making the whole MathJax expression (including \( to \)) italic or bold.

Very nice! Making the whole expression bold or italic does work, quite an amusing fix :) I look forward to start using closet a lot more, this issue was a blocker but now that it's resolved I can use it.

sandersantema commented 4 years ago

I'll close the issue for now, given that making the whole mathjax expression bold or italic works and it should work without if your fixes are merged.

hgiesel commented 4 years ago

I've uploaded a new version (v0.2.4) to AnkiWeb, which means you probably don't need to use the "italic"-trick anymore :)

Fixing commit: 80eb9c9333c639beda2bf04d37