From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Borkowski Subject: Re: Exporting to multiple files Date: Sat, 15 Mar 2014 12:13:53 +0100 Message-ID: <20140315121353.11b9a197@aga-netbook> References: <20140309023409.15f5bd11@aga-netbook> <877g7yyp5u.fsf@berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOmXS-0005EH-7f for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 07:14:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOmXM-0003aQ-5F for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 07:14:02 -0400 Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:50769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOmXL-0003Zi-Pu for emacs-orgmode@gnu.org; Sat, 15 Mar 2014 07:13:56 -0400 Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 4ECE84206B for ; Sat, 15 Mar 2014 12:13:55 +0100 (CET) Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BFGQWwJwYkJR for ; Sat, 15 Mar 2014 12:13:55 +0100 (CET) Received: from aga-netbook (99-234.echostar.pl [213.156.99.234]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 158E942066 for ; Sat, 15 Mar 2014 12:13:55 +0100 (CET) In-Reply-To: <877g7yyp5u.fsf@berkeley.edu> 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 Dnia 2014-03-13, o godz. 10:38:37 Richard Lawrence napisa=C5=82(a): > Hi Marcin, >=20 > Marcin Borkowski writes: > > > > 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. >=20 > I once wrote a function that does something like this. (I haven't > used it since the pre-8.0 days, though, so it probably needs > updating.) It creates individual PDFs from the subtrees under a > headline, then concatenates them into one PDF using an external > program (pdftk). Naming is done based on the EXPORT_FILE_NAME > property as usual. Maybe you can use it as a skeleton: >=20 > #+BEGIN_SRC elisp > ;; utilities for exporting the subtrees of a tree as individual PDFS > ;; and as a single, concatenated PDF > (defun org-export-individual-pdfs-and-concat () > (interactive) > (setq export-files nil > pdf-files nil > ; point must be in main tree to be exported (not a subtree) > concat-pdf-name (get-property-or-fail (point) > "CONCATENATED_PDF_NAME")) (progn > (org-map-entries > (lambda () > (setq org-map-continue-from (outline-next-heading)) > (org-mark-subtree) > ; org-map-entries positions point at the beginning of each > subtree (if org-map-continue-from ; non-nil if outline-next-heading > found a heading (let ((org-trust-scanner-tags t)) > (push (get-property-or-fail (point) "EXPORT_FILE_NAME") > export-files))) (mapcar 'message (org-get-tags)) > (org-export-as-pdf nil)) ; TODO: why doesn't this respect > noexport tag? nil 'tree) > (concat-pdfs (nreverse (mapcar 'tex-name-to-pdf-name > export-files)) concat-pdf-name))) >=20 > (defun get-property-or-fail (pom property) > (or > ; probably some opportunity for optimization here...see function > ; documentation for org-map-entries > (org-entry-get pom property) > (error (format "Entry at %s does not define property > %s" (org-heading-components) property)))) >=20 > (defun tex-name-to-pdf-name (filename) > (concat (file-name-sans-extension filename) ".pdf")) >=20 > (defun concat-pdfs (in-files out-file) > (shell-command > (format "pdftk %s cat output %s" > (mapconcat (lambda (s) s) in-files " ") ; join pdf names > with spaces out-file))) >=20 > #+END_SRC >=20 > Another option that occurs to me -- though it may not serve your needs > -- is to export your Org file to texinfo format. I believe the > texinfo compiler can then generate separate separate HTML files for > the different sections in your .texi file. Might be worth a try. > =20 Thanks a lot! Your code seems inspiring - I've only skimmed through it now, but e.g. the org-map-entries is something very useful I had no idea existed... Best, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University