Browse Search returns the backing HTML

Is there any way to prevent Anki from finding notes that have backing HTML that matches the search query?

For example, I have a ton of notes that are styled with CSS (stuff like font-weight for example). As a result if I search for the word “font”, every card ends up matching.

Most of the time the HTML is there just for styling purposes, is there a way to restrict my search to “textContent” only? I almost wish that Anki would create a hidden auto-generated column that would contain just the raw text.

For that reason and others, it’s usually a good idea to refrain from styling notes and do it on the card template instead.
Having said that, you can filter out HTML using regex. The following might be good enough, depending on the complexity of your HTML and CSS:

"re:(^|>)[^<]*font"
2 Likes

(Anki may expose a way to search without HTML in the future, but the recommendation to place as much formatting as possible in the template is a good one)

2 Likes

Yeah, the issue is that I was using glutimate’s Syntax Highlighting for code snippets which inserts HTML to properly style/highlight whatever code you place in the card (C++, TSQL, Python, etc).

Maybe I’ll create dedicated styling templates for each language or load a syntax highlighter library if that’s even possible.