From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: attachment: link type export to HTML invalid attach dir Date: Wed, 05 Feb 2020 17:54:00 +0100 Message-ID: <87y2th0yc7.fsf@nicolasgoaziou.fr> References: <87pnfnee7e.fsf@gmail.com> <87o8v6iq7n.fsf@gmail.com> <87tv4xl0z9.fsf@gmail.com> <87blr3v8tm.fsf@nicolasgoaziou.fr> <87eevyud9u.fsf@nicolasgoaziou.fr> <87pnfhrob4.fsf@nicolasgoaziou.fr> <871rrvrw0b.fsf@nicolasgoaziou.fr> <87muairkam.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:53085) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1izNwO-0000Py-8v for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 11:54:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1izNwM-0007PG-Cj for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 11:54:15 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:33095) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1izNwM-00073a-29 for emacs-orgmode@gnu.org; Wed, 05 Feb 2020 11:54:14 -0500 In-Reply-To: ("Gustav =?utf-8?Q?Wikstr=C3=B6m=22's?= message of "Sat, 25 Jan 2020 11:34:35 +0000") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Gustav =?utf-8?Q?Wikstr=C3=B6m?= Cc: "emacs-orgmode@gnu.org" Hello, Gustav Wikstr=C3=B6m writes: > That was kind of what I was trying to do, by allowing subtyping, so > that the parser would be more knowledgeable about particular types of > links, by allowing extended attributes. Maybe not implemented in the > most extensible way though I'll admit. Just to be clear, I firmly believe Element library should be as low-level as possible. Ideally (we're not there yet), it should not depend on any other part of Org. It should be the step (largely) above "re-search-forward". So, extending the parser to include knowledge to some other library in Org is not an option. Element is expected to dumbly stick to Org syntax, without knowing what it means. > My suggestion to the link parser would be to have the following propertie= s as the catch-all properties for links: > - type :: Which type of link protocol applies. E.g. file, http, ftp, atta= chment, duckduckgo (ex. for a custom link abbreviation to search ddg) > - raw-path :: The path to use for the particular protocol. Would contain = everything in the link following "protocol:" > - format :: Which format the link has. Plain, bracket or angular bracket Barring custom link abbreviations, this is already the case. > - description :: The description part of the link ([[protocol:path][descr= iption]]) Description is not meaningful here. This is parsed content. > - begin, end, post-blank :: The default properties used for all elements.= Not sure if contents-begin and contents-end are a part here as well. They are when the link has contents, i.e., a description. > As you've stated previously, from a performance perspective maybe it > will be best to not expand the specific properties and instead let the > expansion of those be handled in code by the link type owner (e.g. > org-attach.el for attachment links). More than performance, this is a design issue. > Ah yes. Just briefly looking at the docview code. Docview doesn't seem > to use the parser when extracting information about that "go to page" > information from the link. Which means docview links doesn't really > care how the link information is encoded in the parser anyways. Indeed. However, higher level functions, e.g., org-open-link, do care about it and ensure that "ol-docview.el" really processes a link. > Maybe if docview were allowed to encode custom docview information > into the parsed link in the parser it and others could reused that > encoded information later? Docview would be able to add > a ":go-to-page" option, for example. Just a thought. I'm quite sure this is a wrong way to go. > Most link types probably won't need custom link properties anyways. > But could maybe let the parser know stuff by use of higher order > functions? Or push for being important enough to be included into Org > and allowed to be known by the parser. Only syntax changes can go into the parser. Attachment links are regular links, not something that requires extending Org's syntax. Note that this is not the case of file links, which have a special syntax, e.g., [[./cat.jpg]]. > Ok, got it. Thanks for explaining. I'll admit it hasn't been totally > clear to me what the best way forward is. After refreshing my > understanding on links the conclusion I came to was that link > abbreviations in its current form was not a fitting concept for > attachment links. Attachments are pretty much similar to file links > though, so even if my intention isn't to blur the meaning they will > and should be treated very similar, since functionality is so similar. Functionality may be familiar, but their syntax is not the same, therefore, the differences should be handled elsewhere. > Speaking from the perspective of attachment links, if there were > a file link type exporter function available that could be used by > attachment links without code duplication. Where would live that function? ox.el is not an option since every exporter treats file links differently. As suggested already (I think) we could add a phase in ox.el that would expand attachment links into their file link counterpart automatically. This would avoid adding specific code in every export back-end. However, export back-end would miss the opportunity to handle attachment links specifically. This is one way or the other. > Yes, and the function that implements that would also need the user > argument as input. In addition to the link path. Patch welcome. I see no objection to extending :follow link parameter in "ol.el". > Anyways, patch attached that makes org-element not know about > attachments any longer, and moves most of the responsibility to > org-attach.el. The exporters still needs to know to use the new > function inside org-attach.el though. Thank you. Please apply it.=20 Now we can try improving the situation for exporters. Regards, --=20 Nicolas Goaziou