Dependencies in media

Hi,

I just had an unexpected problem. I’ve got a card type with a javascript library that uses multiple file, the first file including the second one. However, the second one is not detected, and when I export a card, it is not in the media folder.

Is it a question you’d accept to tackle, or do you consider that this is such a niche problem that you wont spend time on it ? In the first case, I’d be willing to help, of course, and to port teh decided solution to ankidroid.

The simplest solution I can imagine would be simply to check, for all medias m, for all exported text file f, check if m’s path appears in f, if so export m. We may export too much media. We may even miss some media if the name does not appear as a litteral but is computed, but it would solve my problem.
Otherwise, having a specific syntax to indicate all medias used by a card type may be a working solution too…

Related: would you accept to add automated code coloration in anki the same way that you added mathjax in anki. Up to now, the only code coloration tools I’ve seen used in anki required the field content to be colored. This is very bad because it makes it hard to modify the code later if it is required. I’ve finally been able to use highlight.js with anki, and I’m going to make a post on reddit and elsewhere explaining how to do it, however, having it natively in anki would make it far more easier. I would be more than willing to do the work if so.

1 Like

You’ll either need to include the filenames in the template (even in a comment should work if I recall correctly), or on a suspended card.

Including a new JS library means we’re effectively stuck supporting it from then on, so it really needs to be limited to libraries that would provide value to a large number of users - and I suspect syntax highlighting would be somewhat less popular than MathJax… Have you considered distributing a 1 card deck with a note type set up to use the js file? Users could then just import the deck, and add new contents to that note type.

1 Like

It’s not only considered, but already done : https://www.reddit.com/r/Anki/comments/kzttw2/syntax_coloring_of_code_in_anki/

I understand your point even if I regret it.
Thanks

1 Like