[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org af4ca40eae 10/13: ox-latex: Fix %-captions in minte
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org af4ca40eae 10/13: ox-latex: Fix %-captions in minted/engraved code |
Date: |
Thu, 12 May 2022 12:57:52 -0400 (EDT) |
branch: externals/org
commit af4ca40eaecf110a6a94629fe1de1f08d846eb73
Author: TEC <tec@tecosaur.com>
Commit: TEC <tec@tecosaur.com>
ox-latex: Fix %-captions in minted/engraved code
* lisp/ox-latex.el (org-latex-src-block--engraved,
org-latex-src-block--minted): Refactor float-env to be clearer, and
switch from `format' to `concat' to fix the bug where %-chars in
captions are interpreted as a format specifier.
---
lisp/ox-latex.el | 55 ++++++++++++++++++++++++-------------------------------
1 file changed, 24 insertions(+), 31 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9634461bd8..ceb1bd483f 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3330,23 +3330,20 @@ and FLOAT are extracted from SRC-BLOCK and INFO in
`org-latex-src-block'."
(let* ((caption-str (org-latex--caption/label-string src-block info))
(placement (or (org-unbracket-string "[" "]" (plist-get attributes
:placement))
(plist-get info :latex-default-figure-position)))
+ (multicolumn-p (string= "multicolumn" float))
(float-env
(cond
- ((string= "multicolumn" float)
- (format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}"
- placement
- (if caption-above-p caption-str "")
- (if caption-above-p "" caption-str)))
- (caption
- (format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}"
- placement
- (if caption-above-p caption-str "")
- (if caption-above-p "" caption-str)))
+ ((or caption multicolumn-p)
+ (cons
+ (concat "\\begin{listing" (when multicolumn-p "*")
+ "}[" placement "]\n"
+ (if caption-above-p caption-str ""))
+ (concat "\n" (if caption-above-p "" caption-str)
+ "\\end{listing" (when multicolumn-p "*") "}")))
((string= "t" float)
- (concat (format "\\begin{listing}[%s]\n"
- placement)
- "%s\n\\end{listing}"))
- (t "%s")))
+ (cons
+ (concat "\\begin{listing}[" placement "]\n")
+ "\n\\end{listing}"))))
(options (plist-get info :latex-minted-options))
(body
(format
@@ -3386,8 +3383,7 @@ and FLOAT are extracted from SRC-BLOCK and INFO in
`org-latex-src-block'."
?\s)
(format "(%s)" ref)))))
nil (and retain-labels (cdr code-info)))))))
- ;; Return value.
- (format float-env body)))
+ (concat (car float-env) body (cdr float-env))))
(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.
@@ -3447,23 +3443,20 @@ and FLOAT are extracted from SRC-BLOCK and INFO in
`org-latex-src-block'."
(let* ((caption-str (org-latex--caption/label-string src-block info))
(placement (or (org-unbracket-string "[" "]" (plist-get attributes
:placement))
(plist-get info :latex-default-figure-position)))
+ (multicolumn-p (string= "multicolumn" float))
(float-env
(cond
- ((string= "multicolumn" float)
- (format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}"
- placement
- (if caption-above-p caption-str "")
- (if caption-above-p "" caption-str)))
- (caption
- (format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}"
- placement
- (if caption-above-p caption-str "")
- (if caption-above-p "" caption-str)))
+ ((or caption multicolumn-p)
+ (cons
+ (concat "\\begin{listing" (when multicolumn-p "*")
+ "}[" placement "]\n"
+ (if caption-above-p caption-str ""))
+ (concat "\n" (if caption-above-p "" caption-str)
+ "\\end{listing" (when multicolumn-p "*") "}")))
((string= "t" float)
- (concat (format "\\begin{listing}[%s]\n"
- placement)
- "%s\n\\end{listing}"))
- (t "%s")))
+ (cons
+ (concat "\\begin{listing}[" placement "]\n")
+ "\n\\end{listing}"))))
(options
(let ((engraved-options (plist-get info :latex-engraved-options))
(local-options (plist-get attributes :options)))
@@ -3498,7 +3491,7 @@ and FLOAT are extracted from SRC-BLOCK and INFO in
`org-latex-src-block'."
content lang
(when engraved-theme (intern engraved-theme))
options)))
- (format float-env body)))
+ (concat (car float-env) body (cdr float-env))))
(cl-defun org-latex-src-block--listings
(&key src-block info lang caption caption-above-p label num-start
retain-labels attributes float &allow-other-keys)
- [elpa] externals/org b4e4b3c502 07/13: ox-latex: Replace `org-latex-listings', (continued)
- [elpa] externals/org b4e4b3c502 07/13: ox-latex: Replace `org-latex-listings', ELPA Syncer, 2022/05/12
- [elpa] externals/org 61d85bcdb3 01/13: ox-latex: Refactor `org-latex-src-block', ELPA Syncer, 2022/05/12
- [elpa] externals/org 40c559ac3d 02/13: ox-latex: Refactor `org-latex-inline-src-block', ELPA Syncer, 2022/05/12
- [elpa] externals/org e07b89c31c 06/13: ox-latex: Refactor source block transcode fun sigs, ELPA Syncer, 2022/05/12
- [elpa] externals/org d30738b786 04/13: ox-latex: Introduce "engraved" code highlighting, ELPA Syncer, 2022/05/12
- [elpa] externals/org a16e208938 08/13: ox-latex: Support setting the engraved theme, ELPA Syncer, 2022/05/12
- [elpa] externals/org 4d5805755c 09/13: ox-latex: Support setting engraved theme per-block, ELPA Syncer, 2022/05/12
- [elpa] externals/org faa5c1887c 11/13: ox-latex: Support mathescape'd code with engraved, ELPA Syncer, 2022/05/12
- [elpa] externals/org 5766ddd758 13/13: ox-latex: Prefix lst: to source block labels, ELPA Syncer, 2022/05/12
- [elpa] externals/org ca91473639 03/13: ox-latex: More versitile option construction, ELPA Syncer, 2022/05/12
- [elpa] externals/org af4ca40eae 10/13: ox-latex: Fix %-captions in minted/engraved code,
ELPA Syncer <=
- [elpa] externals/org 2cb62c0798 12/13: news and manual: Mention ox-latex's engraved code, ELPA Syncer, 2022/05/12