From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 1UWmI/o6oWAnZgEAgWs5BA (envelope-from ) for ; Sun, 16 May 2021 17:32:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id OOW+Hvo6oWAEegAAB5/wlQ (envelope-from ) for ; Sun, 16 May 2021 15:32:10 +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 E763812574 for ; Sun, 16 May 2021 17:32:09 +0200 (CEST) Received: from localhost ([::1]:41500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1liIkR-0000SR-UI for larch@yhetil.org; Sun, 16 May 2021 11:32:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liIk2-0000SF-Ks for emacs-orgmode@gnu.org; Sun, 16 May 2021 11:31:42 -0400 Received: from mout01.posteo.de ([185.67.36.65]:34871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1liIjy-00023v-Fe for emacs-orgmode@gnu.org; Sun, 16 May 2021 11:31:42 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 51C15240033 for ; Sun, 16 May 2021 17:31:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1621179095; bh=xhp0tq7qdKxY2h21i9/kKsNlzyP+zmcsltXPEnYT0dw=; h=From:To:Subject:Date:From; b=h/1Rdc9uP4tDDEEWJnKIE+iK2mtsedFKZPAu0pHxUX8xZOFf6mj/+jtJqDaesfz3W goM5QspcQJ/V7mapc1+GyTvW9SmtyD1ZHTNTUx+JZUfIXlhSaRuYjQ5oePqqeYbKye 6YNQGDcFERvI1rzH8iq0vXX4nS3XC4aoB6Tai2a02BpX5Dh2xuGKGOdzF8IBpDrr7E CuOGugoV18CoBx9wia2wX+tDKCTq3j1To1yWadNQ7hwNwYCSmuUDxn654zImiZCjUd vKq5jIvSb1W8pThme8dGBInxYGu/3MIZSVUxp9vz1yE6ugkCsLXTV//AnMR657W6ct Z61Ry5rMgevaw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FjmT21y7sz9rxQ for ; Sun, 16 May 2021 17:31:34 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [Question] Custom parse tree filter Date: Sun, 16 May 2021 15:31:33 +0000 Message-ID: <87fsym3dbe.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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=1621179130; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=E/D9O4GEDV1rYhZs9uIMkVMjHfXELOePEWlkVweL+MQ=; b=OVJAQ3calrsfgkUzRvRQqZ8RQImsVNfEJchslVOJW/BayTDxK5Vb4vL3prU6OqPJTdmUlT MK/Xpv/Eufqq1J4K53F7mb2MA2RNt/Uem5iUlYCwiE5R11WYSEzD0g6k/KCTbETUQiVUlD LPxe1RtTtxQXvctLRWEvY0HuKSCdwKoVbPpvPrSXylMq3s3XnlWLEMc9HzrLSoJ6HtyQOS r/oIBWY0XQcZHrcp+02MdKXN/1SrktmjwHzwf4kEmvNk7VOgRzOmiphHOLOZXgRdKMJC4N 9GOnHs3df6OTz3ztpHAxAslozHCiEWgSFokoU2bACVP2ylXWRXaa7n3cDknX2g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621179130; a=rsa-sha256; cv=none; b=TVY6TP1Qu1AacyDxGd0fd0wxUYTiZvHjMgV6691qXsmVbAdbMG5d5uARX8p/5y/8WspWxl kFc92KvoMka234ATMcs2vuq8P/EVfYcAioAs2Jro1zi7c7ltnwMovWnWPlk0z0SyJgixxW UNL+MKN8oBSeqe78MHJgzmbSkX+QUU4v+B6h+/mvRrq0MShSz/uokAINUg2k+N3EU8aAmz ht81MPwQYM1R1bM8yx8CPi4Ed1CinejONJc9DfsDCxLLR2lgSo9Tw3FRYvx0Nsi/EOBMYl AgMkQmeifDDtMYyfZZJyCYEn4/QspXsHGZf7PXj2JmpikcBxX8zVpTSdx+R7lg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="h/1Rdc9u"; 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: -1.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="h/1Rdc9u"; 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: E763812574 X-Spam-Score: -1.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: 5UYYog0AnGfK Hi all, I am writing a custom parse tree filter that does the following (LaTeX backend): if a heading has the ':font:' property, the content of that heading is enclosed in a LaTeX group. If the property is ':fontfeature:', then the content is enclosed in a different group. The filter works fine when all the headings are at the same level. But with different levels, it does not returns the expected result. It's evident that I'm doing something catastrophically wrong :-). I wonder if anyone could put me on the track of the origin of my error... Below, the offender function and a sample. Thanks in advance! Best regards, Juan Manuel #+BIND: org-export-filter-parse-tree-functions (my-custom-filters/fontspec-headline) #+begin_src emacs-lisp :exports results :results none (defun my-custom-filters/fontspec-headline (tree backend info) (when (org-export-derived-backend-p backend 'latex) (org-element-map tree 'headline (lambda (hl) (cond ((org-element-property :FONT hl) (let* ((font (org-element-property :FONT hl)) (contents (org-element-interpret-data (org-element-contents hl))) (contents-new (concat "@@latex:{\\fontspec{@@" (replace-regexp-in-string "\s*\\(\\[.+\\]\\)\s*" "" font) "@@latex:}%@@\n" (if (string-match "\\(\\[.+\\]\\)" font) (concat "@@latex:" (match-string 1 font) "%@@\n\n") "\n") contents "\n@@latex:}@@"))) (org-element-set-contents hl (with-temp-buffer (insert contents-new) (org-element-parse-buffer))))) ((org-element-property :FONTFEATURE hl) (let* ((fontfeature (org-element-property :FONTFEATURE hl)) (contents (org-element-interpret-data (org-element-contents hl))) (contents-new (concat "@@latex:{\\addfontfeature{@@" fontfeature "@@latex:}%@@\n" contents "\n@@latex:}@@"))) (org-element-set-contents hl (with-temp-buffer (insert contents-new) (org-element-parse-buffer))))))) info) tree)) #+end_src * Minion Pro :PROPERTIES: :font: Minion Pro [Style=Historic,Color=teal] :END: Lorem ipsum dolor. ** Lowercase Numbers :PROPERTIES: :fontfeature: Numbers=Lowercase :END: Lorem ipsum dolor 1234567890. *** Letter Space :PROPERTIES: :fontfeature: LetterSpace=14.6 :END: Lorem ipsum dolor 1234567890.