emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Erik Hetzner <egh@e6h.org>
To: Org Mode <emacs-orgmode@gnu.org>
Subject: export to temporary HTML file and open
Date: Wed, 12 Feb 2014 18:37:27 -0800	[thread overview]
Message-ID: <87txc3ivq0.wl%egh@e6h.org> (raw)

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	other threads:[~2014-02-13  2:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txc3ivq0.wl%egh@e6h.org \
    --to=egh@e6h.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).