Make latex flavor a list of choices
This commit is contained in:
parent
36b8884b15
commit
e665f2c28f
3 changed files with 22 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,10 +273,9 @@ 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
|
||||
(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
|
||||
|
@ -282,13 +283,13 @@ The result is the path to the newly stored media file."
|
|||
(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)))
|
||||
finally return latex-code))
|
||||
|
||||
(defun anki-editor--translate-latex-env (latex-code)
|
||||
(setq latex-code (replace-regexp-in-string "\n" "<br>" (org-html-encode-plain-text latex-code)))
|
||||
(if anki-editor-use-math-jax
|
||||
(concat "\\[<br>" latex-code "\\]")
|
||||
(concat "[latex]<br>" latex-code "[/latex]")))
|
||||
(cl-ecase anki-editor-latex-style
|
||||
(builtin (concat "[latex]<br>" latex-code "[/latex]"))
|
||||
(mathjax (concat "\\[<br>" latex-code "\\]"))))
|
||||
|
||||
(defun anki-editor--ox-latex (latex _contents _info)
|
||||
"Transcode LATEX from Org to HTML.
|
||||
|
|
Loading…
Reference in a new issue