Vaidheeswaran <vaidheeswaran.chinnar...@gmail.com> writes: > What changes need to be made in ox.el and/or ox-odt.el so that the > snippet I shared produces the right XML acceptable for LibreOffice. > > text1 [fn:1] > > text2 [fn:2] > > [fn:1] footdef1[fn:2] > > [fn:2] footdef2 > > For purposes of ODT backend, we need to find the 'site of first > reference' THAT IS OUTSIDE OF A foonote definition.
I think the following should work (defun org-odt-footnote-first-reference-p (footnote-reference info) "Non-nil when FOOTNOTE-REFERENCE is the first one for its label. INFO is a plist containing current export state. Unlike to `org-export-footnote-first-reference-p', this function ignores footnote definitions. As a consequence, it assumes that for a given label, there is at least one footnote reference outside any footnote definition in the document." (let ((label (org-element-property :label footnote-reference))) (or (not label) (eq footnote-reference (org-element-map (plist-get info :parse-tree) 'footnote-reference (lambda (fn) (and (equal (org-element-property :label fn) label) fn)) info t 'footnote-definition))))) > Would it be possible for you to augment the API so that I can request > such a reference. I'd rather not change the API, as this makes an unnecessary assumption. Note that `org-export-get-footnote-number' also assumes the same. E.g. text1 [fn:foo] text2 [fn:quux] text3 [fn:bar] [fn:foo] footdeffoo[fn:bar] [fn:bar] footdefbar [fn:quux] footdefquux > NOTE: The XML that is emitted by the ODT exporter, suggests that the > '[fn:2]' occurring in '[fn:1]' is treated as site of first reference. > We would like to make '[fn:2]' occurring next to 'text2' be treated as > the site of first reference. If we do that, everything will be just > right. If the function above works for your use case, I'll install a patch in ox-odt. Regards,