Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile support? #3

Open
zeitchef opened this issue Mar 6, 2024 · 4 comments
Open

Mobile support? #3

zeitchef opened this issue Mar 6, 2024 · 4 comments

Comments

@zeitchef
Copy link

zeitchef commented Mar 6, 2024

I primarily use Anki on mobile, but I can't get the syntax to change for some reason. Specifically, I'm targeting the base16/ros-pine theme. On desktop it works, but I had to go through every card for the highlighting to change (something with Anki's cache?), but on mobile I just don't get anything. Before I spend a ton of time debugging it myself, can you confirm this supports mobile (iOS in my case)? Many thanks!

@midrare
Copy link
Owner

midrare commented Mar 6, 2024

Mobile is not supported. There's actually no way for a way for addons to have true support for mobile because addons only run on desktop. The mobile apps are actually third-party implementations that can read the anki db but don't share the same codebase.

The way addons "support" mobile is to use some rather nasty hacks like hardcoding the highlighting directly into your note's html or patching your card templates. The mobile app is just a plain webview; it doesn't know how to call into addon hooks like the desktop app can. So you're only left with this option.

If you really want mobile you have to use one of the other (data-altering) highlighting addons.

@zeitchef
Copy link
Author

zeitchef commented Mar 7, 2024

Totally get what you mean regarding the mobile apps being "third-party implementations", but I mean as you say they are just basically web pages. Why can't I just access the library from a CDN? So long as I have an internet connection, I don't need what's in collection.media on the desktop. For sure external scripts via a CDN can be loaded on mobile, right?

@zeitchef
Copy link
Author

zeitchef commented Mar 7, 2024

Actually, seems support for loading external scripts on AnkiDroid is supported as of 2.15: ankidroid/Anki-Android#9098 (comment)

@midrare
Copy link
Owner

midrare commented Mar 7, 2024

The problem isn't how to access the js, it's how to insert it in the web view. Currently anki-code-highlight adds a hook, called by desktop anki right before the note html is displayed. It takes the note html as an argument, inserts a script tag and then returns the modified html, which desktop anki then sends to the web view.

It's the desktop implementation that provides this intercepting mechanism. I don't know of any equivalent mechanism for mobile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants