diff --git a/Changelog.org b/Changelog.org
index 684e7b5..287a724 100644
--- a/Changelog.org
+++ b/Changelog.org
@@ -15,7 +15,9 @@
of file content
5. Supports literal note fields
6. Added more utility commands/functions
- 7. Minor internal code refactoring
+ 7. ~anki-editor-use-math-jax~ was replaced with
+ ~anki-editor-latex-style~
+ 8. Minor internal code refactoring
** v0.3.3
diff --git a/README.org b/README.org
index c253bf8..45095ce 100644
--- a/README.org
+++ b/README.org
@@ -88,7 +88,7 @@ there are any ambiguity or grammatical mistakes ;-)/
| anki-editor-ignored-org-tags | '("export" "noexport") | A list of Org tags that are ignored when constructing notes form entries. |
| anki-editor-org-tags-as-anki-tags | t | If nil, tags of entries wont't be counted as Anki tags. |
| anki-editor-protected-tags | '("marked" "leech") | A list of tags that won't be deleted from Anki even though they're absent in Org entries. |
- | anki-editor-use-math-jax | nil | Use Anki's built in MathJax support instead of LaTeX. |
+ | anki-editor-latex-style | builtin | The style of latex to translate into. |
** Functions and Macros
diff --git a/anki-editor.el b/anki-editor.el
index a5546e2..c76ec1e 100644
--- a/anki-editor.el
+++ b/anki-editor.el
@@ -98,8 +98,10 @@ form entries."
"8765"
"The port number AnkiConnect is listening.")
-(defcustom anki-editor-use-math-jax nil
- "Use Anki's built in MathJax support instead of LaTeX.")
+(defcustom anki-editor-latex-style 'builtin
+ "The style of latex to translate into."
+ :type '(radio (const :tag "Built-in" builtin)
+ (const :tag "MathJax" mathjax)))
;;; AnkiConnect
@@ -271,24 +273,23 @@ The result is the path to the newly stored media file."
"$" "\\)")))))
(defun anki-editor--translate-latex-fragment (latex-code)
- (let ((table (if anki-editor-use-math-jax
- anki-editor--mathjax-delimiters
- anki-editor--native-latex-delimiters)))
- (cl-loop for delims in table
- for matches = (string-match (cl-first delims) latex-code)
- when matches
- do
- (setq latex-code (replace-match (cl-second delims) t t latex-code))
- (string-match (cl-third delims) latex-code)
- (setq latex-code (replace-match (cl-fourth delims) t t latex-code))
- until matches
- finally return latex-code)))
+ (cl-loop for delims in (cl-ecase anki-editor-latex-style
+ (builtin anki-editor--native-latex-delimiters)
+ (mathjax anki-editor--mathjax-delimiters))
+ for matches = (string-match (cl-first delims) latex-code)
+ when matches
+ do
+ (setq latex-code (replace-match (cl-second delims) t t latex-code))
+ (string-match (cl-third delims) latex-code)
+ (setq latex-code (replace-match (cl-fourth delims) t t latex-code))
+ until matches
+ finally return latex-code))
(defun anki-editor--translate-latex-env (latex-code)
(setq latex-code (replace-regexp-in-string "\n" "
" (org-html-encode-plain-text latex-code)))
- (if anki-editor-use-math-jax
- (concat "\\[
" latex-code "\\]")
- (concat "[latex]
" latex-code "[/latex]")))
+ (cl-ecase anki-editor-latex-style
+ (builtin (concat "[latex]
" latex-code "[/latex]"))
+ (mathjax (concat "\\[
" latex-code "\\]"))))
(defun anki-editor--ox-latex (latex _contents _info)
"Transcode LATEX from Org to HTML.