Bibek Panthi <bpanthi...@gmail.com> writes:

> In ox.el (org-export-resolve-id-link) we need to remove search string 
> from path
> when checking for id.
>
> ID links can have search string. For example:
>
>    id:4E8212FF-55F3-4E23-A63C-DB0EA8003FBA::*Heading
>
> This patch does the following:
>
> When searching for matching id, remove the part beginning at ::. For
> backwards compatibility with links that can have :: within their id,
> also check for any id that match the full path. This is similar to
> what is done at org-id-open in org-id.el .

Thanks for the patch!
The patch reveals a more general problem - introduction of search option
could have broken all the existing code (including third-party code)
that relies upon :path property of id: links.

Currently, search options are explicitly supported only for file: link
type. When one has file+emacs:/path/to/file.txt::extra, the link is split into
:type "file" :application "emacs" :path "/path/to/file.txt"
:search-option "extra"

In contrast, <id:20250517::* Heading> link is simply
:type "id" :path "20250517::* Heading". And we have to re-parse the
:path every time we need to work with the id: links.

What do you think about allowing *all* the link types to have a form of
<type>+<application>:<path>::<search option>? Then, the parser will
split all the typed links into :type, :application, :path = 
"<path>::<search-option>",
:path-no-search-option = "<path>", and :search-option.

Note that we cannot simply reuse :path because it can break links that
have :: as a part of actual path (say, http links). We should also leave
:path in file links as historical case to avoid breakage.

Maybe we can also take this opportunity to use # as an alternative to ::
and naturally support https://example.com/#anchor.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>

Reply via email to