ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.52k stars 2.21k forks source link

AnkiDroid2.0 doesn't open LaTeX generated SVGs. #2367

Closed hssm closed 9 years ago

hssm commented 9 years ago

Originally reported on Google Code with ID 1465

What steps will reproduce the problem?
1. In Anki 2.0 on the desktop replace the LaTeX rendering backend DVIPNG with one that
produces SVGs. Or use ImageMagick to convert a PNG in your media folder to SVG and
delete the PNG.
2. Sync the desktop media and then sync AnkiDroid.
3. AnkiDroid won't load a LaTeX card that is SVG, but it will load a regular card that
has an SVG file, and it will load a card with a LaTeX generated PNG. The Anki desktop
client will load all 3.

What is the expected output? What do you see instead?
 AnkiDroid should load all the same media as the desktop client, even if that includes
LaTeX cards with SVGs.

Does it happen again every time you repeat the steps above? Or did it
happen only one time?

What version of AnkiDroid are you using?
AnkiDroid 2.0-beta20

On what version of Android?
Galaxy Nexus Stock 4.1.2

Here's the SVG generation script, tex2png, that can either be added to $PATH or have
latex.py point to directly:
#! /bin/bash

pdflatex ./tmp.tex
pdfcrop ./tmp.pdf
pdf2svg ./tmp-crop.pdf ./tmp.svg
rm ./tmp.{tex,pdf,log,aux,dvi} ./tmp-crop.pdf

You also have to change some lines in /usr/share/anki/libanki/anki/latex.py:
latexDviPngCmd = ["tex2png"]

    svg = namedtmp("tmp.svg")

        if call(latexDviPngCmd,

        shutil.copyfile(svg, os.path.join(mdir, fname))

Reported by teratomata on 2012-11-04 23:15:11

hssm commented 9 years ago
If you hack the Anki sources then you'll need to hack the AD sources too.

Reported by dae@ichi2.net on 2012-11-05 00:27:52

hssm commented 9 years ago
The only thing is I didn't hack what media Anki can display - and AnkiDroid should have
feature parity for displaying media, even if it's unusual.

Reported by teratomata on 2012-11-05 18:39:42

hssm commented 9 years ago
I'm confused. If this is not working with anki desktop (without changing the anki code),
what constitutes lack of media support on ankidroid's side?

Reported by inigo.aldana on 2012-11-15 20:56:37

hssm commented 9 years ago
I hacked Anki to generate an SVG instead of a PNG, I didn't hack Anki to make it so
it can display SVG - it already can. 

To demonstrate this, make a LaTeX card, go to your media folder, replace the .png with
a .svg of the same filename, restart anki, and then open the card. Clearly without
hacking, Anki is displaying an SVG for a LaTeX card. AnkiDroid won't do this.

Reported by teratomata on 2012-11-20 15:01:18

hssm commented 9 years ago
See comment 1.

Reported by dae@ichi2.net on 2012-11-20 16:13:02

hssm commented 9 years ago

Reported by Houssam.Salem.Au on 2015-01-26 10:19:03