I think add an "description" extraction for standard link style [[link][description]] is convenient for other ol.el ecosystem like link previewing, e.g. [[file:test.pdf][file:preview.png]]
Also, Ihor, maybe this patch can simplify the function `org-link-preview-region` which I reviewed the commit "3362773397df1e05fb2cc31b9cd944ca83ab6792".
From f62c5358a9a2dec52f51be962da100be3af8fc4f Mon Sep 17 00:00:00 2001 From: stardiviner <[email protected]> Date: Sat, 9 May 2026 11:23:49 +0800 Subject: [PATCH] Extract standard link description part * lisp/org-element.el (org-element-link-parser): Extract out the standard link description part for user handling. e.g. Previewing link description part in new ol.el previewing system. --- lisp/org-element.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index 9c485ca70..4d235fb7f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -3941,7 +3941,7 @@ (defun org-element-link-parser () (catch 'no-object (let ((begin (point)) end contents-begin contents-end link-end post-blank path type format - raw-link search-option application + raw-link description search-option application (explicit-type-p nil)) (cond ;; Type 1: Text targeted from a radio target. @@ -3962,6 +3962,8 @@ (defun org-element-link-parser () (setq contents-begin (match-beginning 2)) (setq contents-end (match-end 2)) (setq link-end (match-end 0)) + ;; Put description part match string before raw-link to avoid fail. + (setq description (match-string-no-properties 2)) ;; RAW-LINK is the original link. Decode any encoding. ;; Expand any abbreviation in it. ;; @@ -4058,6 +4060,7 @@ (defun org-element-link-parser () :path path :format format :raw-link (or raw-link path) + :description description :application application :search-option search-option :begin begin -- 2.50.1 (Apple Git-155)
-- [ stardiviner ] I try to make every word tell the meaning that I want to express without misunderstanding. Blog: https://stardiviner.github.io/ IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
signature.asc
Description: PGP signature
