emacs-humanities
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-humanities] Footnote on author


From: Marvin Gülker
Subject: Re: [emacs-humanities] Footnote on author
Date: Tue, 23 Jan 2024 18:13:43 +0100

Am Dienstag, dem 23. Januar 2024 schrieb Marvin Gülker:
> Notice how LibreOffice has appended the footnote *after*
> </text:initial-creator>, whereas the macro trick inserted the footnote
> *inside* that XML element. How can I get it to insert the footnote
> *after* </text:initial-creator>?

I dug into the source code of ox-odt.el and found that this is not
possible easily; the structure of the document beginning is hardcoded in
the (huge) function `org-odt-template'. However, Emacs would not be
Emacs if that was the end of it. I wrote an advice that "fixes" the
problem by moving the "</text:initial-creator>" before the footnote:

--8<---------------cut here---------------start------------->8---
(defun my/footnote (str)
  (with-temp-buffer
    (insert str)
    (goto-char (point-min))
    (if (search-forward "<text:note text:id=\"authorfn\"" nil t)
        (progn
          (backward-char 29) ;; 29 = length of search string
          (insert "</text:initial-creator>")
          (search-forward "</text:initial-creator>" nil)
          (delete-region (- (point) 23) (point)) ;; 23 = length of search string
          (buffer-substring (point-min) (point-max)))
      str)))

(advice-add 'org-odt-template :filter-return #my/footnote)
--8<---------------cut here---------------end--------------->8---

Think what you want, but it works. The advice picks up the XML inserted
with the `authorfn' macro I presented in the parent message.

I however agree that this is not a clean way to approach the problem,
but for the time being, I can live with this workaround.

    Marvin

-- 
Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
Passau, Deutschland  | kontakt@guelker.eu    | O<



reply via email to

[Prev in Thread] Current Thread [Next in Thread]