louietan / anki-editor

Emacs minor mode for making Anki cards with Org
699 stars 87 forks source link

AnkiDroid doesn't support wrapping each lines of display equations in <div> #92

Open jody-frankowski opened 3 years ago

jody-frankowski commented 3 years ago

I have replaced anki-editor--ox-latex-for-mathjax with this version, and I have had no issues on Anki desktop and AnkiDroid.

(defun anki-editor--ox-latex-for-mathjax (latex _contents _info)
  "Transcode LATEX from Org to HTML.
CONTENTS is nil.  INFO is a plist holding contextual information."
  (message "HELLO")
  (let ((code (org-remove-indentation (org-element-property :value latex))))
    (setq code
          (pcase (org-element-type latex)
            ('latex-fragment (anki-editor--translate-latex-delimiters-to-anki-mathjax-delimiters code))
            ('latex-environment (anki-editor--wrap-latex-for-mathjax (org-html-encode-plain-text code)))))

    (if anki-editor-break-consecutive-braces-in-latex
        (replace-regexp-in-string "}}" "} } " code)
      code)))

Please note that I used this pull request to make the display equations (latex-environments) work.