From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Exporting to multiple files Date: Wed, 01 Oct 2014 11:20:29 +0800 Message-ID: <87oatwtr0i.fsf@ericabrahamsen.net> References: <20140309023409.15f5bd11@aga-netbook> <87mw9ghdtk.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZATM-0003Vy-2m for emacs-orgmode@gnu.org; Tue, 30 Sep 2014 23:21:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XZATG-0001hs-0s for emacs-orgmode@gnu.org; Tue, 30 Sep 2014 23:21:00 -0400 Received: from plane.gmane.org ([80.91.229.3]:58398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XZATF-0001ho-QL for emacs-orgmode@gnu.org; Tue, 30 Sep 2014 23:20:53 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XZATE-00045L-Em for emacs-orgmode@gnu.org; Wed, 01 Oct 2014 05:20:52 +0200 Received: from 114.248.29.143 ([114.248.29.143]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Oct 2014 05:20:52 +0200 Received: from eric by 114.248.29.143 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Oct 2014 05:20:52 +0200 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 Marcin Borkowski writes: > On 2014-03-09, at 02:34, Marcin Borkowski wrote: > >> Hi all, >> >> I'd like to export an Org-mode file to /multiple/ HTML files. For >> instance, I might want to convert all first and second level headings >> to files, and third-level headings to

, fourth-level ones to

>> inside these files etc. Is that possible? I looked into the docs, but >> didn't find anything like this. > > Hi all, > > I'm now coming back to this old question of mine, now a bit more > determined to actually code something (as opposed to just thinking about > it). > > One question: is it a good idea to implement my custom options, set in > the > > #+:OPTIONS > > line? If yes (that's what I assume), how to do it? I'm pretty sure there's nothing out of the box that does this. I've spent time thinking about this off and on in the past, as I've been (very slowly) chewing through a direct-to-epub export backend, and it can be nice to have multiple HTML files in the epub package. Splitting the files is a bit of a problem, but the real pain in the neck is re-writing internal links so they're still valid. I thought about using Org publishing mechanism instead of exporting, but the two systems seem pretty locked in their paradigms: publishing is many-to-many, exporting is one-to-one (or many-to-one, with includes). There's no built-in option for one-to-many. If you don't care about internal links, you'll still have to largely short-circuit the export process. You could use org-element-map to zip over the headlines, breaking off subtrees where appropriate and putting them in a temporary Org-mode buffer, using org-promote-subtree to change the depth, and then exporting the buffer to an appropriate file. Or you could go the parsed route: split the file into buffers, parse each buffer, remove top-level headings, increment the :level property of all remaining headings, and then use `org-export-data' to get the HTML. I'm sort of just thinking out loud here, I'm not sure what the best approach would be. Eric