emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Exporting to single LaTeX file and multiple HTML files


From: David Maus
Subject: Re: [Orgmode] Exporting to single LaTeX file and multiple HTML files
Date: Fri, 07 May 2010 20:55:44 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Ulf Stegemann wrote:
>I'm wondering what's the best way to export a single org file to a
>/single/ LaTeX file but also to /multiple/ HTML files. Think of lengthy
>manuals and things like that where such a strategy may be sensible. What
>came to my mind were include commands or publishing functions that
>post-process the export but this seems all rather cumbersome. Has anyone
>a better idea?

The function below could be a starting point of a more general
functionality: It takes a file and splits copys all headlines with a
certain level to a separate output file.

The more general functionality I am thinking of would be: Create
multiple output files for one or more input files that contain
headlines that match a certain criteria.

E.g.: Create output file "TODO.org" with all headlines with todo
keyword TODO or put all files with the tag "tag" into a output file
"tag.org" etc.

Things to consider:

  - escape sequences for output file names
    ("%number" -> counter, "%tag" -> tag etc.)

  - functions to move headline from here to there
    (copy, cut, cut and insert link)

  - maybe provide template for the output file's in file options
    (e.g. #+TITLE etc.)

For the splitting-by-level there is one caveat: The numbering of the
headlines is lost.

Definitively something that should be cooked up a little more.

,----
| (defun org-split-file (file level outfmt)
|   "Split FILE into multiple files.
| FILE is Org file to split.
| LEVEL is outline level of headlines.
| OUTFMT is a template for output files."
|   (let ((visiting (find-buffer-visiting file))
|         (cnt 1)
|         cand hl out)
|     (with-current-buffer (or visiting (find-file-noselect file))
|       (save-excursion
|         (save-restriction
|           (setq cand (org-map-entries 'point
|                                       (format "LEVEL=%s" level)
|                                       'file))
|           (while (setq hl (pop cand))
|             (goto-char hl)
|             (setq out (concat
|                        (org-replace-escapes outfmt
|                                             `(("%n" . ,(format "%s" cnt))))
|                        ".org"))
|             (org-copy-subtree)
|             (with-current-buffer (find-file-noselect out)
|               (erase-buffer)
|               (org-paste-subtree level)
|               (save-buffer))
|             (kill-buffer (find-buffer-visiting out))
|             (setq cnt (1+ cnt))
|             (print out)))))))
`----

HTH
 -- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... address@hidden
Email..... address@hidden

Attachment: pgpVnb0zEIDSB.pgp
Description: PGP signature


reply via email to

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