emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Org-mode element API: How to extract link description


From: Alexander Adolf
Subject: Re: Org-mode element API: How to extract link description
Date: Thu, 22 Aug 2024 21:51:07 +0200

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]