emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas <n.goaziou@gmail.com>
To: Rainer M Krug <r.m.krug@gmail.com>
Cc: Lawrence Mitchell <wence@gmx.li>, emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-latex: Don't append newline to end of footnote
Date: Thu, 31 Mar 2011 00:06:20 +0200	[thread overview]
Message-ID: <878vvwe00z.fsf@gmail.com> (raw)
In-Reply-To: <4D934249.5020602@gmail.com> (Rainer M. Krug's message of "Wed, 30 Mar 2011 16:46:33 +0200")

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

Hello,

Rainer M Krug <r.m.krug@gmail.com> writes:

> Additional information: I changed to 7.5 (released version) and it works
> there as expected.
>
> Rainer
>
>
> On 30/03/11 11:14, Lawrence Mitchell wrote:
>> Nicolas wrote:
>>> Hello,
>> 
>>> Lawrence Mitchell <wence@gmx.li> writes:
>> 
>> 
>> [...]
>> 
>>> The analysis is good, but unfortunately the patch has a flaw.
>> 
>>> In fact, your patch work in that particular situation, but not if
>>> a footnote definition ends with a list, nor if it ends with a link. To
>>> solve the latter, you need to insert a white-space before the closing
>>> bracket. To solve the former, I thought adding a newline instead of the
>>> white-space was enough, but it now appears it was a bad idea.
>> 
>>> Thus, the solution lies elsewhere.
>> 
>> Ugh, indeed.  I wonder whether it would be enough to add the
>> correct list indent to the beginning of the line with the closing
>> brace.
>> 
>> ALthough I notice without my patch, the export of a footnote
>> containing a list which is in a list also does not work:
>> 
>> - Hello [fn:1]
>> 
>> * Footnotes
>> 
>> [fn:1] Goodbye
>>        - an item
>> 
>> No idea how to fix this though, sorry.

Would the attached patch work ? I've tested it successfully on the
following buffer:

--8<---------------cut here---------------start------------->8---
#+title: Test footnotes

* Titre

  Text [fn:1] and a list
  - [fn:2]
  - three
    
    
  Another try [fn:3]

* Footnotes

[fn:1] A definition with
  - a list
  - of two elements

[fn:2] Test

[fn:3] [[file:~/.bashrc][bashrc]]
--8<---------------cut here---------------end--------------->8---

Regards,

-- 
Nicolas


[-- Attachment #2: footnote patch --]
[-- Type: text/plain, Size: 1607 bytes --]

From ccba9a10dddffb805635ecc10e760e92bf6ca8d2 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Wed, 30 Mar 2011 23:52:33 +0200
Subject: [PATCH] org-latex: fix footnotes wrt lists and links

* lisp/org-latex.el: pay attention to end of footnote. Before closing
  the command, ensure that list is properly closed or that last link
  is separated from the curly brace.
---
 lisp/org-latex.el |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index e42b64d..47fdfa7 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2418,12 +2418,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 		 (replace-match (org-export-latex-protect-string
 				 (concat "$^{" (match-string 1) "}$")))
 	       (replace-match "")
-	       (let ((end (save-excursion
-			    (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
-				(match-beginning 0) (point-max)))))
-		 (setq footnote (concat (org-trim (buffer-substring (point) end))
-					; last } won't be part of a link or list.
-					"\n"))
+	       (let* ((end (save-excursion
+			     (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
+				 (match-beginning 0) (point-max))))
+		      (body (org-trim (buffer-substring (point) end))))
+		 ;; Fix for footnotes ending on a link or a list.
+		 (setq footnote
+		       (concat body
+			       (if (string-match "ORG-LIST-END-MARKER\\'" body)
+				   "\n" " ")))
 		 (delete-region (point) end))
 	       (goto-char foot-beg)
 	       (delete-region foot-beg foot-end)
-- 
1.7.4.2


      reply	other threads:[~2011-03-30 22:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-29 13:09 [BUG] LaTeX export inserts "ORG-LIST-END-MARKER" Rainer M Krug
2011-03-29 14:20 ` [PATCH] org-latex: Don't append newline to end of footnote Lawrence Mitchell
2011-03-29 17:38   ` Nicolas
2011-03-30  7:49     ` Rainer M Krug
2011-03-30  9:14     ` Lawrence Mitchell
2011-03-30 14:46       ` Rainer M Krug
2011-03-30 22:06         ` Nicolas [this message]

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=878vvwe00z.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=r.m.krug@gmail.com \
    --cc=wence@gmx.li \
    /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).