emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org faa5c1887c 11/13: ox-latex: Support mathescape'd co


From: ELPA Syncer
Subject: [elpa] externals/org faa5c1887c 11/13: ox-latex: Support mathescape'd code with engraved
Date: Thu, 12 May 2022 12:57:52 -0400 (EDT)

branch: externals/org
commit faa5c1887c1b36fea72e09349531b6bb11b05dd1
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>

    ox-latex: Support mathescape'd code with engraved
    
    * lisp/ox-latex.el (org-latex-src-block--engraved,
    org-latex-src--engrave-mathescape-p): Using the mathescape functionality
    in engrave-faces-latex v0.3.1, we can support the mathescape option of
    fvextra well.  Along the way, we fix a minor issue with the localoptions
    list in `org-latex-src-block--engraved`.
---
 lisp/ox-latex.el | 46 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index ceb1bd483f..29543f8e9b 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3385,6 +3385,40 @@ and FLOAT are extracted from SRC-BLOCK and INFO in 
`org-latex-src-block'."
               nil (and retain-labels (cdr code-info)))))))
     (concat (car float-env) body (cdr float-env))))
 
+(defun org-latex-src--engrave-mathescape-p (info options)
+  "From the export INFO plist, and the per-block OPTIONS, determine 
mathescape."
+  (let ((default-options (plist-get info :latex-engraved-options))
+        (mathescape-status
+         (lambda (opts)
+           (cl-some
+            (lambda (opt)
+              (or (and
+                   (null (cdr opt))
+                   (cond
+                    ((string-match-p
+                      "\\(?:^\\|,\\)mathescape=false\\(?:,\\|$\\)"
+                      (car opt))
+                     'no)
+                    ((or (string-match-p
+                          "\\(?:^\\|,\\)mathescape\\(?:=true\\)?\\(?:,\\|$\\)"
+                          (car opt))
+                         (string= "mathescape" (car opt)))
+                     'yes)))
+                  (and
+                   (string= (car opt) "mathescape")
+                   (cond
+                    ((or (and (stringp (cdr opt)) (string= (cdr opt) "true"))
+                         (equal '("true") (cdr opt)))
+                     'yes)
+                    ((or (and (stringp (cdr opt)) (string= "false" (cdr opt)))
+                         (equal '("false") (cdr opt)))
+                     'no)))))
+            opts))))
+    (if-let ((mathescape (or (funcall mathescape-status default-options)
+                             (funcall mathescape-status options))))
+        (when (eq mathescape 'yes)
+          (or engrave-faces-latex-mathescape t)))))
+
 (defun org-latex-src--engrave-code (content lang &optional theme options 
inline)
   "Engrave CONTENT to LaTeX in a LANG-mode buffer, and give the result.
 When the THEME symbol is non-nil, that theme will be used.
@@ -3464,7 +3498,7 @@ and FLOAT are extracted from SRC-BLOCK and INFO in 
`org-latex-src-block'."
              (when (and num-start (not (assoc "linenos" engraved-options)))
                `(("linenos")
                  ("firstnumber" ,(number-to-string (1+ num-start)))))
-             (and local-options (list local-options)))))
+             (and local-options `((,local-options))))))
          (engraved-theme (plist-get attributes :engraved-theme))
          (content
           (let* ((code-info (org-export-unravel-code src-block))
@@ -3487,10 +3521,12 @@ and FLOAT are extracted from SRC-BLOCK and INFO in 
`org-latex-src-block'."
                           (format "(%s)" ref)))))
              nil (and retain-labels (cdr code-info)))))
          (body
-          (org-latex-src--engrave-code
-           content lang
-           (when engraved-theme (intern engraved-theme))
-           options)))
+          (let ((engrave-faces-latex-mathescape
+                 (org-latex-src--engrave-mathescape-p info options)))
+            (org-latex-src--engrave-code
+             content lang
+             (when engraved-theme (intern engraved-theme))
+             options))))
     (concat (car float-env) body (cdr float-env))))
 
 (cl-defun org-latex-src-block--listings



reply via email to

[Prev in Thread] Current Thread [Next in Thread]