Editor: apply font color, background color, custom class, custom style [Official thread]

The add-on has been updated to work with 2.1.60

3 Likes

That’s great, no more fiddling around with HTML to change the formatting. A big thank you.

style (inline) category does not seem to work with Anki 2.1.61 and macOS 11.5.2. It has no effect at all to the HTML source code.

I’m having the same problem. I assumed that the inline styling would wrap the selected text with a <span> containing the style added in the config menu, but it doesn’t do anything at all.

The option “text wrapper” seems to be broken, “class (other)” and “class (other), wrapped in div” are still working.

Anki 2.1.66 (cf16ce1d) Python 3.11.5 Qt 6.5.2 PyQt 6.5.2
Platform: Linux-5.15.131-1-MANJARO-x86_64-with-glibc2.38
Flags: frz=False ao=True sv=3
Add-ons, last update check: 2023-10-02 10:10:55
Möglicherweise beteiligte Erweiterungen: Custom Styles font color background colour classes

Caught exception:
Traceback (most recent call last):
  File "/home/simon/.local/share/Anki2/addons21/1899278645/editor/menu.py", line 99, in my_highlight_helper
    func(editor, entry)
  File "/home/simon/.local/share/Anki2/addons21/1899278645/editor/apply_categories.py", line 16, in wrap_text
    before, after = beforeAfter.split(unique_string)
    ^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

Edit:
Removing the assigned keyboard shortcuts solves the issue. Took me a while to figure out that you need to press Ctrl to unset a keyboard shortcut. This also works for the options that did not have a keyboard shortcut assigned anyway.
Adding a new keyboard shortcut afterwards causes the issue to reappear.

Hello, I need to create custum format to make text Italic and Superscript, for example, the orginal text should return text, like anki buttons would do.
I could not manage to do this on the plugin because I’m not a dev. Can anyone help me?

If you always want Superscript to be combined with Italic, you should be able to accomplish that by adding this code to the Styling section of your notes:

sup { font-style: italic; }

Thanks for the reply @jcznk , maybe it will help :).
But at first my intention would be using it only in special cases, not always. How can I do that only on the addon setup?

please make a version off this Add-on compatible with V 2.1.50+ especially V 2.1.54 because It is not compatible with It (error on start up)

如下图,标注的那个菜组组似乎并不起作用。我想把分属不同类的样式放在一组,但没有效果。


I have been using your addon for years unfortunately in newer anki versions it causes slowdown on my pc when loading formatting. I would like to replace class tags with normal formatting using regular expression in find and replace
for example

Par quelle <span class="bold_red">lettre</span> commence votre <span class="bold_blue">prénom</span> ?

to

Par quelle <b><font color="#ff0000">lettre</font></b> commence votre <b><font color="#0000ff">prénom</font></b>?

How to do it?