* How to extract raw link and description from the "link" element?
@ 2015-02-24 0:29 Marcin Borkowski
2015-02-24 0:56 ` John Kitchin
2015-02-24 20:50 ` Samuel W. Flint
0 siblings, 2 replies; 5+ messages in thread
From: Marcin Borkowski @ 2015-02-24 0:29 UTC (permalink / raw)
To: Org-Mode mailing list
Hi all,
so I have this:
[[file:whatever.org][Some link]]
How do I extract bith parts of this link programmatically?
My use case is that I have an Org tree of links, and I want to export
them to certain XML format.
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to extract raw link and description from the "link" element?
2015-02-24 0:29 How to extract raw link and description from the "link" element? Marcin Borkowski
@ 2015-02-24 0:56 ` John Kitchin
2015-02-24 20:50 ` Samuel W. Flint
1 sibling, 0 replies; 5+ messages in thread
From: John Kitchin @ 2015-02-24 0:56 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Org-Mode mailing list
Probably there is some more elegant way but if you run this on a link,
you get the two pieces I think. In a filter or exporter, you might
replace (org-element-context) with the link element/object
#+BEGIN_SRC emacs-lisp
(defun parse-link ()
(interactive)
(message-box "%s"
(cons
;; path
(org-element-property :path (org-element-context))
;; description
(buffer-substring
(org-element-property :contents-begin (org-element-context))
(org-element-property :contents-end (org-element-context))))))
#+END_SRC
Marcin Borkowski writes:
> Hi all,
>
> so I have this:
>
> [[file:whatever.org][Some link]]
>
> How do I extract bith parts of this link programmatically?
>
> My use case is that I have an Org tree of links, and I want to export
> them to certain XML format.
>
> TIA,
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to extract raw link and description from the "link" element?
2015-02-24 0:29 How to extract raw link and description from the "link" element? Marcin Borkowski
2015-02-24 0:56 ` John Kitchin
@ 2015-02-24 20:50 ` Samuel W. Flint
2015-02-24 21:24 ` Marcin Borkowski
1 sibling, 1 reply; 5+ messages in thread
From: Samuel W. Flint @ 2015-02-24 20:50 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Org-Mode mailing list
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> Hi all,
>
> so I have this:
>
> [[file:whatever.org][Some link]]
>
> How do I extract bith parts of this link programmatically?
>
> My use case is that I have an Org tree of links, and I want to export
> them to certain XML format.
>
> TIA,
Have you considered a custom exporter? Just a little thought.
Sam
--
Samuel W. Flint
swflint@flintfam.org (402) 517-8468 <XMPP>
freenode: swflint
http://flintfam.org/~swflint
4096R/266596F4
(9477 D23E 389E 40C5 2F10 DE19 68E5 318E 2665 96F4)
"The most dangerous phrase in the language is, 'We've always done it
this way'." -- Grace Hopper
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to extract raw link and description from the "link" element?
2015-02-24 20:50 ` Samuel W. Flint
@ 2015-02-24 21:24 ` Marcin Borkowski
2015-02-24 21:28 ` Samuel W. Flint
0 siblings, 1 reply; 5+ messages in thread
From: Marcin Borkowski @ 2015-02-24 21:24 UTC (permalink / raw)
To: Samuel W. Flint; +Cc: Org-Mode mailing list
On 2015-02-24, at 21:50, Samuel W. Flint <swflint@flintfam.org> wrote:
> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>
>> Hi all,
>>
>> so I have this:
>>
>> [[file:whatever.org][Some link]]
>>
>> How do I extract bith parts of this link programmatically?
>>
>> My use case is that I have an Org tree of links, and I want to export
>> them to certain XML format.
>>
>> TIA,
>
> Have you considered a custom exporter? Just a little thought.
That's exactly what I'm writing. It just hadn't occured to me to use
the parsed version in the element tree – I just concentrated on
exporting the headlines (which contain the links). Stupid me. Thanks
for this (obvious) tip!
> Sam
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to extract raw link and description from the "link" element?
2015-02-24 21:24 ` Marcin Borkowski
@ 2015-02-24 21:28 ` Samuel W. Flint
0 siblings, 0 replies; 5+ messages in thread
From: Samuel W. Flint @ 2015-02-24 21:28 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Org-Mode mailing list
Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
> On 2015-02-24, at 21:50, Samuel W. Flint <swflint@flintfam.org> wrote:
>
>> Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:
>>
>>> Hi all,
>>>
>>> so I have this:
>>>
>>> [[file:whatever.org][Some link]]
>>>
>>> How do I extract bith parts of this link programmatically?
>>>
>>> My use case is that I have an Org tree of links, and I want to export
>>> them to certain XML format.
>>>
>>> TIA,
>>
>> Have you considered a custom exporter? Just a little thought.
>
> That's exactly what I'm writing. It just hadn't occured to me to use
> the parsed version in the element tree – I just concentrated on
> exporting the headlines (which contain the links). Stupid me. Thanks
> for this (obvious) tip!
You are welcome! Glad I could help!
Sam
--
Samuel W. Flint
swflint@flintfam.org (402) 517-8468 <XMPP>
freenode: swflint
http://flintfam.org/~swflint
4096R/266596F4
(9477 D23E 389E 40C5 2F10 DE19 68E5 318E 2665 96F4)
"The most dangerous phrase in the language is, 'We've always done it
this way'." -- Grace Hopper
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-02-24 21:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24 0:29 How to extract raw link and description from the "link" element? Marcin Borkowski
2015-02-24 0:56 ` John Kitchin
2015-02-24 20:50 ` Samuel W. Flint
2015-02-24 21:24 ` Marcin Borkowski
2015-02-24 21:28 ` Samuel W. Flint
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).