emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org-mode element API: How to extract link description
@ 2024-08-18 12:08 Sébastien Gendre
  2024-08-18 13:17 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Gendre @ 2024-08-18 12:08 UTC (permalink / raw)
  To: Org mode

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

Hello,

With the Org-mode element API, when I get an element of type "link", how
do I extract the link description ?

It's not a property of a link, from what I can see in when explore the
content of a link element. And I found nothing on the documentation.

Did I miss something ?


Best regards

-------
Gendre Sébastien

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]

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

* Re: Org-mode element API: How to extract link description
  2024-08-18 12:08 Org-mode element API: How to extract link description Sébastien Gendre
@ 2024-08-18 13:17 ` Ihor Radchenko
  2024-08-18 13:47   ` Sébastien Gendre
  2024-08-22 19:51   ` Alexander Adolf via General discussions about Org-mode.
  0 siblings, 2 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-08-18 13:17 UTC (permalink / raw)
  To: Sébastien Gendre; +Cc: Org mode

Sébastien Gendre <seb@k-7.ch> writes:

> With the Org-mode element API, when I get an element of type "link", how
> do I extract the link description ?

> It's not a property of a link, from what I can see in when explore the
> content of a link element. And I found nothing on the documentation.

Link description is considered to be link contents.
But do note that simple `org-element-at-point' does not compute
contents. It is only available in the full parse tree. From
`org-element-at-point', a practical way to retrieve description text is
using substring between :contents-begin/end.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: Org-mode element API: How to extract link description
  2024-08-18 13:17 ` Ihor Radchenko
@ 2024-08-18 13:47   ` Sébastien Gendre
  2024-08-22 19:51   ` Alexander Adolf via General discussions about Org-mode.
  1 sibling, 0 replies; 4+ messages in thread
From: Sébastien Gendre @ 2024-08-18 13:47 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Org mode

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


Thank you very much.

Ihor Radchenko <yantar92@posteo.net> writes:

> Sébastien Gendre <seb@k-7.ch> writes:
>
>> With the Org-mode element API, when I get an element of type "link", how
>> do I extract the link description ?
>
>> It's not a property of a link, from what I can see in when explore the
>> content of a link element. And I found nothing on the documentation.
>
> Link description is considered to be link contents.
> But do note that simple `org-element-at-point' does not compute
> contents. It is only available in the full parse tree. From
> `org-element-at-point', a practical way to retrieve description text is
> using substring between :contents-begin/end.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 849 bytes --]

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

* Re: Org-mode element API: How to extract link description
  2024-08-18 13:17 ` Ihor Radchenko
  2024-08-18 13:47   ` Sébastien Gendre
@ 2024-08-22 19:51   ` Alexander Adolf via General discussions about Org-mode.
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Adolf via General discussions about Org-mode. @ 2024-08-22 19:51 UTC (permalink / raw)
  To: Ihor Radchenko, Sébastien Gendre; +Cc: Org mode

Ihor Radchenko <yantar92@posteo.net> writes:

> Sébastien Gendre <seb@k-7.ch> writes:
>
>> With the Org-mode element API, when I get an element of type "link", how
>> do I extract the link description ?
> [...]
> Link description is considered to be link contents.
> But do note that simple `org-element-at-point' does not compute
> contents. It is only available in the full parse tree. From
> `org-element-at-point', a practical way to retrieve description text is
> using substring between :contents-begin/end.
> [...]

I use org-link-display-format to get the description part when I have
the link as a string. Perhaps something along the lines of

    (org-link-display-format (buffer-substring-no-properties
                              (org-element-contents-begin link)
                              (org-element-contents-end link)))

for your use-case?


Hoping to have helped,

  --alexander


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

end of thread, other threads:[~2024-08-22 19:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-18 12:08 Org-mode element API: How to extract link description Sébastien Gendre
2024-08-18 13:17 ` Ihor Radchenko
2024-08-18 13:47   ` Sébastien Gendre
2024-08-22 19:51   ` Alexander Adolf via General discussions about Org-mode.

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