From 6dbd132e62c0305ce021d550ea66268e0497f80d Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 13 Apr 2021 00:27:45 +0200 Subject: [PATCH] ox-texinfo: Fix footnotes ending on a special environment * lisp/ox-texinfo.el (org-texinfo-footnote-reference): Prevent a footnote from ending on an "@end" line. Reported-by: Ramesh Nedunchezian --- lisp/ox-texinfo.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 52c8180b4..ece0ef4d8 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -846,9 +846,17 @@ CONTENTS is nil. INFO is a plist holding contextual information." FOOTNOTE is the footnote to define. CONTENTS is nil. INFO is a plist holding contextual information." - (let ((def (org-export-get-footnote-definition footnote info))) + (let* ((contents (org-export-get-footnote-definition footnote info)) + (data (org-export-data contents info))) (format "@footnote{%s}" - (org-trim (org-export-data def info))))) + ;; It is invalid to close a footnote on a line starting + ;; with "@end". As a safety net, we leave a newline + ;; character before the closing brace. However, when the + ;; footnote ends with a paragraph, it is visually pleasing + ;; to move the brace right after its end. + (if (eq 'paragraph (org-element-type (org-last contents))) + (org-trim data) + data)))) ;;;; Headline