From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: Exporting to multiple files Date: Thu, 13 Mar 2014 10:38:37 -0700 Message-ID: <877g7yyp5u.fsf@berkeley.edu> References: <20140309023409.15f5bd11@aga-netbook> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO9ce-0005i0-UB for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 13:40:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WO9cW-0006UZ-H1 for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 13:40:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:43610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WO9cW-0006UO-89 for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 13:40:40 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WO9cQ-0008UH-UF for emacs-orgmode@gnu.org; Thu, 13 Mar 2014 18:40:34 +0100 Received: from c-67-164-45-159.hsd1.ca.comcast.net ([67.164.45.159]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 13 Mar 2014 18:40:34 +0100 Received: from richard.lawrence by c-67-164-45-159.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 13 Mar 2014 18:40:34 +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 Cc: Marcin Borkowski Hi Marcin, 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. 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: #+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))) (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)))) (defun tex-name-to-pdf-name (filename) (concat (file-name-sans-extension filename) ".pdf")) (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))) #+END_SRC 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. -- Best, Richard