[Top][All Lists]

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

[Orgmode] Re: convert region to html?

From: Michael Olson
Subject: [Orgmode] Re: convert region to html?
Date: Sat, 19 May 2007 22:27:35 -0400
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.0.98 (gnu/linux)

David O'Toole <address@hidden> writes:

> I am working on my blog extension for org-publish. I would like to
> convert a region of text (say, between two markers) from org-mode
> markup into html and then paste the resulting html into another buffer
> where I am building a full page. I need to do this from a lisp
> program. It says that org-export-as-html will export an active region
> but I tried it and it doesn't work in a temp-buffer where
> (buffer-file-name) is nil. Anyway, would it be hard to expose a
> function like the following?
> (defun org-export-region-to-html (beg end)
>   "Convert region between BEG and END into HTML, placing the result
>   into a new buffer. The new buffer is returned."
>   ...
>   ...

I did something similar for Muse recently.  I'm including the code
snippet in case it comes in handy.

(defun muse-publish-region (beg end &optional title style)
  "Apply the given STYLE's markup rules to the given region.
The result is placed in a new buffer that includes TITLE in its name."
  (interactive "r")
  (when (interactive-p)
    (unless title (setq title (read-string "Title: ")))
    (unless style (setq style (muse-publish-get-style))))
  (let ((muse-publishing-current-style style)
        (muse-publishing-p t)
        (text (buffer-substring beg end))
        (buf (generate-new-buffer (concat "*Muse: " title "*"))))
    (with-current-buffer buf
      (insert text)
      (muse-publish-markup-buffer title style)
      (goto-char (point-min))
      (let ((inhibit-read-only t))
        (remove-text-properties (point-min) (point-max)
                                '(rear-nonsticky nil read-only nil))))
    (pop-to-buffer buf)))

       Michael Olson -- FSF Associate Member #652     |
 http://mwolson.org/ -- Jabber: mwolson_at_hcoop.net  |  /` |\ | | |
            Sysadmin -- Hobbies: Lisp, GP2X, HCoop    | |_] | \| |_|
Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |

Attachment: pgpQ1qUaCqULP.pgp
Description: PGP signature

reply via email to

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