branch: externals/org
commit 18d2f871c298b1033cb164dacd48e0f723379a2e
Author: TEC <g...@tecosaur.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    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 0e6a3da0a3..00674d1fcb 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

Reply via email to