emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to deal with 'contents' in (derived) exporter backend
@ 2013-11-04 12:30 Thorsten Jolitz
  2013-11-05 20:21 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2013-11-04 12:30 UTC (permalink / raw)
  To: emacs-orgmode


Hi List, 

assume I want to derive an exporter backend from ox-org.el, and there
are just a few new transcoder functions, so all other elements/object
should be exported as Org-syntax (with inherited function
`org-org-identity').

Using this example Org-snippet

#+begin_src org
* A1
Text *A1*
** A2
Text *A2*
* B1
Text *B1*
** B2
Text *B2*
#+end_src

I get something like this if I write a transcoder function for 'headline'
ignoring argument 'contents' (don't bother with the details please):

#+begin_src emacs-lisp
(org-data nil "(headline (title-string \"A1\"
alt-title-string \"A1\" category \"tmp5\" level 1 priority nil tags nil
todo-keyword nil quotedp nil archivedp nil commentedp nil footnote-secion-p
nil))

(headline (title-string \"B1\" alt-title-string \"B1\" category \"tmp5\" level
1 priority nil tags nil todo-keyword nil quotedp nil archivedp nil commentedp
nil footnote-secion-p nil)) ")
#+end_src

Only the two 1st level headlines are successfully transcoded, their content is
missing. 

But when I use something like this in the headline transcode function

#+begin_src emacs-lisp
  (format "(headline %S %s) "
          [... return headline string ...]
          contents)
#+end_src

I get the parse-tree structure as output instead of elements/object
in their original Org text syntax as expected:

#+begin_src emacs-lisp
  (org-data nil "(headline (title-string \"A1\" alt-title-string \"A1\"
  category \"tmp5\" level 1 priority nil tags nil todo-keyword nil
  quotedp nil archivedp nil commentedp nil footnote-secion-p nil)
  (section (#(\"Text *A1* \" 0 5 (:parent (paragraph (:begin 6 :end 16
  :contents-begin 6 :contents-end 16 :post-blank 0 :post-affiliated 6
  :parent (section (:begin 6 :end 16 :contents-begin 6 :contents-end 16
  :post-blank 0 :parent (headline (:raw-value \"A1\" :begin 1 :end 32
  :pre-blank 0 :contents-begin 6 :contents-end 32 :level 1 :priority nil
  :tags [...]
#+end_src

Note that I have a simple filter-function for section that looks like this:

#+begin_src emacs-lisp
(defun org-iorg-data-filter-section-function (section backend info)
  (format "(section (%S))" section))
#+end_src

I'm sure there is some misunderstanding on my side here. I would expect
that all elements/objects inside the section have already been
transcoded back to Org-syntax when this filter is applied, so I should
not see parse-tree structures in the output.

I had a look at other backends for inspiration on how to deal with
'contents' in my headline transcoder function, e.g.

#+begin_src emacs-lisp
  (defun org-html-section (section contents info)
    [...]
    ;; Build return value.
    (format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>"
            class-num
            (or (org-element-property :CUSTOM_ID parent) section-number)
            contents)))))
#+end_src

but that looks to me just how I treated 'contents' above. 

Any tips would be appreciated. 

-- 
cheers,
Thorsten

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

* Re: How to deal with 'contents' in (derived) exporter backend
  2013-11-04 12:30 How to deal with 'contents' in (derived) exporter backend Thorsten Jolitz
@ 2013-11-05 20:21 ` Nicolas Goaziou
  2013-11-06 14:36   ` Thorsten Jolitz
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2013-11-05 20:21 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode

Hello,

Thorsten Jolitz <tjolitz@gmail.com> writes:


> But when I use something like this in the headline transcode function
>
> #+begin_src emacs-lisp
>   (format "(headline %S %s) "
>           [... return headline string ...]
>           contents)
> #+end_src
>
> I get the parse-tree structure as output instead of elements/object
> in their original Org text syntax as expected:
>
> #+begin_src emacs-lisp
>   (org-data nil "(headline (title-string \"A1\" alt-title-string \"A1\"
>   category \"tmp5\" level 1 priority nil tags nil todo-keyword nil
>   quotedp nil archivedp nil commentedp nil footnote-secion-p nil)
>   (section (#(\"Text *A1* \" 0 5 (:parent (paragraph (:begin 6 :end 16
>   :contents-begin 6 :contents-end 16 :post-blank 0 :post-affiliated 6
>   :parent (section (:begin 6 :end 16 :contents-begin 6 :contents-end 16
>   :post-blank 0 :parent (headline (:raw-value \"A1\" :begin 1 :end 32
>   :pre-blank 0 :contents-begin 6 :contents-end 32 :level 1 :priority nil
>   :tags [...]
> #+end_src

You don't get the parse-tree structure, you get Org syntax within
a propertized string. Try (org-no-properties contents) instead.


Regards,

-- 
Nicolas Goaziou

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

* Re: How to deal with 'contents' in (derived) exporter backend
  2013-11-05 20:21 ` Nicolas Goaziou
@ 2013-11-06 14:36   ` Thorsten Jolitz
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2013-11-06 14:36 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> But when I use something like this in the headline transcode function
>>
>> #+begin_src emacs-lisp
>>   (format "(headline %S %s) "
>>           [... return headline string ...]
>>           contents)
>> #+end_src
>>
>> I get the parse-tree structure as output instead of elements/object
>> in their original Org text syntax as expected:
>>
>> #+begin_src emacs-lisp
>>   (org-data nil "(headline (title-string \"A1\" alt-title-string \"A1\"
>>   category \"tmp5\" level 1 priority nil tags nil todo-keyword nil
>>   quotedp nil archivedp nil commentedp nil footnote-secion-p nil)
>>   (section (#(\"Text *A1* \" 0 5 (:parent (paragraph (:begin 6 :end 16
>>   :contents-begin 6 :contents-end 16 :post-blank 0 :post-affiliated 6
>>   :parent (section (:begin 6 :end 16 :contents-begin 6 :contents-end 16
>>   :post-blank 0 :parent (headline (:raw-value \"A1\" :begin 1 :end 32
>>   :pre-blank 0 :contents-begin 6 :contents-end 32 :level 1 :priority nil
>>   :tags [...]
>> #+end_src
>
> You don't get the parse-tree structure, you get Org syntax within
> a propertized string. Try (org-no-properties contents) instead.

That does the trick, thank you very much, I was kind of stuck without
being aware of this function. 

-- 
cheers,
Thorsten

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

end of thread, other threads:[~2013-11-06 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-04 12:30 How to deal with 'contents' in (derived) exporter backend Thorsten Jolitz
2013-11-05 20:21 ` Nicolas Goaziou
2013-11-06 14:36   ` Thorsten Jolitz

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