Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-21 Thread Max Nikulin

On 21/10/2022 10:16, Ihor Radchenko wrote:

Max Nikulin writes:


I am apologizing if my comments make no sense. I remember a thread on
improper handling on id links in ox-html, so I am a bit surprised that a
link to the whole file (if I got the goal of the patch correctly, of
course) is the only problem with ODT.


It is likely not the only problem. But this thread is about one
particular problem that should also be fixed regardless of others.
If you find other problems, please report them.


I am sorry. I confused this thread with some other bug report. I agree 
that the original post describes namely file links. When Moritz provided 
an example in response to your request for more details I decided that 
more similar problems are coming. Perhaps particular use case does not 
include links to specific headings in files and I was wrong. On the 
other hand if ox-odt code works with id links better than ox-html then 
the former may be a source of inspiration how to fix the latter.



Here, we at least fix the export error. So that people can at least get
some exported .odt file.


I have tried main HEAD (your fix should be applied) and I did not get an 
error, but the result is quite strange. Consider a single file with an 
internal link:


:PROPERTIES:
:ID:   3c885843-13ad-4dd8-a57f-de8271403b85
:END:
#+TITLE: Note A

* H 1
Some text

* H 2
[[id:3c885843-13ad-4dd8-a57f-de8271403b85][Link to Note A]]

Link in the exported document:

Link to Note 
A


I would expect a target withing the same .odt file.

Properties as displayed in LibreOffice UI are even more peculiar:
Document path
file:///tmp/d/test-odt.odt/test-odt.org
Target in document is empty.

My expectation for path is file:///tmp/d/test-odt.odt or at least 
file:///tmp/d/test-odt.org, but certainly not their combination. I am 
unsure if you consider this observation as relevant to this thread.







Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-21 Thread Ihor Radchenko
Ihor Radchenko  writes:

> Subject: [PATCH] ox-odt: Allow id: links to files
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> * lisp/ox-odt.el (org-odt-link): Transcode id: links to file property
> drawers.
>
> Reported-by: Moritz Schäfer 
> Link: 
> https://orgmode.org/list/CA+FVMQDBUwCQHFOWieELaB3=4mh2yba66+npcuqwvvv_1hv...@mail.gmail.com

Applied onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=4e5c7373115cfeb88fb4392252d682fad8d178a8

We can further improve things, like with escaping the file name, but the
patch should at least fix the immediate export problem.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-20 Thread Ihor Radchenko
Max Nikulin  writes:

> I am apologizing if my comments make no sense. I remember a thread on 
> improper handling on id links in ox-html, so I am a bit surprised that a 
> link to the whole file (if I got the goal of the patch correctly, of 
> course) is the only problem with ODT.

It is likely not the only problem. But this thread is about one
particular problem that should also be fixed regardless of others.
If you find other problems, please report them.

> - ox-html may transform file suffix from .org to .html. Have I missed 
> the same code for ox-odt?

ox-html does it according to org-html-link-org-files-as-html. ox-odt
does not provide such feature. If people need it, it can be added.

Here, we at least fix the export error. So that people can at least get
some exported .odt file.

> - Doesn't destination should be passed through some quoting-escaping 
> function to avoid characters in file names that may make XML invalid? 
> (Perhaps id links between .org files will be broken earlier.)
>
> Max Nikulin. Re: Internal link broken when publishing (was org-id with 
> ox-html) Tue, 14 Sep 2021 23:33:43 +0700. 
> https://list.orgmode.org/shqit9$8ds$1...@ciao.gmane.io

It should be. But, similar to ox-html, it is not escaped.
Patches welcome.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-20 Thread Max Nikulin

On 19/10/2022 17:36, Ihor Radchenko wrote:


--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2737,6 +2737,12 @@ (defun org-odt-link (link desc info)
   (format "%s"
   (org-export-get-reference destination info)
   (or desc (org-export-get-ordinal destination info
+  ;; Link to a file, corresponding to string return value of
+  ;; `org-export-resolve-id-link'.
+  (plain-text
+   (format "%s"
+  destination
+  (or desc (org-export-get-ordinal destination info


I am apologizing if my comments make no sense. I remember a thread on 
improper handling on id links in ox-html, so I am a bit surprised that a 
link to the whole file (if I got the goal of the patch correctly, of 
course) is the only problem with ODT.


- ox-html may transform file suffix from .org to .html. Have I missed 
the same code for ox-odt?
- Doesn't destination should be passed through some quoting-escaping 
function to avoid characters in file names that may make XML invalid? 
(Perhaps id links between .org files will be broken earlier.)


Max Nikulin. Re: Internal link broken when publishing (was org-id with 
ox-html) Tue, 14 Sep 2021 23:33:43 +0700. 
https://list.orgmode.org/shqit9$8ds$1...@ciao.gmane.io






Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-19 Thread Ihor Radchenko
Moritz Schäfer  writes:

> Thanks for getting back to me on this.
>
> Here is a minimal example. In org-roam (v2), when having a file/node:

Thanks! An example helps a lot.

Can you try the attached patch against the latest main branch?

>From 4e5c7373115cfeb88fb4392252d682fad8d178a8 Mon Sep 17 00:00:00 2001
Message-Id: <4e5c7373115cfeb88fb4392252d682fad8d178a8.1666175750.git.yanta...@posteo.net>
From: Ihor Radchenko 
Date: Wed, 19 Oct 2022 18:33:44 +0800
Subject: [PATCH] ox-odt: Allow id: links to files
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ox-odt.el (org-odt-link): Transcode id: links to file property
drawers.

Reported-by: Moritz Schäfer 
Link: https://orgmode.org/list/CA+FVMQDBUwCQHFOWieELaB3=4mh2yba66+npcuqwvvv_1hv...@mail.gmail.com
---
 lisp/ox-odt.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 208a39d9d..4ff667640 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2737,6 +2737,12 @@ (defun org-odt-link (link desc info)
 	   (format "%s"
 		   (org-export-get-reference destination info)
 		   (or desc (org-export-get-ordinal destination info
+  ;; Link to a file, corresponding to string return value of
+  ;; `org-export-resolve-id-link'.
+  (plain-text
+   (format "%s"
+		   destination
+		   (or desc (org-export-get-ordinal destination info
 	  ;; Fuzzy link points to some element (e.g., an inline image,
 	  ;; a math formula or a table).
 	  (otherwise
-- 
2.35.1



-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 


Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-19 Thread Moritz Schäfer
Thanks for getting back to me on this.

Here is a minimal example. In org-roam (v2), when having a file/node:

*note_a.org *:




*:PROPERTIES::ID:   3c885843-13ad-4dd8-a57f-de8271403b85:END:#+TITLE:
Note A*



and a second file *note_b.org *:





*:PROPERTIES::ID:   715fdccf-0c40-4bbe-87b0-ae9787c46a1b:END:#+TITLE:
Note B[[id:3c885843-13ad-4dd8-a57f-de8271403b85][Link to Note A]]*



and then run *(org-odt-export-to-odt)* (within the buffer *#note_b.org
*), then I get the aforementioned error:

*OpenDocument export failed: FIXME: Unable to resolve "note_a.org
"*

Hope this helps.

Best,
Moritz

On Tue, 18 Oct 2022 at 09:46, Ihor Radchenko  wrote:

> Moritz Schäfer  writes:
>
> > When exporting an org-file with org-id based links  to odt, I get the
> > error error "FIXME: Unable to resolve ", where  is
> the
> > filename, the org-id-link was pointing to.
> >
> > Org-id links (example below) are the default for org-roam (v2).
> >
> > [[id:5222a0dd-5084-41bd-b61d-21dcb3290187][Note title]]
> >
> > The issue lies within ox-odt.el in the org-odt-link function. There, '
> > destination' takes the value of the file name of the id-link target.
> > Therefore, (org-element-type destination) gets evaluated to 'plain-text,
> > which is not resolvable by 'org-odt-link--infer-description', thus it
> > raises the error.
> >
> > I worked around this issue by adding a check for plain-text, but would
> like
> > to raise this issue here to find proper ideas on how to fix this.
>
> Thanks for reporting, and sorry for the late reply.
> Could you provide an example and steps demonstrating the problem?
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at .
> Support Org development at ,
> or support my work at 
>


-- 



*Moritz Schäfer**, PhD*
Bioinformatician
Postdoctoral Fellow

Christoph Bock Group



*CeMM*

Research Center for Molecular Medicine
of the Austrian Academy of Sciences

Lazarettgasse 14, AKH BT 25.3
1090 Vienna, Austria

mschae...@cemm.at

www.cemm.at





Re: [BUG] ox-odt fails for org-id links (e.g., from org-roam v2) [9.5.2 (9.5.2-gfbff08 @ /home/moritz/.emacs.d/elpa/27.2/develop/org-9.5.2/)]

2022-10-18 Thread Ihor Radchenko
Moritz Schäfer  writes:

> When exporting an org-file with org-id based links  to odt, I get the
> error error "FIXME: Unable to resolve ", where  is the
> filename, the org-id-link was pointing to.
>
> Org-id links (example below) are the default for org-roam (v2).
>
> [[id:5222a0dd-5084-41bd-b61d-21dcb3290187][Note title]]
>
> The issue lies within ox-odt.el in the org-odt-link function. There, '
> destination' takes the value of the file name of the id-link target.
> Therefore, (org-element-type destination) gets evaluated to 'plain-text,
> which is not resolvable by 'org-odt-link--infer-description', thus it
> raises the error.
>
> I worked around this issue by adding a check for plain-text, but would like
> to raise this issue here to find proper ideas on how to fix this.

Thanks for reporting, and sorry for the late reply.
Could you provide an example and steps demonstrating the problem?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at