emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [tip] Export some footnotes as pdf annotations (LaTeX) or comments (odt)
@ 2021-10-22 15:01 Juan Manuel Macías
  0 siblings, 0 replies; only message in thread
From: Juan Manuel Macías @ 2021-10-22 15:01 UTC (permalink / raw)
  To: orgmode


Sometimes I need to export an Org document with certain "meta-comments",
so I wrote this export filter to export those footnotes that start with
the string "!annot" to:

- [LaTeX] PDF annotations (requires the pdfcomment LaTeX package),

- [odt] Comments.

#+BIND: org-export-filter-footnote-reference-functions (my-custom-filters/export-footnote-as-annotation)
#+begin_src emacs-lisp :exports results :results none
  (defun my-custom-filters/export-footnote-as-annotation (text backend info)
    (cond ((and (org-export-derived-backend-p backend 'latex)
                (string-match-p "!annot" text))
           (replace-regexp-in-string "\\\\footnote{\s*!annot\s*"
          ((and (org-export-derived-backend-p backend 'odt)
                (string-match-p "!annot" text))
             (insert text)
             (let* ((from (save-excursion
                            (goto-char (point-min))
                            (re-search-forward "!annot" nil t)
                    (to (save-excursion
                          (goto-char from)
                          (re-search-forward "</text:p>" nil t)
                          (- (point) 9)))
                    (contents (buffer-substring-no-properties from to)))
               (delete-region (point-min) (point-max))
               (insert (concat
                        "<office:annotation loext:resolved=\"false\"><dc:creator>"
                        (car (plist-get info :author))
                        ;; date in iso format
                        (org-odt--format-timestamp (plist-get info :date) nil t)
                        "</dc:date><text:p text:style-name=\"P5\"><text:span text:style-name=\"T1\">"
                        "</text:span></text:p></office:annotation> "))
               (setq text (buffer-string)))))))


Lorem[fn:1] ipsum dolor sit amet,

[fn:1] !annot This note will be exported as an annotation...

And this other filter does not export the notes that start with the
string "!noannot" (although it could be merged with the previous

#+BIND: org-export-filter-footnote-reference-functions (my-custom-filters/disable-footnote-as-annotation)
#+begin_src emacs-lisp :exports results :results none
  (defun my-custom-filters/disable-footnote-as-annotation (text backend info)
    (cond ((and (org-export-derived-backend-p backend 'latex)
                (string-match-p "!noannot" text))
           (replace-regexp-in-string ".+"
          ((and (org-export-derived-backend-p backend 'odt)
                (string-match-p "!noannot" text))
           (replace-regexp-in-string ".+"

Best regards,

Juan Manuel

Juan Manuel Macías --


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-22 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 15:01 [tip] Export some footnotes as pdf annotations (LaTeX) or comments (odt) Juan Manuel Macías

Code repositories for project(s) associated with this public inbox


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).