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
|
of file content
|
||||||
5. Supports literal note fields
|
5. Supports literal note fields
|
||||||
6. Added more utility commands/functions
|
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
|
** 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-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-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-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
|
** Functions and Macros
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,10 @@ form entries."
|
||||||
"8765"
|
"8765"
|
||||||
"The port number AnkiConnect is listening.")
|
"The port number AnkiConnect is listening.")
|
||||||
|
|
||||||
(defcustom anki-editor-use-math-jax nil
|
(defcustom anki-editor-latex-style 'builtin
|
||||||
"Use Anki's built in MathJax support instead of LaTeX.")
|
"The style of latex to translate into."
|
||||||
|
:type '(radio (const :tag "Built-in" builtin)
|
||||||
|
(const :tag "MathJax" mathjax)))
|
||||||
|
|
||||||
|
|
||||||
;;; AnkiConnect
|
;;; AnkiConnect
|
||||||
|
@ -271,10 +273,9 @@ The result is the path to the newly stored media file."
|
||||||
"$" "\\)")))))
|
"$" "\\)")))))
|
||||||
|
|
||||||
(defun anki-editor--translate-latex-fragment (latex-code)
|
(defun anki-editor--translate-latex-fragment (latex-code)
|
||||||
(let ((table (if anki-editor-use-math-jax
|
(cl-loop for delims in (cl-ecase anki-editor-latex-style
|
||||||
anki-editor--mathjax-delimiters
|
(builtin anki-editor--native-latex-delimiters)
|
||||||
anki-editor--native-latex-delimiters)))
|
(mathjax anki-editor--mathjax-delimiters))
|
||||||
(cl-loop for delims in table
|
|
||||||
for matches = (string-match (cl-first delims) latex-code)
|
for matches = (string-match (cl-first delims) latex-code)
|
||||||
when matches
|
when matches
|
||||||
do
|
do
|
||||||
|
@ -282,13 +283,13 @@ The result is the path to the newly stored media file."
|
||||||
(string-match (cl-third delims) latex-code)
|
(string-match (cl-third delims) latex-code)
|
||||||
(setq latex-code (replace-match (cl-fourth delims) t t latex-code))
|
(setq latex-code (replace-match (cl-fourth delims) t t latex-code))
|
||||||
until matches
|
until matches
|
||||||
finally return latex-code)))
|
finally return latex-code))
|
||||||
|
|
||||||
(defun anki-editor--translate-latex-env (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)))
|
(setq latex-code (replace-regexp-in-string "\n" "<br>" (org-html-encode-plain-text latex-code)))
|
||||||
(if anki-editor-use-math-jax
|
(cl-ecase anki-editor-latex-style
|
||||||
(concat "\\[<br>" latex-code "\\]")
|
(builtin (concat "[latex]<br>" latex-code "[/latex]"))
|
||||||
(concat "[latex]<br>" latex-code "[/latex]")))
|
(mathjax (concat "\\[<br>" latex-code "\\]"))))
|
||||||
|
|
||||||
(defun anki-editor--ox-latex (latex _contents _info)
|
(defun anki-editor--ox-latex (latex _contents _info)
|
||||||
"Transcode LATEX from Org to HTML.
|
"Transcode LATEX from Org to HTML.
|
||||||
|
|
Loading…
Reference in a new issue