emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* convert region to html?
@ 2007-05-19  1:17 David O'Toole
  2007-05-20  2:27 ` Michael Olson
  2007-05-20 15:17 ` Carsten Dominik
  0 siblings, 2 replies; 7+ messages in thread
From: David O'Toole @ 2007-05-19  1:17 UTC (permalink / raw)
  To: emacs-orgmode


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."
  ...
  ...
      

-- 
David O'Toole 
dto@gnu.org
http://dto.freeshell.org/notebook/

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

* Re: convert region to html?
  2007-05-19  1:17 convert region to html? David O'Toole
@ 2007-05-20  2:27 ` Michael Olson
  2007-05-20 15:17 ` Carsten Dominik
  1 sibling, 0 replies; 7+ messages in thread
From: Michael Olson @ 2007-05-20  2:27 UTC (permalink / raw)
  To: emacs-orgmode


[-- 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

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

* Re: convert region to html?
  2007-05-19  1:17 convert region to html? David O'Toole
  2007-05-20  2:27 ` Michael Olson
@ 2007-05-20 15:17 ` Carsten Dominik
  2007-05-21  6:56   ` Giovanni Ridolfi
                     ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Carsten Dominik @ 2007-05-20 15:17 UTC (permalink / raw)
  To: David O'Toole; +Cc: emacs-orgmode


On May 19, 2007, at 3:17, David O'Toole wrote:

>
> 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."


Thanks for this idea, will be useful for many things.

- Carsten

4.75 will contain the following function:

(defun org-export-region-as-html (beg end &optional body-only buffer)
   "Convert region fron BEG to END in org-mode buffer to HTML.
If prefix arg BODY-ONLY is set, omit file header, footer, and table of
contents, and only produce the region of converted text, useful for
cut-and-paste operations.
If BUFFER is a buffer or a string, use/create that buffer as a target
of the converted HTML.  If BUFFER is the symbol `string', return the
produced HTML as a string and leave no buffer behind.  For example,
a Lisp program could call this function in the following way:

   (setq html (org-export-region-as-html beg end t 'string))

When called interactively, the output buffer is selected, and shown
in a window.  A non-interactive call will only retunr the buffer."

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

* Re: Re: convert region to html?
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Giovanni Ridolfi @ 2007-05-21  6:56 UTC (permalink / raw)
  To: emacs-orgmode

On Sun, May 20, 2007 at 05:17:52PM +0200, Carsten Dominik wrote:
> 
> (defun org-export-region-as-html (beg end &optional body-only buffer)
>   "Convert region fron BEG to END in org-mode buffer to HTML.
                      ^^^^
fron -> from

Giovanni

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

* Re: convert region to html?
  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
  2 siblings, 0 replies; 7+ messages in thread
From: David O'Toole @ 2007-05-21 15:00 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode


super! thanks for this Carsten, i will test it when it is released and
see if i can get my org-blog.el working properly. I have had the urge
to blog a lot lately but haven't had an outlet :-)

> Thanks for this idea, will be useful for many things.
>
> - Carsten
>
> 4.75 will contain the following function:
>
> (defun org-export-region-as-html (beg end &optional body-only buffer)
>   "Convert region fron BEG to END in org-mode buffer to HTML.
> If prefix arg BODY-ONLY is set, omit file header, footer, and table of
> contents, and only produce the region of converted text, useful for
> cut-and-paste operations.
> If BUFFER is a buffer or a string, use/create that buffer as a target
> of the converted HTML.  If BUFFER is the symbol `string', return the
> produced HTML as a string and leave no buffer behind.  For example,
> a Lisp program could call this function in the following way:
>
>   (setq html (org-export-region-as-html beg end t 'string))
>
> When called interactively, the output buffer is selected, and shown
> in a window.  A non-interactive call will only retunr the buffer."
>
>
>
>

-- 
David O'Toole 
dto@gnu.org
http://dto.freeshell.org/notebook/

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

* org-blog.el updated to v1.17
  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   ` David O'Toole
       [not found]     ` <465DB53B.3030209@calicojack.co.uk>
  2 siblings, 1 reply; 7+ messages in thread
From: David O'Toole @ 2007-05-30 13:17 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, Eduardo Ochs


Available from http://dto.freeshell.org/e/org-blog.el

This is the first usable release of org-blog. Instructions for setup
and use are in the file's commentary. It requires org-mode at least
4.75 (very recent, see quoted posts below.)

You can see an example of the output at http://dto.freeshell.org/blog/
and the generated XML at http://dto.freeshell.org/blog/blog.xml

Features: 

  - write blog posts in org-mode syntax
  - juggle multiple posts while writing, publish in any order when finished
  - RSS 2.0 file. Now you can be on planet.emacsen.org!
  - "blogroll" (not well-tested)

Carsten Dominik <dominik@science.uva.nl> writes:

> On May 19, 2007, at 3:17, David O'Toole wrote:
>
>>
>> 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."
>
>
> Thanks for this idea, will be useful for many things.
>
> - Carsten
>
> 4.75 will contain the following function:
>
> (defun org-export-region-as-html (beg end &optional body-only buffer)
>   "Convert region fron BEG to END in org-mode buffer to HTML.
> If prefix arg BODY-ONLY is set, omit file header, footer, and table of
> contents, and only produce the region of converted text, useful for
> cut-and-paste operations.
> If BUFFER is a buffer or a string, use/create that buffer as a target
> of the converted HTML.  If BUFFER is the symbol `string', return the
> produced HTML as a string and leave no buffer behind.  For example,
> a Lisp program could call this function in the following way:
>
>   (setq html (org-export-region-as-html beg end t 'string))
>
> When called interactively, the output buffer is selected, and shown
> in a window.  A non-interactive call will only retunr the buffer."
>
>
>
>

-- 
David O'Toole 
dto@gnu.org
http://dto.freeshell.org/notebook/

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

* Re: org-blog.el v1.17 and org-publish-org-to-html
       [not found]       ` <m3myzlrwtu.fsf@gnu.org>
@ 2007-05-31 15:34         ` Rick Moynihan
  0 siblings, 0 replies; 7+ messages in thread
From: Rick Moynihan @ 2007-05-31 15:34 UTC (permalink / raw)
  To: David O'Toole; +Cc: emacs-orgmode

Hi,

I was using the version with org-mode (4.75) which seems to be the same 
as the one on your site.  Anyway, It seems like I was mistaken and 
org-publish-org-to-html is defined, it's just that the function wasn't 
interactive and I was expecting it to be.  I've not had chance to look 
much further into org-blog than this, but I have managed to get it to 
output some HTML.

On another note, I've not really used org-publish before, and have just 
seen that it supports multiple projects.  Is it possible to configure a 
project that is a 'single.org' file, which is in a folder of org files. 
  What I'd like is to be able to publish only single.org, and none of 
the others.  Is it possible to include *ONLY* this file?

Thanks again,

R.

David O'Toole wrote:
> Hi. Maybe you are using the version of org-publish.el that comes with
> org. The newer version it at
> http://dto.freeshell.org/e/org-publish.el
> 
> Can you try that and let me know if it helps?
> 
> Rick Moynihan <rick@calicojack.co.uk> writes:
> 
>> Hi, I just took a look at org-blog.el, and I couldn't get it to
>> publish to html because I don't have an org-publish-org-to-html
>> defined.  I'm using org-4.75.
>>
>> Great idea btw...
>>
>> R.
>>
>> David O'Toole wrote:
>>> Available from http://dto.freeshell.org/e/org-blog.el
>>>
>>> This is the first usable release of org-blog. Instructions for setup
>>> and use are in the file's commentary. It requires org-mode at least
>>> 4.75 (very recent, see quoted posts below.)
>>>
>>> You can see an example of the output at http://dto.freeshell.org/blog/
>>> and the generated XML at http://dto.freeshell.org/blog/blog.xml
>>>
>>> Features: 
>>>
>>>   - write blog posts in org-mode syntax
>>>   - juggle multiple posts while writing, publish in any order when finished
>>>   - RSS 2.0 file. Now you can be on planet.emacsen.org!
>>>   - "blogroll" (not well-tested)
>>>
>>> Carsten Dominik <dominik@science.uva.nl> writes:
>>>
>>>> On May 19, 2007, at 3:17, David O'Toole wrote:
>>>>
>>>>> 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."
>>>> Thanks for this idea, will be useful for many things.
>>>>
>>>> - Carsten
>>>>
>>>> 4.75 will contain the following function:
>>>>
>>>> (defun org-export-region-as-html (beg end &optional body-only buffer)
>>>>   "Convert region fron BEG to END in org-mode buffer to HTML.
>>>> If prefix arg BODY-ONLY is set, omit file header, footer, and table of
>>>> contents, and only produce the region of converted text, useful for
>>>> cut-and-paste operations.
>>>> If BUFFER is a buffer or a string, use/create that buffer as a target
>>>> of the converted HTML.  If BUFFER is the symbol `string', return the
>>>> produced HTML as a string and leave no buffer behind.  For example,
>>>> a Lisp program could call this function in the following way:
>>>>
>>>>   (setq html (org-export-region-as-html beg end t 'string))
>>>>
>>>> When called interactively, the output buffer is selected, and shown
>>>> in a window.  A non-interactive call will only retunr the buffer."
>>>>
>>>>
>>>>
>>>>
>>
>> -- 
>> Rick Moynihan
>> Software Engineer
>> Calico Jack LTD
>> http://www.calicojack.co.uk/
>>
> 


-- 
Rick Moynihan
Software Engineer
Calico Jack LTD
http://www.calicojack.co.uk/

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

end of thread, other threads:[~2007-05-31 15:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-19  1:17 convert region to html? David O'Toole
2007-05-20  2:27 ` Michael Olson
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

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).