natfarleydev / anki-auto-markdown

10 stars 2 forks source link

Broken for Anki Version ⁨2.1.50 (26d40c3a)⁩ #20

Open webdavis opened 2 years ago

webdavis commented 2 years ago

This was working until the latest Anki update via Homebrew.

Here's the debug info:

Debug info:
Anki 2.1.50 (26d40c3a) Python 3.9.7 Qt 6.2.3 PyQt 6.2.3
Platform: Mac 12.2.1
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-04-15 10:48:09
Add-ons possibly involved: ⁨Auto Markdown - fix version⁩

Caught exception:
Traceback (most recent call last):
  File "aqt.webview", line 557, in handler
  File "/Users/stephen/Library/Application Support/Anki2/addons21/15061497/editor.py", line 161, in onHtmlAvailable
    edited_field_html = re.sub(
  File "re", line 210, in sub
TypeError: expected string or bytes-like object
natfarleydev commented 2 years ago

Thanks for the report @stephenalandavis, I've just upgraded to 2.1.54 myself and can confirm this. It looks like the code for the editor has changed a lot! Since this plugin monkey-patches the editor, this part of the plugin is quite fragile.

I'm hoping to look at this over the next week, but if anyone else has more experience with the new editor, PRs are welcome!

rinogo commented 1 year ago

Bummer. I'm still seeing this in 2.1.54.

On a side-note: Why does Anki seem to have so many breaking changes? So many add-ons that I'd love to use no longer work. This seems like a design flaw of the core Anki system. ?

natfarleydev commented 1 year ago

Unfortunately in the past the only way a lot of plugins could work was by changing the internals of Anki at runtime. I've spent a day trying to fix this plugin but the internals have changed too much for me to fix myself, so I'm personally going to switch to an approach like this plugin (https://ankiweb.net/shared/info/1087328706) where it changes the markdown directly in the card using javascript.

Changing the card at runtime has some disadvantages (increased loading time being the main one) but the solution is much more sustainable as it doesn't rely on any Anki internals, just the various Anki apps rendering JavaScript/HTML.

I'll be archiving this repo, anyone who wants to continue development is more than welcome to fork the repo and start work!