Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloze detection broken for multi-line cloze inside html tag #5421

Closed
leezu opened this issue Aug 31, 2019 · 9 comments
Closed

Cloze detection broken for multi-line cloze inside html tag #5421

leezu opened this issue Aug 31, 2019 · 9 comments
Labels

Comments

@leezu
Copy link

leezu commented Aug 31, 2019

Reproduction Steps
  1. Create a cloze containing the following html on Anki Desktop:
<p>Cloze in html tag with {{c1::multi-line
string}}</p>

Note the difference to

<p>Cloze in html tag with {{c1::string}}</p>

or

Cloze with {{c1::multi-line
string}}
  1. Sync to AnkiDroid
  2. Review notes
Expected Result

All 3 notes should show up as Cloze with [...].

Actual Result

The <p>Cloze in html tag with {{c1::multi-line string}}</p> note does not show up correctly.
Instead Edit this note and add some cloze deletions. (help) is displayed.

After clicking "Edit note" on AnkiDroid without making any changes to the note, the note is displayed correctly.
Checking on Anki Desktop, it turns out that clicking Edit note on AnkiDroid changed the html of the note to:

<p>Cloze in html tag with {{c1::multi-line<br>string}}</p>
Debug info

AnkiDroid Version = 2.9beta7

Android Version = 10

ACRA UUID = b8969252-15d5-4075-92a1-81871187ab4b

Research

Enter an [ x ] character to confirm the points below:

[X] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[X] I have checked the manual and the FAQ and could not find a solution to my issue

[X] I have searched for similar existing issues here and on the user forum

@mikehardy
Copy link
Member

interesting! great report
The perturbation of the note (saving it back as something different without editing) is tracked elsewhere #3304 which can be summed as "if you edit but make no changes, no changes should be made" (a reasonable stance)

This issue should be focused on "the close identification regexp seems to be different on AnkiDroid than Anki Desktop"

The python code they're using in Anki Desktop should be examined and whatever part makes it work multiline should be brought in to here

This should be a great first issue since Anki Desktop (code available here https://github.com/dae/anki/) is so easy to inspect

@mikehardy
Copy link
Member

thanks by the way for confirming this in the beta so we know it is a current issue - that would have been one of my first requests :-)

@adamwolf
Copy link
Contributor

adamwolf commented Aug 31, 2019 via email

@leezu
Copy link
Author

leezu commented Aug 31, 2019

@mikehardy Both the AnkiDroid and Anki regexes seem the same and explicitly enable matching new-lines via the (?s) inline flag.

https://github.com/dae/anki/blob/8a2a4d827f1afcab746585ede2ac08833d679757/anki/template/template.py#L7

public static final String clozeReg = "(?si)\\{\\{(c)%s::(.*?)(::(.*?))?\\}\\}";

The buggy behaviour only occurs when wrapping the cloze in <p></p> tags.

@adamwolf I don't have an Android dev setup ready to verify any changes, so it would be appreciated if you could go ahead ;) Thanks for taking care of it!

@adamwolf
Copy link
Contributor

adamwolf commented Aug 31, 2019 via email

@adamwolf
Copy link
Contributor

adamwolf commented Sep 3, 2019

(I'm a few minutes into this, adding some tests, and... we have at least a few bugs here, folks!)

Thanks @leezu. Good catch!

@mikehardy
Copy link
Member

Nothing like good user reports (yes, thank you @leezu ) + automated testing + a developer ready to go (thank you @adamwolf ) :-)

@adamwolf
Copy link
Contributor

Can someone confirm this is fixed in the latest betas?

@leezu
Copy link
Author

leezu commented Sep 29, 2019

It's fixed, thank you!

@leezu leezu closed this as completed Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants