glutanimate / syntax-highlighting

A fork of Tiago Barroso's Syntax Highlighting add-on with support for Anki 2.1
https://ankiweb.net/shared/info/1463041493
Other
108 stars 27 forks source link

Multiline cloze deletions not detected by Anki #7

Open salty5436 opened 5 years ago

salty5436 commented 5 years ago

Prerequisite checklist

What is the problem/feature you would like to see fixed/implemented?

Cloze deletions do not work when selecting multiple lines of code - Anki reports that I have not made any cloze deletions.

How can we reproduce the problem?

  1. In a cloze note type paste: test test test
  2. Select all and use the lightning bolt to convert to code
  3. Select two or three lines and add a cloze deletion
  4. Try to add the note

Expected behavior: [What you expected to happen]

Note adds successfully with the desired cloze in place.

Actual behavior: [What actually happened]

Anki warns that no cloze was made.

Reproducible?: [Can you reliably reproduce the issue by following the steps above?]

Yes.

Possible Cause

The problem may be related to the line breaks between the cloze tags. The above steps lead to this html, taken from the html editor:

<div><center style="text-align: -webkit-auto;">{{c1::<table><tbody><tr><td><div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>test
test
test
</pre></div>
</td></tr></tbody></table>}}</center><br /></div>

I used the html editor to remove the line breaks after each 'test' and placed a <br /> tag between them. I also removed the line break after the second to last </div>:

<div><center style="text-align: -webkit-auto;">{{c1::<table><tbody><tr><td><div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>test<br />test<br />test</pre></div></td></tr></tbody></table>}}</center><br /></div>

The cloze then successfully added.

Version information

Anki

[Please head to HelpAbout Anki and Paste the version string here, e.g.:]

Version 2.0.51 Qt 4.8.4 PyQt 4.10

System

ijgnd commented 5 years ago

This is not about the add-on syntax highlighting. This is a bug of Anki 2.0 which can't be reproduced in 2.1.13. I think this was fixed in 2018-06 (related discussion). The solution should be updating to 2.1.