Revert style stripping in HTML editor

Please let me know if there’s an existing workaround or configuration for this. I’m no expert.

Updated to 2.1.52 from 2.1.49 (I think) today and found that the HTML editor now automatically deletes style tags, which is not a bug(?) (thread: /t/the-style-element-is-lost-after-click-the-html-editor/19370)

I use inline styling to highlight and format tables for particular cards, e.g. highlighting the column that contains the answer. Most of my tables have unique functional and aesthetic styling that AFAIK would be extremely impractical to move into the note template, or difficult to read and edit if written into the cells’ tags. I am sure other users have found other uses for style tags.

I understand CSS generally should go into the note templates by default, but no inline styling ever? Even then, prohibiting an extant tool over the user’s discretion seems unnecessary and unhelpful in a personal program, and retroactively purging it is [obligatory Apple joke]. Please allow this behavior to be worked around or turned off.

2 Likes

Poked around the github and it looks like this is what’s doing it (/ankitects/anki/blob/main/ts/editor/plain-text-input/remove-prohibited.ts). Might cross my fingers and try building from source.

A browser extension called ODH adds cards with formatting, when you add a card it looks like this:

However, when I hit the “Edit” button (e.g. to add a picture):

The formatting disappears:

Even though I don’t make any changes to the card.

This started happening after I switched from the version of 2.1.35-linux-amd64
to 2.1.51-linux-qt6, OS: Kubuntu 22.04

@hengiesel we previously discussed this on Split/Merge editor.py for its three use cases by hgiesel · Pull Request #1581 · ankitects/anki · GitHub - are there any technical reasons preventing us from removing style from the blacklist as well? Inline style tags are not something we’ve ever encouraged, but it would be nice to avoid breaking existing cards if we can avoid it.

3 Likes