emacs-orgmode
[Top][All Lists]
Advanced

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

[O] export to temporary HTML file and open


From: Erik Hetzner
Subject: [O] export to temporary HTML file and open
Date: Wed, 12 Feb 2014 18:37:27 -0800
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/24.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Hi all,

This may be of some interest to list members, and possibly for org
mode itself.

I find myself wanting to get a nice view of org files, for printing or
otherwise, and would like to export to HTML. But I don’t want to have
a bunch of HTML files in my org directory. Here is a hack to allow you
to export to a temporary HTML file and open in a browser, for when you
don’t want to create an HTML file in your org directory.

best, Erik

(defun org-html-export-to-temp-file
  (&optional async subtreep visible-only body-only ext-plist)
"Export current buffer to a temporary HTML file.

If narrowing is active in the current buffer, only export its
narrowed part.

If a region is active, export that region.

A non-nil optional argument ASYNC means the process should happen
asynchronously.  The resulting file should be accessible through
the `org-export-stack' interface.

When optional argument SUBTREEP is non-nil, export the sub-tree
at point, extracting information from the headline properties
first.

When optional argument VISIBLE-ONLY is non-nil, don't export
contents of hidden elements.

When optional argument BODY-ONLY is non-nil, only write code
between \"<body>\" and \"</body>\" tags.

EXT-PLIST, when provided, is a property list with external
parameters overriding Org default settings, but still inferior to
file-local settings.

Return output file's name."
  (interactive)
  (let* ((extension (concat "." org-html-extension))
         (file (make-temp-file "org-export" nil extension))
         (org-export-coding-system org-html-coding-system))
    (org-export-to-file 'html file
      async subtreep visible-only body-only ext-plist)))

(org-export-define-derived-backend 'html-temp 'html
   :menu-entry 
   '(?h 2
        ((?t "As temporary HTML file and open"
            (lambda (a s v b)
              (if a (org-html-export-to-temp-file t s v b)
                (org-open-file (org-html-export-to-temp-file nil s v b))))))))

-- 
Sent from my free software system <http://fsf.org/>.



reply via email to

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