emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] HTML export and heading levels


From: Bernt Hansen
Subject: [Orgmode] HTML export and heading levels
Date: Tue, 15 Jan 2008 21:05:26 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Hi Carsten and list,

I started playing with HTML export this week and since I'm lazy I don't
want to have to remember to export.  I created a few simple functions
that export my org file to HTML and copies the resulting HTML file to my
webserver when I save my org file using C-x C-s.

This works great for sharing my ToDo list and other documents with other
people.

-----8<-----

(defvar bth-publish-command "/home/bernt/bin/publish"
  "Command used to publish a document")

(defun bth-publish-buffer ()
  "Publish the document associated with the current buffer."
  (interactive)
  (cond
   ((not (buffer-file-name))
    (error "This buffer is not associated with a file"))
   ((buffer-modified-p)
    (error "Save buffer prior to publishing this document"))
   (t
    (message "Updating document..")
    (if (/= 0 (call-process bth-publish-command
                            nil nil nil
                            (buffer-file-name)))
        (error "Failed to update document")
      (message "Done.")))))

(defun bth-export-save-then-publish ()
  "Save the current buffer, export to HTML, and publish on the website"
  (interactive)
  (save-buffer)
  (org-export-as-html 2)
  (bth-publish-buffer)
  (message "Published."))

(defun bth-org-define-keys ()
  "Define C-x C-s for buffer whose filename ends with .org"
  (when (and (buffer-file-name)
             (string= (substring (buffer-file-name) -4) ".org"))
    (local-set-key "\C-x\C-s" 'bth-export-save-then-publish)))

(add-hook 'text-mode-hook 'bth-org-define-keys)

----->8-----

Now I have multiple org-mode files and they don't all have the same
structure.  I've hardcoded the HTML export to level 2 in
bth-export-save-then-publish but it would be much better to have the
export honour the org-mode file option instead.

I have the following at the top of my org files:

#+TITLE: ToDo List
#+OPTIONS: H:2 ^:nil f:nil author:nil toc:t

I tried various things but if I change the H:2 to something else (H:3,
etc) it always exports with level 2 in the table of contents when I save
the file with C-x C-s.  If I export manually with the C-c C-e h
sequences then the #+OPTIONS: heading level is used.  All of the other
#+OPTIONS seem to work fine it's just the heading level from my
(org-export-as-html 2) seems to override the file level setting.

Is there an easy fix for this?  I'm still a lisp novice.

One other thing that would be handy is a way to skip tasks in the
export.  I'm not sure if anything like that exists yet or not.  I
normally have a 

* Timelog

entry at the top of every org file which has the clock table format that
is appropriate for that file.  I really don't want that included in my
export to HTML so it would be great if there was a way to say 'skip this
heading and all sublevel headings' on export - maybe as a property or
something.

For now I've delete the Timelog tasks from the files I'm exporting to
keep the time log tables off the published version.

Thanks,
Bernt





reply via email to

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