emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: ePub and Org mode


From: Richard Lawrence
Subject: [Orgmode] Re: ePub and Org mode
Date: Sun, 20 Feb 2011 17:34:40 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

"Eric Schulte" <address@hidden> writes:

>> The only thing missing is a function to export all (not excluded)
>> subtrees one by one and honor the properties slapped onto each subtree.
>>
>
> `org-map-entries' should satisfy this need. -- Eric

I have been doing something similar with LaTeX export.  Here is my
(pretty hacky) code; it should be easy to adapt to HTML export.  It
does the following:

1) export each subtree of the current tree as a separate PDF (there's
some validation here, to make sure each of these trees has properties
that I need to produce the output I want)

2) concatenates the resulting PDFs into a single PDF for printing (this
requires the pdftk package)

Good luck!

Richard

;;;;
(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
       (let ((org-trust-scanner-tags t))
         (push (get-property-or-fail (point) "EXPORT_FILE_NAME") export-files))
       (org-export-as-pdf nil))
     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))) 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]