From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [bug, patch, ox] INCLUDE and footnotes Date: Tue, 09 Dec 2014 20:14:37 +0100 Message-ID: <87oarcbppe.fsf@nicolasgoaziou.fr> References: <87h9x5hwso.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyQEH-000234-Q7 for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 14:13:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyQEB-0001Ro-Re for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 14:13:49 -0500 Received: from relay6-d.mail.gandi.net ([2001:4b98:c:538::198]:53116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyQEB-0001Ri-L7 for emacs-orgmode@gnu.org; Tue, 09 Dec 2014 14:13:43 -0500 In-Reply-To: <87h9x5hwso.fsf@gmx.us> (rasmus@gmx.us's message of "Tue, 09 Dec 2014 12:44:55 +0100") 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: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus writes: > When using LINES in `org-export--prepare-file-contents' the footnotes > section is not preserved causing export to fail. > > Minimal example > > $> cat t{1,2}.org > # this is t1.org > * intro > foo[fn:1] > * sec2 > bar > * Footnotes > > [fn:1] baz > > > # this is t2.org > #+INCLUDE: "./t1.org::#intro" > > And export t2.org. > > The attached patch fixes this by explicitly saving the footnote section > > (Aside: org-footnote-section is used in hackish ways; should we make a > function that returns to correct regexp for the footnotes section?). > > It works in a rather large document of mine and in the minimal test. > > Should I apply it, or is there a better way to fix this bug? Thanks for the patch. However, it is incorrect. First `org-footnote-section' could be nil, in which case there is no headline to look after. Also, there may be multiple footnote sections in the included document, or even some footnote definitions inside and some outside the single section... Eventually, you are inserting a headline in the source document, which could break its structure (e.g., if you're only inserting a table). You should only extract the definitions associated to the references within the included part of the document. However, you cannot insert them right after the included text, as it could break the surrounding environment, e.g., - item #+INCLUDE: some-table.org A possible solution would be to somehow postpone insertion of footnotes at the very end of the source document, not at the location of the keyword. However it would need some testing. Regards, -- Nicolas Goaziou