From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id EDhHDHT6YWNYRAAAbAwnHQ (envelope-from ) for ; Wed, 02 Nov 2022 06:04:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cAs3DHT6YWPP+gAAauVa8A (envelope-from ) for ; Wed, 02 Nov 2022 06:04:52 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E0EEF1DF58 for ; Wed, 2 Nov 2022 06:04:51 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oq5ug-0001Nd-JM; Wed, 02 Nov 2022 01:03:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oq5ue-0001N7-Lj for emacs-orgmode@gnu.org; Wed, 02 Nov 2022 01:03:40 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oq5uX-0002H3-OL for emacs-orgmode@gnu.org; Wed, 02 Nov 2022 01:03:40 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6369D240104 for ; Wed, 2 Nov 2022 06:03:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667365411; bh=gBh3SLBBMPq/4iUloHuZzIU+Lu1OgzVvtlDDQxSzMww=; h=From:To:Cc:Subject:Date:From; b=pyWzmsssplC33O5roAaQI0fg8Aq/MhcuaseGcTHEF3hSHUmLjXmDve78Ohqe77lCI 4NapFDf6gQRI0hYPK81O4XcFQGjwEEUPiotO9Ake0eY7Vlb5Yp3gDVZ6Yb1fPIDHTH VdgALfK/9k2uvJq8zSqKEitwetHWLub3kXb6EqbgW1aGOi2XEoxujW1LG9ejhvvcJV ElWw9sAt0j5vG3bzK5Fe+u6N5ZS4G3ThmjUQ6rCa3JerHVbgvEx+M9qwQujGLWeyx3 IyJmhNv5puLdd5fZK1qOriJbGtYaY+CU+n3OYig79O55AukKyWb3FJKHLtpibP5uJZ Si8kvCc6DQj1Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N2FCL6g9rz9rxH; Wed, 2 Nov 2022 06:03:26 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] ox-odt file: links are not pointing to the real files (was: [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/)]) In-Reply-To: References: <877d0xfu9m.fsf@localhost> <877d0wayn8.fsf@localhost> <87lep97tnn.fsf@localhost> <87ilkc30wd.fsf@localhost> <87ilk0jzab.fsf@localhost> <87iljzjkpu.fsf@localhost> Date: Wed, 02 Nov 2022 05:04:03 +0000 Message-ID: <87pme6kkvw.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667365491; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=jHV55AkNouncNDd2NUdz9FXdX8SIeNYIFQEWvdD2vwM=; b=p7Hm9Dt3xcO5GK153yAyeDI6lC/qKLuchvBYZO7W86Wqyn5khepSKGNpgov+taGpLUe6cC 3yjglD2mwluq5fj08Yc5S11Lpgjr0iDgpc4ksRGpAVZKmW8kZTy01sSCGfcH6Pod9MdgcF XnFk5ie4NkCfKjZbLq4cn7lRmSG7pgr3UZfkouX6e4FkW8iMHEI1bWnVklBYwtctB2Nsgr sSNYdKCvPAQspqP++sDLOLGkC0UzeWQ+pTmPoMcs47I8Prkk1qXVzEub/tz38NHlshL3mG b91gORZxt0920m9C477f8kqzzp+UFWrWisGisWmvWY9KbCVdGzy0+qKOa6JMhw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667365491; a=rsa-sha256; cv=none; b=QynnoHHqYAmOJnbMMOgZ1k2Hxx9XXbhKy5Uqw6b3uGzcJCdos4Apak1oKUkc3U0ZgTI4y8 S0Xqy4KZzI2SKiAyhZIyI38CuabRs8N6LV7for4hlk5XUofwxsoc/TYVh44/yB65/NrEv4 S7x6nfF6FncENwDpTWOG9NCgMuhyc6odGuzMO1tvB8/5cUTfWFqepM9W7hmvpdPOtGyi5i Yu/PAv2tKjfnKqyvTEZktOiAQvCRWcepQjY+mbQjJiDYhe4IjsLTtlVBSxzpWpcy3k72Oe 7DOvH95YMcCZnFOCvyNP7i51ZdeIpOoaaZywcoqgXd/K8OObO2horWSmXW2p0Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pyWzmsss; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.95 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=pyWzmsss; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E0EEF1DF58 X-Spam-Score: -1.95 X-Migadu-Scanner: scn1.migadu.com X-TUID: tQOVamQHYNDA --=-=-= Content-Type: text/plain Max Nikulin writes: >> - (org-export-file-uri raw-path)) >> + (pcase (org-export-file-uri raw-path) >> + (`(and (pred #'file-name-absolute-p) ,path) >> + path) > > I am in doubts if this branch may be executed at all. For absolute file > names `org-export-file-uri' adds "file:" prefix so I expect that > `file-name-absolute-p' is always false. You are indeed right. See the attached new version of the patch. > This time I am not lucky enough to accidentally face a case with invalid > link URI. However I do not think that for the link > > [[file:file-b.org]] > > "../file-b.org" is appropriate default description. I do not expect > "../" here. I also noticed this, but I feel that it is reasonable. In odt, "file-b.org" implies a resource inside the odt archive. "../file-b.org" will highlight that it is an external file. I'd prefer to leave the "../file" description for now and only do something when/if we hear from the ox-odt users. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v3-0001-org-odt-link-Fix-relative-file-links.patch >From c72d90244eb1a0fafb42a8c7841be82ad882efc5 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Mon, 31 Oct 2022 14:11:19 +0800 Subject: [PATCH v3] org-odt-link: Fix relative file links * lisp/ox-odt.el (org-odt-link): Append an extra "../" to relative links. This is needed to conform with OpenOffice convention to treat base path inside the odt archive. The path containing the odt file is thus "../". Reported-by: Ihor Radchenko Link: https://orgmode.org/list/87ilkc30wd.fsf@localhost --- lisp/ox-odt.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 15a9cf2de..11b834d5d 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -2688,7 +2688,14 @@ (defun org-odt-link (link desc info) ((member type '("http" "https" "ftp" "mailto")) (concat type ":" raw-path)) ((string= type "file") - (org-export-file-uri raw-path)) + (let ((path-uri (org-export-file-uri raw-path))) + (if (string-prefix-p "file://" path-uri) + path + ;; Otherwise, it is a relative path. + ;; OpenOffice treats base directory inside the odt + ;; archive. The directory containing the odt file + ;; is "../". + (concat "../" path)))) (t raw-path))) ;; Convert & to & for correct XML representation (path (replace-regexp-in-string "&" "&" path))) -- 2.35.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--