From f592d7b3cc0c22c557a42d62b6a25f532aeaaa48 Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 26 Feb 2023 20:30:39 +0800 Subject: [PATCH] org-latex-preview: Split out entry construction * lisp/org-latex-preview.el (org-latex-preview--place-from-elements, org-latex-preview--construct-entries): Split the entry construction code into its own function `org-latex-preview--construct-entries'. This change will make it easier to generate previews during export. --- lisp/org-latex-preview.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index dec2f5a7e..add1cefd3 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -1005,12 +1005,16 @@ protection against placing doubled up overlays." (error "Unknown conversion process %s for previewing LaTeX fragments" processing-type))))) -(defun org-latex-preview--place-from-elements (processing-type elements) - "Preview LaTeX math fragments ELEMENTS using PROCESSING-TYPE." - (let* ((numbering-table (and org-latex-preview-numbered +(defun org-latex-preview--construct-entries + (elements &optional construct-numbering-p parse-tree) + "Constuct a well formatted list of entries and (optinally) numbering offsets. +This operates by processing ELEMENTS. When CONSTRUCT-NUMBERING-P is non-nil, +the number offsets will also be calculated, using PARSE-TREE if given." + (let* ((numbering-table (and construct-numbering-p (cl-find 'latex-environment elements :key #'org-element-type :test #'eq) - (org-latex-preview--environment-numbering-table))) + (org-latex-preview--environment-numbering-table + parse-tree))) (numbering-offsets (and numbering-table (mapcar @@ -1031,7 +1035,13 @@ protection against placing doubled up overlays." 1 0)) (org-element-property :value element))) elements))) - (org-latex-preview-place processing-type entries numbering-offsets))) + (list entries numbering-offsets))) + +(defun org-latex-preview--place-from-elements (processing-type elements) + "Preview LaTeX math fragments ELEMENTS using PROCESSING-TYPE." + (apply #'org-latex-preview-place processing-type + (org-latex-preview--construct-entries + elements org-latex-preview-numbered))) ;;;###autoload (defun org-latex-preview-place (processing-type entries &optional numbering-offsets latex-preamble)