Multiline cloze deletions not detected by Anki
Prerequisite checklist
- [Yes] In case of a bug: Have you tried restarting Anki?
- [Yes] Are you running the latest version of the add-on. Have you redownloaded the add-on from AnkiWeb to make sure?
- [Yes] Did you check the add-on documentation (e.g. AnkiWeb description, Wiki if it exists) for known issues?
- [Yes] Did you perform a cursory search through the existing issue reports?
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?
- In a cloze note type paste: test test test
- Select all and use the lightning bolt to convert to code
- Select two or three lines and add a cloze deletion
- 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 Help → About Anki and Paste the version string here, e.g.:]
Version 2.0.51 Qt 4.8.4 PyQt 4.10
System
- Operating system: Windows
- Version: 7
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.