frostschutz / Anki-LilyPond

LilyPond integration addon for Anki
5 stars 2 forks source link

Uses same picture for all flashcards when field is something-lilypond #2

Closed Senth closed 11 years ago

Senth commented 11 years ago

Hi, found a bug when using a whole field as lilypond

Using Anki 2.0-r6

How to reproduce

  1. Have a field set to something-lilypond
  2. Set it as "a e c"
  3. Click on cards to compile the picture
  4. Change the contents in something-lilypond to "e"
  5. Click on cards.

    What should happen

The card displays "e".

What actually happens

It still displays "a e c" and displays "a e c" for every flashcard created.

frostschutz commented 11 years ago

For whatever reason, Anki calls the mungefields hook twice per card; in the first run the lilypond plugin replaces a e c with <img src=...>, in the second run it replaces <img src=...> with None/empty string (because it filters HTML codes put in by Anki such as <p> or <br>).

And for some reason the empty string ends up getting rendered as the previously generated image the first time, and afterwards lilypond just reuses the previously cached image (which is always the image for None).

It doesn't happen for [lilypond] tags because the second time around those are already replaced with <img src=...> which does not match the regexp that looks for [lilypond] anymore. So it's left alone in the 2nd mungeFields call.

Thanks for your report - I'll fix it as soon as I find out how.

frostschutz commented 11 years ago

Hopefully fixed. Please update the plugin and let me know if it works for you.

Senth commented 11 years ago

Works, thanks :)

Although the ability to add/remove templates disappeared from the lilypond menu, was this intentional? Hmm, if I changed the name of the plugin from LilyPond_Integration_Sheet_Music_Typesetter to just lilypond I could see the template menu again.

frostschutz commented 11 years ago

No, that's not intentional. It appears the addon site changed the filename for some reason. Delete that and try redownloading the addon again please?

Senth commented 11 years ago

Works now :)

frostschutz commented 11 years ago

Great. I'll have to remember to upload it as .zip instead of .py in the future.

Closing...