all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to convert a string to Org parsed tree
@ 2013-07-28 10:18 Yujie Wen
  2013-07-28 10:43 ` Robert Klein
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yujie Wen @ 2013-07-28 10:18 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org Mode

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

Hi,

  I am working on the org-reveal exporter and I need to convert a string
get from org-element-property into HTML format. The property string have
some Org-mode markups that need to be converted to relevant HTML labels.
For example, a string of "/italic/" to "<i>italic</i>"

  Is there any existing Org-mode functions can help me to achieve this kind
of functionality?

Regards,
Yujie

[-- Attachment #2: Type: text/html, Size: 511 bytes --]

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

* Re: How to convert a string to Org parsed tree
  2013-07-28 10:18 How to convert a string to Org parsed tree Yujie Wen
@ 2013-07-28 10:43 ` Robert Klein
  2013-07-28 11:07 ` Nicolas Goaziou
  2013-07-28 12:17 ` Eric Abrahamsen
  2 siblings, 0 replies; 5+ messages in thread
From: Robert Klein @ 2013-07-28 10:43 UTC (permalink / raw)
  To: emacs-orgmode

On 07/28/2013 12:18 PM, Yujie Wen wrote:
> Hi,
> 
>   I am working on the org-reveal exporter and I need to convert a string
> get from org-element-property into HTML format. The property string have
> some Org-mode markups that need to be converted to relevant HTML labels.
> For example, a string of "/italic/" to "<i>italic</i>"
> 
>   Is there any existing Org-mode functions can help me to achieve this
> kind of functionality?
> 
> Regards,
> Yujie
> 

Hi Yujie,

how about applying the exporter to the string, e.g. something like

(with-temp-buffer
  (insert (plist-get plist yout-property-string))
  (org-html-export-as-html nil nil nil t new-plist)
  (buffer-string))

(didn't test, just typed this into the mail)


Best regards
Robert

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

* Re: How to convert a string to Org parsed tree
  2013-07-28 10:18 How to convert a string to Org parsed tree Yujie Wen
  2013-07-28 10:43 ` Robert Klein
@ 2013-07-28 11:07 ` Nicolas Goaziou
  2013-07-28 12:17 ` Eric Abrahamsen
  2 siblings, 0 replies; 5+ messages in thread
From: Nicolas Goaziou @ 2013-07-28 11:07 UTC (permalink / raw)
  To: Yujie Wen; +Cc: emacs-orgmode@gnu.org Mode

Hello,

Yujie Wen <yjwen.ty@gmail.com> writes:

>   I am working on the org-reveal exporter and I need to convert a string
> get from org-element-property into HTML format. The property string have
> some Org-mode markups that need to be converted to relevant HTML labels.
> For example, a string of "/italic/" to "<i>italic</i>"
>
>   Is there any existing Org-mode functions can help me to achieve this kind
> of functionality?

For interactive functions, you can use `org-export-string-as'. E.g.,

  (org-export-string-as "/italic/" 'html 'body-only)

If you don't want the surronding paragraph, you can use the same
function with an anonymous export back-end derived from HTML:

  (org-export-string-as "/italic/"
                      (org-export-create-backend
                       :parent 'html
                       :transcoders '((paragraph . (lambda (e c i) c))))
                      'body-only)

But, from within an export back-end, there are probably other ways that
will not require to collect export options again. E.g,

  (org-export-data-with-backend
   (org-element-parse-secondary-string
    "/italic/" org-element-all-successors)
   'html info)


Regards,

-- 
Nicolas Goaziou

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

* Re: How to convert a string to Org parsed tree
  2013-07-28 10:18 How to convert a string to Org parsed tree Yujie Wen
  2013-07-28 10:43 ` Robert Klein
  2013-07-28 11:07 ` Nicolas Goaziou
@ 2013-07-28 12:17 ` Eric Abrahamsen
  2013-07-28 14:16   ` Yujie Wen
  2 siblings, 1 reply; 5+ messages in thread
From: Eric Abrahamsen @ 2013-07-28 12:17 UTC (permalink / raw)
  To: emacs-orgmode

Yujie Wen <yjwen.ty@gmail.com> writes:

> Hi,
>
>   I am working on the org-reveal exporter and I need to convert a
> string get from org-element-property into HTML format. The property
> string have some Org-mode markups that need to be converted to
> relevant HTML labels. For example, a string of "/italic/" to "<i>
> italic</i>"
>
>   Is there any existing Org-mode functions can help me to achieve
> this kind of functionality?
>
> Regards,
> Yujie

Try out `org-export-string-as', that will probably do what you want...

E

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

* Re: How to convert a string to Org parsed tree
  2013-07-28 12:17 ` Eric Abrahamsen
@ 2013-07-28 14:16   ` Yujie Wen
  0 siblings, 0 replies; 5+ messages in thread
From: Yujie Wen @ 2013-07-28 14:16 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org Mode

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

Hi, Robert, Nicolas and Eric,

  Thanks to all of you for the kind answers. org-export-data-with-backend
and org-element-parse-secondary-string best meet my requirements. They
worked just as I expected. Thanks again.

Regards,
Yujie



2013/7/28 Eric Abrahamsen <eric@ericabrahamsen.net>

> Yujie Wen <yjwen.ty@gmail.com> writes:
>
> > Hi,
> >
> >   I am working on the org-reveal exporter and I need to convert a
> > string get from org-element-property into HTML format. The property
> > string have some Org-mode markups that need to be converted to
> > relevant HTML labels. For example, a string of "/italic/" to "<i>
> > italic</i>"
> >
> >   Is there any existing Org-mode functions can help me to achieve
> > this kind of functionality?
> >
> > Regards,
> > Yujie
>
> Try out `org-export-string-as', that will probably do what you want...
>
> E
>
>
>

[-- Attachment #2: Type: text/html, Size: 1537 bytes --]

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

end of thread, other threads:[~2013-07-28 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-28 10:18 How to convert a string to Org parsed tree Yujie Wen
2013-07-28 10:43 ` Robert Klein
2013-07-28 11:07 ` Nicolas Goaziou
2013-07-28 12:17 ` Eric Abrahamsen
2013-07-28 14:16   ` Yujie Wen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.