From: Michael Olson <mwolson@gnu.org>
To: emacs-orgmode@gnu.org
Subject: Re: convert region to html?
Date: Sat, 19 May 2007 22:27:35 -0400 [thread overview]
Message-ID: <87odkgmdpk.fsf@hariken.mwolson.org> (raw)
In-Reply-To: m3zm41pq67.fsf@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 1993 bytes --]
David O'Toole <dto@gnu.org> 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.
;;;###autoload
(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 #1.2: Type: application/pgp-signature, Size: 188 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2007-05-20 3:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-19 1:17 convert region to html? David O'Toole
2007-05-20 2:27 ` Michael Olson [this message]
2007-05-20 15:17 ` Carsten Dominik
2007-05-21 6:56 ` Giovanni Ridolfi
2007-05-21 15:00 ` David O'Toole
2007-05-30 13:17 ` org-blog.el updated to v1.17 David O'Toole
[not found] ` <465DB53B.3030209@calicojack.co.uk>
[not found] ` <m3myzlrwtu.fsf@gnu.org>
2007-05-31 15:34 ` org-blog.el v1.17 and org-publish-org-to-html Rick Moynihan
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=87odkgmdpk.fsf@hariken.mwolson.org \
--to=mwolson@gnu.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).