From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Bug: Export to Latex - Incorrect output for list items starting with left bracket [8.2.3c (8.2.3c-elpa @ /Users/jdegenhardt/.emacs.d/elpa/org-20131115/)] Date: Wed, 15 Jan 2014 14:18:59 +0100 Message-ID: <8738kps7r0.fsf@gmail.com> References: <1389475109.23348.YahooMailNeo@web184706.mail.ne1.yahoo.com> <87sisrkepy.fsf@gmail.com> <87lhyiv7pt.fsf@ucl.ac.uk> <87zjmyl80v.fsf@gmail.com> <87d2jubaqg.fsf@ucl.ac.uk> <87mwiyl20n.fsf@gmail.com> <87vbxltzg0.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3QMw-0005hK-Jv for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 08:18:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3QMr-0005ai-7D for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 08:18:54 -0500 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]:41366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3QMr-0005aZ-0b for emacs-orgmode@gnu.org; Wed, 15 Jan 2014 08:18:49 -0500 Received: by mail-wg0-f52.google.com with SMTP id b13so1749878wgh.19 for ; Wed, 15 Jan 2014 05:18:48 -0800 (PST) In-Reply-To: <87vbxltzg0.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Wed, 15 Jan 2014 08:35:27 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jon Degenhardt Cc: "emacs-orgmode@gnu.org" --=-=-= Content-Type: text/plain Hello, Eric S Fraga writes: > Nicolas Goaziou writes: > >> I'd like to fix it, yes. It will not help you with older documents, but >> what do you think about the export snippet exception I suggested? > > Sorry, I didn't get back to you on this. Although obviously more > cumbersome than my current approach, your suggestion would cover my main > use case *and* from org's point of view would be much more "honest". I > would be happy with this. So, here comes another patch. WDYT? Regards, -- Nicolas Goaziou --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-latex-Fix-items-starting-with-a-square-bracket.patch >From fd99c294e2f5ae75fa5f6a23c1958bd437310d0c Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 13 Jan 2014 17:48:19 +0100 Subject: [PATCH] ox-latex: Fix items starting with a square bracket * lisp/ox-latex.el (org-latex-headline, org-latex-item): Fix items starting with a square bracket. Thanks to Jon Degenhardt, Vladimir Lomov and Eric S Fraga for contributing to the discussion. --- lisp/ox-latex.el | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 8294938..8842923 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1374,7 +1374,13 @@ holding contextual information." (when (org-export-first-sibling-p headline info) (format "\\begin{%s}\n" (if numberedp 'enumerate 'itemize))) ;; Itemize headline - "\\item " full-text "\n" headline-label pre-blanks contents))) + "\\item" + (and full-text (org-string-match-p "\\`[ \t]*\\[" full-text) + "\\relax") + " " full-text "\n" + headline-label + pre-blanks + contents))) ;; If headline is not the last sibling simply return ;; LOW-LEVEL-BODY. Otherwise, also close the list, before ;; any blank line. @@ -1564,7 +1570,25 @@ contextual information." (and tag (format "[{%s}] " (concat checkbox (org-export-data tag info))))))) - (concat counter "\\item" (or tag (concat " " checkbox)) + (concat counter + "\\item" + (cond + (tag) + (checkbox (concat " " checkbox)) + ;; Without a tag or a check-box, if CONTENTS starts with + ;; an opening square bracket, add "\relax" to "\item", + ;; unless the brackets comes from an initial export + ;; snippet (i.e. it is inserted willingly by the user). + ((and contents + (org-string-match-p "\\`[ \t]*\\[" contents) + (not (let ((e (car (org-element-contents item)))) + (and (eq (org-element-type e) 'paragraph) + (let ((o (car (org-element-contents e)))) + (and (eq (org-element-type o) 'export-snippet) + (eq (org-export-snippet-backend o) + 'latex))))))) + "\\relax ") + (t " ")) (and contents (org-trim contents)) ;; If there are footnotes references in tag, be sure to ;; add their definition at the end of the item. This -- 1.8.5.2 --=-=-=--