zjosua / anki-mc

Multiple choice questions for Anki.
https://ankiweb.net/shared/info/1566095810
GNU Affero General Public License v3.0
49 stars 16 forks source link

Issue with formatting of the cards after copy and pasting contents - Multiple Choice for Anki (1566095810) #104

Closed ursibot closed 1 year ago

ursibot commented 1 year ago

Hi! 

Hi! I‘m completely new to GitHub (as well as Anki and coding in general), so please excuse my lack of knowledge and/or understanding. I was informed that it would be best to post to this (unclosed) issue regarding the troubles with the addon I have due to some formatting error I have caused by copy-pasting the mc questions and answers from different pdfs/browsers (see: closed issue #50 "Multiple Choice für Anki (1566095810) - Kartenrückseite/Antwort: Correct answers: x %").

Also, I was advised to add additional information such as the CSS, which I have hopefully managed to attach to this post. To summarize my original post: When I try to study my cards, they appear with really garbled up formatting, and when I try to click the checkbox and let Anki show the answer, the "x % correct" message appears. Since starting using Anki/the add-on (which I have for just a few days), I did make some alterations to the font size, the colors and one label of the "sources" field (I named it "Erklärung/Ergänzung"). I suspected that the issue was maybe due to my alterations, so since then I have tried to copy the original CSS and successfully inserted it (which I infer from the colors and font changing back to the previous style; for the cards that work fine). For the other ones, sadly, the formatting issue still remains.

Furthermore, I think it might be important to add that when I did the latter, I had to delete (from the back of the card) or add (to the front of the card) the "Sources" field. That is to say, I deleted this part of the html code:

{{#Sources}}

Sources:
{{Sources}}

{{/Sources}}

To be honest, I‘m not sure if this issue is really due to the copy-paste procedure I have used, but as I’ve mentioned, other cards I have created "manually" seem to work just fine. 

As the closed issue proposed, the only option would be to now re-write all the cards or to copy and paste the questions/solutions (with the "Paste without shift key strips formatting" setting turned on) onto completely new cards…

I would really appreciate it if someone could maybe help me out.

Screenshots for the working cards: image image

Screenshots documenting my issue: image image

Information about my set-up: Desktop: Windows 10, Version ⁨2.1.56 (07fd88dd)⁩, Python 3.9.15 Qt 6.4.0 PyQt 6.4.0


    Anki 2.1.56 (07fd88dd) Python 3.9.15 Qt 6.4.0 PyQt 6.4.0
    Platform: Windows-10-10.0.19045
    Flags: frz=True ao=True sv=3
    Add-ons, last update check: 2023-02-05 22:26:13

    ===Add-ons (active)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    Add Table ['1237621971', 2022-12-21T12:20, 'None', mod]
    Enhanced Cloze for Anki 21 ['1990296174', 2022-11-15T13:16, 'None', '']
    Image Occlusion Enhanced for Anki 21 alpha ['1374772155', 2022-04-09T09:15, 'None', '']
    ImageResizer ['1214357311', 2022-07-15T15:05, 'None', '']
    Multiple Choice for Anki ['1566095810', 2022-12-16T21:04, 'None', '']
    multiple choice with 12 options ['1573325751', 2022-03-05T02:53, 'None', '']

    ===IDs of active AnkiWeb add-ons===
    1214357311 1237621971 1374772155 1566095810 1573325751 1990296174

    ===Add-ons (inactive)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])

P.S. The attached file isn't in the default ".apkg" format as GitHub doesn't support it (?) Like I've said, comlplete noob here -.-

garbledformatting.txt

3ter commented 1 year ago

please excuse my lack of knowledge and/or understanding

No worries, we're all learning constantly - and I think that's a good thing 😄.

I couldn't import the textfile (it gave me only two fields filled). Just ZIP the file before dragging it onto your message: Selected Notes.zip

Why did you apply the bug label to this issue? Up until now I would consider it a question.

ursibot commented 1 year ago

Thank you for your patience and understanding! :3 I think this should work now:

garbledformatting.zip

I didn't really think anything of it (sorry for my ignorance). I kind of just skipped over it, thinking "Something isn't working" would be appropriate. Of course I can change the label, if I knew how to actually do that... I suppose I should be able to do that somewhere, right?

3ter commented 1 year ago

You can keep the label.

The HTML in one of your question fields unfortunately gets garbled by our JavaScript on the note type. image Removing it restores it to working condition. image

So as an easy workaround I recommend using the card browser in Anki, select all of the offending notes and use "Find and Replace" to strip the HTML tags from the respective field (I guess it's only the field Q1):

image The regex that was used is <([^>]+)> (regex in action with a test string).

If it's not only in Q1 but some of the others too, repeat the process accordingly. Of course only do this if you don't care about the HTML being stripped (but it looks that way to me).

3ter commented 1 year ago

Addendum: I said you can keep the label because it isn't intended that table HTML kills the purpose of the addon.

In your case though, said HTML only came from pasting it with formatting. You should consider turning it off by default: image Paste without shift key strips formatting. This would invert the current setting. So by default you only get the text (which you want most of the time) and if you really need the HTML formatting, you can press shift + ctrl + V and it gets pasted into Anki as before.

If that's help enough for the moment I'm going to close the issue as I found that for the bug in question there's already an issue open (#97).

ursibot commented 1 year ago

Thank you so, so much! Everything now works perfectly! I really thought I'd have to redo all the cards I had already written. You saved me a lot of time!