Skip to content

Use SVG images of LaTeX formulas, when required#4724

Merged
timrae merged 1 commit intoankidroid:masterfrom
plotasse:svg-latex
Nov 10, 2017
Merged

Use SVG images of LaTeX formulas, when required#4724
timrae merged 1 commit intoankidroid:masterfrom
plotasse:svg-latex

Conversation

@plotasse
Copy link
Contributor

@plotasse plotasse commented Nov 4, 2017

As this pull request was merged into Anki 2.1, LaTeX can now be exported to SVG instead of PNG, by enabling an option in the note type (see this commit).

This works the same way as the current Anki 2.1 code:

  • if the note type specifies it, look for an svg file
  • otherwise, look for a png one

I'm not sure if it should be done this way or if AnkiDroid should check for both files, ignoring the note type.

@timrae
Copy link
Member

timrae commented Nov 7, 2017

@dae
Why do you have those three unused parameters in:

def mungeQA(html, type, fields, model, data, col):

String fname = "latex-" + Utils.checksum(txt) + ".png";

String ext = "png";
if (model.optBoolean("latexsvg", false))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

This works the same way as the current Anki 2.1 code:
- if the note type specifies it, look for an svg file
- otherwise, look for a png one
@dae
Copy link
Contributor

dae commented Nov 8, 2017

The LaTeX code doesn't need the unused parameters, but they may be used by some add-ons.

@timrae
Copy link
Member

timrae commented Nov 8, 2017

Thanks, any comment on this?

I'm not sure if it should be done this way or if AnkiDroid should check for both files, ignoring the note type.

It would seem that the setting should just control whether or not svg files are generated, and clients should be able to handle both file types. Obviously we want old .png files to still work on non-rendering clients even after the user changes to the setting to svg. Clients that do render may want to re-render as svg however.

@dae
Copy link
Contributor

dae commented Nov 8, 2017

If a user has opted in to svg generation, then I think it's reasonable for the mobile clients to only look for svg files. Falling back on any png files that may be lying around is likely to only cause confusion, as users may wonder why some images are being rendered in a different font. If the user is stuck on an old Android version, then it does not make sense for them to enable the svg generation option as any new LaTeX they add would not appear in AnkiDroid.

@timrae timrae merged commit 4af6a68 into ankidroid:master Nov 10, 2017
@timrae
Copy link
Member

timrae commented Nov 10, 2017

Released in v2.9 alpha 12

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

Successfully merging this pull request may close these issues.

3 participants