emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* HTML export and heading levels
@ 2008-01-16  2:05 Bernt Hansen
  2008-01-16  2:42 ` Bastien
  2008-01-17 13:49 ` Bernt Hansen
  0 siblings, 2 replies; 5+ messages in thread
From: Bernt Hansen @ 2008-01-16  2:05 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-17 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-16  2:05 HTML export and heading levels Bernt Hansen
2008-01-16  2:42 ` Bastien
2008-01-16  5:06   ` Bernt Hansen
2008-01-17 13:49 ` Bernt Hansen
2008-01-17 15:02   ` William Henney

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).