summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-08-12 18:24:34 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2012-08-12 18:24:34 +0200
commita88ab9cdbcc67d471dc25fcc66113fb2a735fdb3 (patch)
tree32eb597b5c165bfd58cec1661422cdd16a18a16b
parent1e47e65e977e0f704feed505595ff87da0369350 (diff)
downloadorg-mode-a88ab9cdbcc67d471dc25fcc66113fb2a735fdb3.tar.gz
org-e-beamer: Prevent fragile frames from eating first word
* contrib/lisp/org-e-beamer.el (org-e-beamer--format-frame): In a fragile frame, append a white space to contents in order to prevent Beamer from eating first word when appending "\par".
-rw-r--r--contrib/lisp/org-e-beamer.el94
1 files changed, 51 insertions, 43 deletions
diff --git a/contrib/lisp/org-e-beamer.el b/contrib/lisp/org-e-beamer.el
index 002d28e..af5b8ff 100644
--- a/contrib/lisp/org-e-beamer.el
+++ b/contrib/lisp/org-e-beamer.el
@@ -379,55 +379,63 @@ used as a communication channel."
"Format HEADLINE as a frame.
CONTENTS holds the contents of the headline. INFO is a plist
used as a communication channel."
- (concat "\\begin{frame}"
- ;; Overlay specification, if any. If is surrounded by square
- ;; brackets, consider it as a default specification.
- (let ((action (org-element-property :beamer-act headline)))
- (cond
- ((not action) "")
- ((string-match "\\`\\[.*\\]\\'" action )
- (org-e-beamer--normalize-argument action 'defaction))
- (t (org-e-beamer--normalize-argument action 'action))))
- ;; Options, if any.
- (let ((options
- ;; Collect options from default value and headline's
- ;; properties. Also add a label for links.
- (append
- (org-split-string org-e-beamer-frame-default-options
- ",")
- (let ((opt (org-element-property :beamer-opt headline)))
- (and opt (org-split-string
- ;; Remove square brackets if user
- ;; provided them.
- (and (string-match "^\\[?\\(.*\\)\\]?$" opt)
- (match-string 1 opt))
- ",")))
- (list
- (format "label=sec-%s"
- (mapconcat
- 'number-to-string
- (org-export-get-headline-number headline info)
- "-"))))))
- ;; Change options list into a string. FRAGILEP is non-nil
- ;; when HEADLINE contains an element among
- ;; `org-e-beamer-verbatim-elements'.
- (let ((fragilep (org-element-map
- headline org-e-beamer-verbatim-elements 'identity
- info 'first-match)))
+ (let ((fragilep
+ ;; FRAGILEP is non-nil when HEADLINE contains an element
+ ;; among `org-e-beamer-verbatim-elements'.
+ (org-element-map headline org-e-beamer-verbatim-elements 'identity
+ info 'first-match)))
+ (concat "\\begin{frame}"
+ ;; Overlay specification, if any. If is surrounded by square
+ ;; brackets, consider it as a default specification.
+ (let ((action (org-element-property :beamer-act headline)))
+ (cond
+ ((not action) "")
+ ((string-match "\\`\\[.*\\]\\'" action )
+ (org-e-beamer--normalize-argument action 'defaction))
+ (t (org-e-beamer--normalize-argument action 'action))))
+ ;; Options, if any.
+ (let ((options
+ ;; Collect options from default value and headline's
+ ;; properties. Also add a label for links.
+ (append
+ (org-split-string org-e-beamer-frame-default-options
+ ",")
+ (let ((opt (org-element-property :beamer-opt headline)))
+ (and opt (org-split-string
+ ;; Remove square brackets if user
+ ;; provided them.
+ (and (string-match "^\\[?\\(.*\\)\\]?$" opt)
+ (match-string 1 opt))
+ ",")))
+ (list
+ (format "label=sec-%s"
+ (mapconcat
+ 'number-to-string
+ (org-export-get-headline-number headline info)
+ "-"))))))
+ ;; Change options list into a string.
(org-e-beamer--normalize-argument
(mapconcat
'identity
(if (or (not fragilep) (member "fragile" options)) options
(cons "fragile" options))
",")
- 'option)))
- ;; Title.
- (format "{%s}"
- (org-export-data (org-element-property :title headline)
- info))
- "\n"
- contents
- "\\end{frame}"))
+ 'option))
+ ;; Title.
+ (format "{%s}"
+ (org-export-data (org-element-property :title headline)
+ info))
+ "\n"
+ ;; The following workaround is required in fragile frames
+ ;; as Beamer will append "\par" to the beginning of the
+ ;; contents. So we need to make sure the command is
+ ;; separated from the contents by at least one space. If
+ ;; it isn't, it will create "\parfirst-word" command and
+ ;; remove the first word from the contents in the PDF
+ ;; output.
+ (if (not fragilep) contents
+ (replace-regexp-in-string "\\`\n*" "\\& " contents))
+ "\\end{frame}")))
(defun org-e-beamer--format-block (headline contents info)
"Format HEADLINE as a block.