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)
(org-create-formula-image
value movefile options forbuffer processing-type))
(org-place-formula-image
link block-type beg end value overlays movefile imagetype)))
(if overlays
(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.
The overlay will be above BEG if OVERLAYS is non-nil."
(if overlays
(progn
(dolist (o (overlays-in beg end))
(when (eq (overlay-get o 'org-overlay-type)
'org-latex-overlay)
(delete-overlay o)))
(org--make-preview-overlay beg end movefile imagetype)
(goto-char end))
(delete-region beg end)
(insert
(org-add-props link
(list 'org-latex-src
(replace-regexp-in-string "\"" "" value)
'org-latex-src-embed-type
(if block-type 'paragraph 'character))))))
(dolist (o (overlays-in beg end))
(when (eq (overlay-get o 'org-overlay-type)
'org-latex-overlay)
(delete-overlay o)))
(org--make-preview-overlay beg end movefile imagetype)
(goto-char end))
(defun org-place-latex-image-link (link block-type beg end value)
"Place then link LINK at BEG END."
(delete-region beg end)
(insert
(org-add-props link
(list 'org-latex-src
(replace-regexp-in-string "\"" "" value)
'org-latex-src-embed-type
(if block-type 'paragraph 'character)))))
(defun org-create-math-formula (latex-frag &optional mathml-file)
"Convert LATEX-FRAG to MathML and store it in MATHML-FILE.