From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 64y3OpnTcmHuAwEAgWs5BA (envelope-from ) for ; Fri, 22 Oct 2021 17:07:05 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8NkjNZnTcmF/HgAA1q6Kng (envelope-from ) for ; Fri, 22 Oct 2021 15:07:05 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4132A2E563 for ; Fri, 22 Oct 2021 17:07:05 +0200 (CEST) Received: from localhost ([::1]:34088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdw8O-0000WR-Bf for larch@yhetil.org; Fri, 22 Oct 2021 11:07:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdw35-00036d-Sy for emacs-orgmode@gnu.org; Fri, 22 Oct 2021 11:01:35 -0400 Received: from mout02.posteo.de ([185.67.36.66]:45391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdw32-0007Wd-KW for emacs-orgmode@gnu.org; Fri, 22 Oct 2021 11:01:34 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 39808240105 for ; Fri, 22 Oct 2021 17:01:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1634914886; bh=w6Aph2taxZdZ6bBW07vV3XgNSoqi0tS2y9Pww7JW4lU=; h=From:To:Subject:Date:From; b=FaCFBA4TRuOea59m0+GAxxge0afoGPl2WI4e5Cc4Mn0jfksAwmG9H+TfDKRtIR0RR pzoL7XgAT2i5P9VfAyV/4Llit7Nm1xuAKjywzT1jpJAOk00/R5AiTDQ4dmTKvwZ7SH ztmC0vjWQxGJwzwF5yBLKw1jkKjnaV2JIby3lIai3ovIVTg++qsIpeaLpoHZ/5SSpJ YTWKiA9gBwqFPFNb7dO+CbS07LF0pQA2ruV1+yvDsKzm4PtVweDneJV5nsFY/2qdiJ hcuWSgTWNT7rGOjuLXSZMaRdT72IDDkrD/VHHfk7azsFcawgsLZWpbOt8zpKBrJqQ6 gDiU53/yJkGcA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HbSGs5Tbpz9rxN for ; Fri, 22 Oct 2021 17:01:25 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [tip] Export some footnotes as pdf annotations (LaTeX) or comments (odt) Date: Fri, 22 Oct 2021 15:01:24 +0000 Message-ID: <877de55cjf.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634915225; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=eD8w/YQjCWYJZWUBzLIsHscYPJh9u3i+CGTxtYzyW6s=; b=nSFJgVfmpZ770dWbYc/ISn+LrPJAV7/5Y6EmfFcClZl4Mc4ldkcN9PPBnoqD8jVj4dkszb vbw8TL3P6huS6AxfDagzcuRCKFvDtMEQDPk3HUAUHbIp9gbtFXp6LL5ou5X3Ecxv5JuS43 bwFgMyUioN5ws4VN1TnM/KAehjw6O3/3CBtrd8KUW3TOmyqtbfH/MMt7FAk4I/qflDEFnW eFHllbeZ9Fz3fhWEsU0ijEFLi18Ia9gCFX52qF+nVDh4qh9PYdoJ7fIk+y9mihsWtKLJ/6 EY12jrRdmOuzQQR29eNPpdpPij6QXaZ224f2hU4izcCS9/Bv3+twqdJEvFQ9xw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634915225; a=rsa-sha256; cv=none; b=LOUD3asYbb8QUeoF/5FA67o809Z7chtlL3XOwpm05FPZmdFnznc/b9wfd6KGPj1zBmkxiu Ac9LGl3WOWSyWRuUS/x9sPazwMWZfQDv5VqhCavTacLgtKG1SLvkaZNd9dOJql5JxB9rmw tQa1S3zaT4tQ6WNYMDRFhUSyHUmVV4PD5hB4UHKiAir0Bssg3EtDp09pWns9xXFSRyyUtQ OasNKyhM6RWObtRnMMZ7ulNf0j34xY22KdyDTJFLcDT6PuA1zo9R4XirScXtDGIiNF4669 h1QHBnvaHVjt0lJ56kKSO7aC7CdNKuY65UpjqUkKIiC3V2Bn091VOALFEifzTg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FaCFBA4T; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FaCFBA4T; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 4132A2E563 X-Spam-Score: -3.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: wrGLBdVQZuXh Hi, 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/e= xport-footnote-as-annotation) #+begin_src emacs-lisp :exports results :results none (defun my-custom-filters/export-footnote-as-annotation (text backend info) (interactive) (cond ((and (org-export-derived-backend-p backend 'latex) (string-match-p "!annot" text)) (replace-regexp-in-string "\\\\footnote{\s*!annot\s*" "\\\\pdfcomment[icon=3DNote,opacity=3D= 0.4,color=3Dgray,date]{" text)) ((and (org-export-derived-backend-p backend 'odt) (string-match-p "!annot" text)) (with-temp-buffer (insert text) (let* ((from (save-excursion (goto-char (point-min)) (re-search-forward "!annot" nil t) (point))) (to (save-excursion (goto-char from) (re-search-forward "" nil t) (- (point) 9))) (contents (buffer-substring-no-properties from to))) (delete-region (point-min) (point-max)) (insert (concat "" (car (plist-get info :author)) "" ;; date in iso format (org-odt--format-timestamp (plist-get info :date) n= il t) "" contents " ")) (setq text (buffer-string))))))) #+end_src Example: 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 filter): #+BIND: org-export-filter-footnote-reference-functions (my-custom-filters/d= isable-footnote-as-annotation) #+begin_src emacs-lisp :exports results :results none (defun my-custom-filters/disable-footnote-as-annotation (text backend inf= o) (interactive) (cond ((and (org-export-derived-backend-p backend 'latex) (string-match-p "!noannot" text)) (replace-regexp-in-string ".+" "" text)) ((and (org-export-derived-backend-p backend 'odt) (string-match-p "!noannot" text)) (replace-regexp-in-string ".+" "" text)))) #+end_src Best regards, Juan Manuel -- -- ------------------------------------------------------ Juan Manuel Mac=C3=ADas -- https://juanmanuelmacias.com/