emacs-orgmode
[Top][All Lists]
Advanced

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

[org-export] Linking inlinetasks (was: BUG?: Link to inline-task not wor


From: Ihor Radchenko
Subject: [org-export] Linking inlinetasks (was: BUG?: Link to inline-task not working)
Date: Wed, 05 Oct 2022 11:23:50 +0800

Ihor Radchenko <yantar92@gmail.com> writes:

> Michael Dauer <mick.dauer@gmail.com> writes:
>
>> Shouldn't be org-export-resolve-fuzzy-link the relevant function, at least
>> for my use case?
>>
>> But there it looks like it is searching through all elements including
>> inlinetasks, which is in org-element-all-elements:
>> (append pseudo-types '(target) org-element-all-elements)
>
> Maybe. Further it also calls org-export-search-cells, which does not
> consider inlinetasks even if they are matched.

I have investigated further.
In addition to inlinetasks not being taken into account by
`org-export-search-cells', `org-export-resolve-fuzzy-link', and
`org-export-resolve-id-link', there is no export backend support for
linking inlinetasks.

In order to have full support for inlinetasks during export, we need to
modify export backends to be able to link to the inlinetasks.

For example,
- ox-html.el does not associate ID anchor in
  `org-html-format-inlinetask-default-function'
- ox-latex.el also does not provide any label in
  `org-latex-format-inlinetask-default-function'
- ox-ascii.el does not assign a number to be referred to in
  `org-ascii-format-inlinetask-default'

I did not check other backends.

Note that changing only ox.el without altering the individual backends
can break export in unexpected ways.

I am attaching a simple patch changing the generic link resolution
machinery. If one applies the patch, **export will be broken**.
In particular, exporting to ASCII (C-c C-e t U) will straight throw
an error.

The same may happen in third-party export backends even if we alter the
all built-in export backends appropriately.

Thus, supporting links to inlinetasks will be a breaking change and such
support should be shielded behind a user customization, not be enabled
by default.

>From c6737633b12b8f9de1a240b2f32f52d54e1c14a1 Mon Sep 17 00:00:00 2001
Message-Id: 
<c6737633b12b8f9de1a240b2f32f52d54e1c14a1.1664939959.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Wed, 5 Oct 2022 11:17:55 +0800
Subject: [PATCH] lisp/ox.el: Allow links to inlinetasks

* lisp/ox.el (org-export-search-cells):
(org-export-resolve-fuzzy-link):
(org-export-resolve-id-link): Resolve links to inlinetasks.

**This is not a proper commit**
Applying it will not make inlinetask links work during export.
Backend-specific support will be required.
---
 lisp/ox.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index 51145acaa..6090d1ecd 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -4313,7 +4313,7 @@ (defun org-export-search-cells (datum)
 A search cell is the internal representation of a fuzzy link.  It
 ignores white spaces and statistics cookies, if applicable."
   (pcase (org-element-type datum)
-    (`headline
+    ((or `headline `inlinetask)
      (let ((title (split-string
                   (replace-regexp-in-string
                    "\\[[0-9]*\\(?:%\\|/[0-9]*\\)\\]" " "
@@ -4408,7 +4408,8 @@ (defun org-export-resolve-fuzzy-link (link info &rest 
pseudo-types)
         ;; Matching both a name and a target is not valid, and
         ;; therefore undefined.
         (or (cl-some (lambda (datum)
-                       (and (not (eq (org-element-type datum) 'headline))
+                       (and (not (memq (org-element-type datum)
+                                      '(headline inlinetask)))
                             datum))
                      matches)
             (car matches))
@@ -4428,7 +4429,7 @@ (defun org-export-resolve-id-link (link info)
                              (let ((table (make-hash-table :test #'equal)))
                                (org-element-map
                                    (plist-get info :parse-tree)
-                                   'headline
+                                   '(headline inlinetask)
                                  (lambda (headline)
                                    (let ((id (org-element-property :ID 
headline))
                                          (custom-id (org-element-property 
:CUSTOM_ID headline)))
-- 
2.35.1


-- 
Ihor Radchenko,
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

reply via email to

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