From 18d2f871c298b1033cb164dacd48e0f723379a2e Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 25 Dec 2022 00:48:17 +0800 Subject: [PATCH] org: Split org-format-latex into two functions * lisp/org.el (org-place-formula-image, org-format-latex): Extract the overlay placement component of `org-format-latex' into a new function `org-place-formula-image`. --- lisp/org.el | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 0e6a3da0a..00674d1fc 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15801,21 +15801,7 @@ 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)) - (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))))))) + (org-place-formula-image link block-type beg end value overlays movefile imagetype))) ((eq processing-type 'mathml) ;; Process to MathML. (unless (org-format-latex-mathml-available-p) @@ -15830,6 +15816,25 @@ Some of the options can be changed using the variable (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))))))) +(defun org-place-formula-image (link block-type beg end value overlays 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)))))) + (defun org-create-math-formula (latex-frag &optional mathml-file) "Convert LATEX-FRAG to MathML and store it in MATHML-FILE. Use `org-latex-to-mathml-convert-command'. If the conversion is