From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Reyero Subject: Re: Need help exporting subtrees to html Date: Fri, 1 Jan 2010 14:33:48 +0100 Message-ID: <55bd243d1001010533s13691049pbc31c2be6d8bcb91@mail.gmail.com> References: <55bd243d0912270834j73859a65veae0d06d39755257@mail.gmail.com> <3780C6B3-72F7-4438-8100-A307D9716857@gmail.com> <55bd243d0912271131r55927ec3w9edf16ff605f9f9c@mail.gmail.com> <773F1CE8-2EB7-4D29-BCD8-126C64EF6532@gmail.com> <55bd243d0912310550u79d37a3dia3ec509f5f04aa03@mail.gmail.com> <87tyv7f4kc.fsf@gmail.com> <55bd243d0912311002i501882fcvdb72d15b2325b7d7@mail.gmail.com> <87ljgigbw6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NQhdc-0008Ei-40 for emacs-orgmode@gnu.org; Fri, 01 Jan 2010 08:33:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NQhdX-0008E8-BA for emacs-orgmode@gnu.org; Fri, 01 Jan 2010 08:33:55 -0500 Received: from [199.232.76.173] (port=57512 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NQhdX-0008E5-5f for emacs-orgmode@gnu.org; Fri, 01 Jan 2010 08:33:51 -0500 Received: from mail-fx0-f228.google.com ([209.85.220.228]:49698) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NQhdW-00070m-Sz for emacs-orgmode@gnu.org; Fri, 01 Jan 2010 08:33:51 -0500 Received: by fxm28 with SMTP id 28so4632337fxm.26 for ; Fri, 01 Jan 2010 05:33:49 -0800 (PST) In-Reply-To: <87ljgigbw6.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: org-mode Mailing List , Carsten Dominik On Thu, Dec 31, 2009 at 8:51 PM, Eric Schulte wrot= e: > Juan Reyero writes: > >> On Thu, Dec 31, 2009 at 6:15 PM, Eric Schulte w= rote: >>> Juan Reyero writes: >>> >>>> On Thu, Dec 31, 2009 at 9:15 AM, Carsten Dominik >>>> wrote: >>>>> On Dec 27, 2009, at 8:31 PM, Juan Reyero wrote: >>>>>> On Sun, Dec 27, 2009 at 7:35 PM, Carsten Dominik >>>>>> wrote: >>>>>>> On Dec 27, 2009, at 5:34 PM, Juan Reyero wrote: >>>>>>>> I have written a function to export org-mode subtrees as jekyll po= sts, >>>>>>>> http://juanreyero.com/open/org-jekyll/ =A0The idea is that any ent= ry in >>>>>>>> an org-publish project that has a :blog: keyword and an :on: prope= rty >>>>>>>> with a timestamp should be exported to a _posts directory with the >>>>>>>> year-month-day-title.html that jekyll expects, with the properties= as >>>>>>>> front-matter. >>> If it helps, I've been doing something similar to support publishing >>> updates on the org-babel development -- using the code shown here [1] >>> under the "Development Updates" section. =A0This generates a files in >>> _posts for each subtree of of the "tasks" and "bugs" sections which hav= e >>> a time-stamp in their properties. =A0It should be fairly straightforwar= d >>> to adapt this code to export all properties as YAML frontmatter. >> >> It is exactly what I did :-). =A0I found your code here [1], and adapted >> it so that it would use files in an org-publish project and would >> export properties. > > Ah, I should have read the thread more carefully :) > >> So thank you very much for making it available. =A0It does, however, >> have the same problem I find: the header level with which the piece is >> exported (h1, h2, etc) depends on the outline level on which the item >> you export happened to be. =A0I was hoping to export the chunks >> independently of where they were written. >> > > So this turned out to be somewhat tricky. =A0I was able to adjust my > previous code so that every subtree will be promoted to a top-level > heading before export by adding the following (this change can also be > seen in my published code here [1]). > > --8<---------------cut here---------------start------------->8--- > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(org-narrow-to-subtree) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(let ((level (- (org-outline-level) 1)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(contents (buffer-substring (p= oint-min) (point-max)))) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(dotimes (n level nil) (org-promote-su= btree)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq html (org-export-as-html nil nil= nil 'string t nil)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(set-buffer org-buffer) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(delete-region (point-min) (point-max)= ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(insert contents) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(save-buffer)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(widen) > --8<---------------cut here---------------end--------------->8--- It works! Thank you _very_ much. I've just had to add a org-reduced-level to the org-outline-level, like (org-reduced-level (org-outline-level)). I've updated it in github and on http://juanreyero.com/open/org-jekyll/, and I'll try to add something to worg this afternoon. Best, Juan > Footnotes: > [1] =A0http://eschulte.github.com/babel-dev/publish.html --=20 http://juanreyero.com/ http://unarueda.com