Closed ExtremeCoolDude closed 10 months ago
Sometimes also throws the same error, when there is nothing to clean:
Hi @ExtremeCoolDude,
Regarding the first issue, a solution would be to implement an automatic way to clean up HTML from cards. You could also write a Python script yourself that cleans up your cards.
At this moment, I don't have the capacity to work on that but I welcome contributions.
Regarding the second issue, could you open a bug ticket and provide reproduction steps? I can't reproduce your issue, so I don't know how to fix it.
Thank you for reporting.
Steps to reproduce:
on back : press enter twice to have two br tags, create a <div> a </div>
in the html editor
This happens on my machine :
Please let me know if this is not reproducible. That would mean the issue is with my Anki version. (Version 2.1.61 (0c1eaf4c) Python 3.9.15 Qt 6.4.2 PyQt 6.4.0)
WAI. You are selecting a text block with HTML tags in them, which the current tool is not sophisticated enough to handle. You need to clean up HTML tags before applying a highlight.
WAI ? I'm just a tech hobbyist, with no formal education in tech. Maybe make the message clear to something like " remove all html code from editor" instead of "remove partial tags"
I've taken a deeper look into this and made the error message clearer.
I've been mistaken in my previous explanation. The problem is that you are selecting a partial non-Text node. The background is that I'm using Range.surroundContents to implement essential functionality and it doesn't work with partial nodes (https://developer.mozilla.org/en-US/docs/Web/API/Range/surroundContents). In other words, you just need to make sure you don't select half of div or span or something like that. It should be much better than cleaning entire HTML tags.
I've made the error message clearer in the latest CL to address the issue. I don't intend to make the code work with partial selection as I don't have the time to do that. :(
Thank you for reporting and your patience. Let me know though if you have further ideas on how to make this better.
I'm using a premade deck and whenever I try to highlight, I get this error :
The selected code contains partial HTML tags. Clean up your code snippet in the HTML editor (https://docs.ankiweb.net/editing.html#editing-features) before highlighting.
It's not very practical to edit every html card in a premade deck with 1000 cards. I am wondering if there is a solution. Thanks!