emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Jon Degenhardt <jondegenhardt@yahoo.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <8738kps7r0.fsf@gmail.com> (raw)
In-Reply-To: <87vbxltzg0.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Wed, 15 Jan 2014 08:35:27 +0000")

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hello,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-Fix-items-starting-with-a-square-bracket.patch --]
[-- Type: text/x-diff, Size: 2362 bytes --]

From fd99c294e2f5ae75fa5f6a23c1958bd437310d0c Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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


  reply	other threads:[~2014-01-15 13:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 21:18 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/)] Jon Degenhardt
2014-01-13  0:26 ` Vladimir Lomov
2014-01-13 16:51 ` Nicolas Goaziou
2014-01-13 23:56   ` Vladimir Lomov
2014-01-14 16:39   ` Eric S Fraga
2014-01-14 18:42     ` Nicolas Goaziou
2014-01-14 19:54       ` Eric S Fraga
2014-01-14 20:52         ` Nicolas Goaziou
2014-01-15  8:35           ` Eric S Fraga
2014-01-15 13:18             ` Nicolas Goaziou [this message]
2014-01-16  9:55               ` Eric S Fraga
2014-01-16 12:03                 ` Sebastien Vauban
2014-01-16 15:10                   ` Eric S Fraga
2014-01-16 15:15                     ` Nicolas Goaziou
     [not found]                       ` <87ha94vtyj.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-16 15:24                         ` Sebastien Vauban
2014-01-16 16:42                           ` Eric S Fraga
2014-08-03  7:57                             ` Nicolas Goaziou
2014-01-16 14:54                 ` Nicolas Goaziou
2014-01-18 20:06                   ` Jon Degenhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738kps7r0.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jondegenhardt@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).