From: Richard Lawrence <richard.lawrence@berkeley.edu>
To: emacs-orgmode@gnu.org
Cc: Marcin Borkowski <mbork@wmi.amu.edu.pl>
Subject: Re: Exporting to multiple files
Date: Thu, 13 Mar 2014 10:38:37 -0700 [thread overview]
Message-ID: <877g7yyp5u.fsf@berkeley.edu> (raw)
In-Reply-To: 20140309023409.15f5bd11@aga-netbook
Hi Marcin,
Marcin Borkowski <mbork@wmi.amu.edu.pl> 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 <h1>, fourth-level ones to <h2>
> 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
next prev parent reply other threads:[~2014-03-13 17:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-09 1:34 Exporting to multiple files Marcin Borkowski
2014-03-09 9:34 ` Marcin Borkowski
2014-03-13 11:59 ` Bastien
2014-03-15 11:11 ` Marcin Borkowski
2014-03-13 13:11 ` Fabrice Popineau
2014-03-13 17:38 ` Richard Lawrence [this message]
2014-03-15 11:13 ` Marcin Borkowski
2014-04-06 20:45 ` Sacha Chua
2014-04-07 13:45 ` Iannis Zannos
2014-09-30 23:46 ` Marcin Borkowski
2014-10-01 3:20 ` Eric Abrahamsen
2014-10-01 12:44 ` Nicolas Goaziou
2014-10-01 14:07 ` Marcin Borkowski
2014-10-01 15:00 ` Nicolas Goaziou
2014-10-01 17:17 ` Eric Abrahamsen
2014-10-01 19:12 ` Nicolas Goaziou
2014-10-02 3:22 ` Eric Abrahamsen
2014-10-01 9:25 ` Rasmus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877g7yyp5u.fsf@berkeley.edu \
--to=richard.lawrence@berkeley.edu \
--cc=emacs-orgmode@gnu.org \
--cc=mbork@wmi.amu.edu.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.