org-latex-preview: Split org-place-formula-image

* lisp/org-latex-preview.el (org-create-latex-preview,
org-place-formula-image, org-place-latex-image,
org-place-latex-image-link): Replace `org-place-formula-image' with two
functions, one for overlays (`org-place-latex-image') and another for
links (`org-place-latex-image-link').
This commit is contained in:
TEC 2022-12-26 16:17:25 +08:00
parent ae09ab8ebe
commit 3b9b87548b
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 20 additions and 18 deletions

View File

@ -501,27 +501,29 @@ Some of the options can be changed using the variable
(unless (file-exists-p movefile) (unless (file-exists-p movefile)
(org-create-formula-image (org-create-formula-image
value movefile options forbuffer processing-type)) value movefile options forbuffer processing-type))
(org-place-formula-image (if overlays
link block-type beg end value overlays movefile imagetype))) (org-place-latex-image beg end movefile imagetype)
(org-place-latex-image-link link block-type beg end value))))
(defun org-place-formula-image (link block-type beg end value overlays movefile imagetype) (defun org-place-latex-image (beg end movefile imagetype)
"Place an overlay from BEG to END showing MOVEFILE. "Place an overlay from BEG to END showing MOVEFILE.
The overlay will be above BEG if OVERLAYS is non-nil." The overlay will be above BEG if OVERLAYS is non-nil."
(if overlays (dolist (o (overlays-in beg end))
(progn (when (eq (overlay-get o 'org-overlay-type)
(dolist (o (overlays-in beg end)) 'org-latex-overlay)
(when (eq (overlay-get o 'org-overlay-type) (delete-overlay o)))
'org-latex-overlay) (org--make-preview-overlay beg end movefile imagetype)
(delete-overlay o))) (goto-char end))
(org--make-preview-overlay beg end movefile imagetype)
(goto-char end)) (defun org-place-latex-image-link (link block-type beg end value)
(delete-region beg end) "Place then link LINK at BEG END."
(insert (delete-region beg end)
(org-add-props link (insert
(list 'org-latex-src (org-add-props link
(replace-regexp-in-string "\"" "" value) (list 'org-latex-src
'org-latex-src-embed-type (replace-regexp-in-string "\"" "" value)
(if block-type 'paragraph 'character)))))) 'org-latex-src-embed-type
(if block-type 'paragraph 'character)))))
(defun org-create-math-formula (latex-frag &optional mathml-file) (defun org-create-math-formula (latex-frag &optional mathml-file)
"Convert LATEX-FRAG to MathML and store it in MATHML-FILE. "Convert LATEX-FRAG to MathML and store it in MATHML-FILE.