* Preserving links when using org-element-interpret-data
@ 2016-10-06 4:14 Thibault Marin
2016-10-09 7:44 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: Thibault Marin @ 2016-10-06 4:14 UTC (permalink / raw)
To: emacs-orgmode
Hi all,
I am trying to use the org-element tools to modify an org file from elisp code
and I was wondering if the `org-element-parse-buffer' /
`org-element-interpret-data' combo should result in the same content as the
original buffer. I am having issues with links where the target and the
description are both =file:= entries.
My original org looks like this:
#+NAME: org-data
#+begin_example
,#+TITLE: test
[[file:a.png][file:a.png]]
#+end_example
The elisp code parses the org file and outputs the result from
`org-element-interpret-data':
#+NAME: org-interpret
#+BEGIN_SRC emacs-lisp :var org-data=org-data :results verbatim
(let (org-tree)
(with-temp-buffer
(insert org-data)
(setq org-tree (org-element-parse-buffer)))
(org-element-interpret-data org-tree))
#+END_SRC
#+RESULTS: org-interpret
: "#+TITLE: test
:
: [[file:a.png][[[file:a.png]]]]
: "
The input link is transformed from
#+begin_example
[[file:a.png][file:a.png]]
#+end_example
to
#+begin_example
[[file:a.png][[[file:a.png]]]]
#+end_example
Are the additional brackets in the description expected? Is there any way to
achieve what I want: I am trying to get org-element-interpret-data to output the
same link syntax as the input (in my real application, I am changing the
filename).
Thanks in advance for the help.
P.S.: Here is my version information:
#+BEGIN_SRC emacs-lisp :results drawer
(concat (emacs-version) "\n"
(replace-regexp-in-string "@.*)" "@ ... )" (org-version nil t)))
#+END_SRC
#+RESULTS:
:RESULTS:
GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.21.5)
of 2016-09-05 on trouble, modified by Debian
Org-mode version 8.3.6 (release_8.3.6-1179-ga9ae0e @ ... )
:END:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Preserving links when using org-element-interpret-data
2016-10-06 4:14 Preserving links when using org-element-interpret-data Thibault Marin
@ 2016-10-09 7:44 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2016-10-09 7:44 UTC (permalink / raw)
To: Thibault Marin; +Cc: emacs-orgmode
Hello,
Thibault Marin <thibault.marin@gmx.com> writes:
> I am trying to use the org-element tools to modify an org file from elisp code
> and I was wondering if the `org-element-parse-buffer' /
> `org-element-interpret-data' combo should result in the same content as the
> original buffer.
There is no guarantee that they return the same original buffer.
Actually, it is highly unlikely. Some information, not useful to Org, is
ignored during parsing (e.g., global indentation, case for keywords...).
However, they will return an equivalent buffer, in the sense that both
the produced and the original one have the same parse tree.
> I am having issues with links where the target and the
> description are both =file:= entries.
[...]
> The input link is transformed from
>
> #+begin_example
> [[file:a.png][file:a.png]]
> #+end_example
>
> to
>
> #+begin_example
> [[file:a.png][[[file:a.png]]]]
> #+end_example
>
> Are the additional brackets in the description expected?
No, this is a genuine bug. This is now fixed. Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-09 7:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-06 4:14 Preserving links when using org-element-interpret-data Thibault Marin
2016-10-09 7:44 ` Nicolas Goaziou
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).