<br> at the end of all anki-editable tags

When doing some hacks with the anki-editable tag and inserting custom CSS with the CSS injector addon, I noticed that at the end of all of these tags, there is a <br> inserted to the end of it (confirmed using the AnkiWebView Inspector addon

I’m guessing this behavior is not a bug, and this doesn’t seem to cause any issues because the text content itself doesn’t contain the <br> (i.e. the text in the templates don’t have the <br> applied).

More so out of curiosity, I was wondering if anyone who’s familiar with Anki’s code can explain why this is is here in the first place? My initial hypothesis was that the <br> was required to give the element vertical space, but removing the <br> element seems to have no effect visually. I did try to do a preliminary search around in the source code, but I couldn’t seem to find where this was added either.

As you’ve correctly inferred, these linebreaks are used to give inputs vertical space. This is only required initially, e.g. when a new field is mounted or an input is expanded from a collapsed state - that’s why it doesn’t have an effect when you delete it afterwards.

Trailing linebreaks are filtered out when the field content is stored to the database.


That makes sense, thanks for the fast reply!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.