From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Allen S. Rout" Subject: More export filter examples out there? Date: Tue, 17 Mar 2015 18:15:49 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXzmw-0007Ik-4A for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 18:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXzms-00049h-25 for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 18:16:38 -0400 Received: from plane.gmane.org ([80.91.229.3]:34421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXzmr-00049Z-Qc for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 18:16:33 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YXzmm-0004zH-EX for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 23:16:28 +0100 Received: from host-128-227-138-22.xlate.ufl.edu ([128.227.138.22]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Mar 2015 23:16:28 +0100 Received: from asr by host-128-227-138-22.xlate.ufl.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 17 Mar 2015 23:16:28 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I'm trying to accomplish a custom export task which I'd hoped to be pretty simple: something like: In each status section, only export the first child headline. After several dumb ideas, I decided that doing it with a filter was probably the Right Place. I built a filter intended to be used on :filter-parse-tree and attempted to express: If you're parent is a headline and your parent's title is 'Status' and you're not the first of your siblings then don't be included. I've added my malfunctioning filter below,to clearly display my "thinking". I don't seem to be able to get the title as a string. org-export-data seems to expect a different 'info' than the 'info' present at filter time. I get complaints about org-export-data: Wrong type argument: hash-table-p, nil if I uncomment the attempt to string compare the title. I'm finding my experience with XSLT to be a handicap; I bring expectations to the table that are misguided. Is there a pretty-printer or other dump for the export parse tree? The dump I sometimes get in *Messages* is not all that readable. Should I be thinking of this as a parse-table operation, or should I be reasoning about it from :filter-headline? More generally, anyone got some art for some similar reconstruction they've done, which they might like to share? - Allen S. Rout (defun ox-asr-only-first-status ( tree backend info ) " Arrange that, under headlines marked 'Status', only the first of them is included. " ( org-element-map tree (remq 'item org-element-all-elements) ( lambda (e) ( let* ( ( parent ( org-element-property :parent e) ) ( first-sib ( car (org-element-contents parent ))) ( parent-type ( org-element-type parent )) ( parent-title ( org-element-property :title e)) ; ( pt-string ( org-export-data parent-title info )) ) (if (and ( eq parent-type 'headline ) ( not (eq e first-sib )) ; ( string= (org-export-data parent-title) "Status") ) ( org-element-set-contents e "-->" parent-title "<--- " (org-element-contents e)) ) ) ) ) tree )