[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Bug: Export to Latex - Incorrect output for list items starting
From: |
Nicolas Goaziou |
Subject: |
Re: [O] 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 |
Hello,
Eric S Fraga <address@hidden> writes:
> Nicolas Goaziou <address@hidden> 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
>From fd99c294e2f5ae75fa5f6a23c1958bd437310d0c Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
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
- [O] 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/12
- Re: [O] 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/)], Vladimir Lomov, 2014/01/12
- Re: [O] 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/)], Nicolas Goaziou, 2014/01/13
- Re: [O] 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/)], Vladimir Lomov, 2014/01/13
- Re: [O] 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/)], Eric S Fraga, 2014/01/14
- Re: [O] 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/)], Nicolas Goaziou, 2014/01/14
- Re: [O] 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/)], Eric S Fraga, 2014/01/14
- Re: [O] 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/)], Nicolas Goaziou, 2014/01/14
- Re: [O] 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/)], Eric S Fraga, 2014/01/15
- Re: [O] 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/)],
Nicolas Goaziou <=
- Re: [O] 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/)], Eric S Fraga, 2014/01/16
- Re: [O] 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/)], Sebastien Vauban, 2014/01/16
- Re: [O] 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/)], Eric S Fraga, 2014/01/16
- Re: [O] 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/)], Nicolas Goaziou, 2014/01/16
- Re: [O] 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/)], Sebastien Vauban, 2014/01/16
- Re: [O] 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/)], Eric S Fraga, 2014/01/16
- Re: [O] 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/)], Nicolas Goaziou, 2014/01/16
- Re: [O] 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/18