From mboxrd@z Thu Jan 1 00:00:00 1970 From: timor Subject: HTML Export of Links to Source Blocks seems broken Date: Thu, 16 Jun 2016 12:18:28 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDUNb-0002ZM-Pn for emacs-orgmode@gnu.org; Thu, 16 Jun 2016 06:18:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDUNZ-0007Fs-NZ for emacs-orgmode@gnu.org; Thu, 16 Jun 2016 06:18:30 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:35344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDUNZ-0007Ey-GG for emacs-orgmode@gnu.org; Thu, 16 Jun 2016 06:18:29 -0400 Received: by mail-wm0-x22c.google.com with SMTP id v199so185811972wmv.0 for ; Thu, 16 Jun 2016 03:18:29 -0700 (PDT) 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.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hello, considering the following example: -------------------------------------- #+NAME: test_fun #+BEGIN_SRC js function test_fun() { } #+END_SRC Link to [[test_fun]] #+NAME: another_test_fun #+BEGIN_SRC js function another_test_fun() { } #+END_SRC Link to [[another_test_fun]] ----------------------------------------- the exported html code creates to tags, like this: ------------------------------------ Link to 1 ------------------------------------ and this: ------------------------------------ Link to 1 ------------------------------------ Is that behavior desired? I would expect the link text to actually spell "test_fun" and "another_test_fun" in this case, since those are the names of the source blocks. As a workaround, is there anywhere in the exporter that I could hook into to change the link text myself? (org version 8.3.4) Regads, timor From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Fri, 17 Jun 2016 09:51:10 +0200 Message-ID: <874m8sxngx.fsf@saiph.selenimh> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDoYl-00046J-NX for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 03:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDoYh-0000LL-JG for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 03:51:22 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:36649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDoYh-0000LG-Bt for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 03:51:19 -0400 In-Reply-To: (timor's message of "Thu, 16 Jun 2016 12:18:28 +0200") 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.org@gnu.org Sender: "Emacs-orgmode" To: timor Cc: emacs-orgmode@gnu.org Hello, timor writes: > considering the following example: > > -------------------------------------- > #+NAME: test_fun > #+BEGIN_SRC js > function test_fun() { > > } #+END_SRC > > Link to [[test_fun]] > > #+NAME: another_test_fun > #+BEGIN_SRC js > function another_test_fun() { > > } > #+END_SRC > > Link to [[another_test_fun]] > ----------------------------------------- > > the exported html code creates to tags, like this: > > ------------------------------------ > Link to 1 > ------------------------------------ > > and this: > > ------------------------------------ > Link to 1 > ------------------------------------ > > Is that behavior desired? Yes, it is. Those are internals targets. Org handles them, well, internally. > I would expect the link text to actually spell "test_fun" and > "another_test_fun" in this case, since those are the names of the > source blocks. This is a reasonable expectation only if you are a bit careful about the value of the NAME keyword. See `org-latex-prefer-user-labels' for more information. > As a workaround, is there anywhere in the exporter that I could hook > into to change the link text myself? There is no equivalent to `org-latex-prefer-user-labels' in HTML export back-end at the moment. Though, patches to add one are welcome since this is a quite frequent request. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: timor Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Fri, 17 Jun 2016 12:46:26 +0200 Message-ID: References: <874m8sxngx.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrID-0005C2-Lz for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 06:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDrIC-0006RN-88 for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 06:46:29 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:36038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDrIC-0006RG-0M for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 06:46:28 -0400 Received: by mail-wm0-x22d.google.com with SMTP id f126so83838439wma.1 for ; Fri, 17 Jun 2016 03:46:27 -0700 (PDT) In-Reply-To: <874m8sxngx.fsf@saiph.selenimh> 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.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr Hello Nicolas, 2016-06-17 9:51 GMT+02:00 Nicolas Goaziou : >> the exported html code creates to tags, like this: >> >> ------------------------------------ >> Link to 1 >> ------------------------------------ >> >> and this: >> >> ------------------------------------ >> Link to 1 >> ------------------------------------ >> >> Is that behavior desired? > > Yes, it is. Those are internals targets. Org handles them, well, > internally. Why is the link text set to "1" in both cases? >> I would expect the link text to actually spell "test_fun" and >> "another_test_fun" in this case, since those are the names of the >> source blocks. > > This is a reasonable expectation only if you are a bit careful about the > value of the NAME keyword. See `org-latex-prefer-user-labels' for more > information. Thanks for the pointer. I tried to see the effect of that variable, but I noticed that for latex export, a \ref{orgsrcblock1} tag is created, although the listing in the exported latex code does not provide a "target" to link to at all. This is probably unrelated to my original problem, but keeps me from understanding how the mechanism around `org-latex-prefer-user-labels` works. (maybe related: http://emacs.stackexchange.com/questions/20947/how-to-reference-source-blocks-in-org-text) >> As a workaround, is there anywhere in the exporter that I could hook >> into to change the link text myself? > > There is no equivalent to `org-latex-prefer-user-labels' in HTML export > back-end at the moment. Though, patches to add one are welcome since > this is a quite frequent request. I was more thinking along the lines of treating internal links to named blocks in the same way that external links in HTML export are treated: For [[http://some/url]], the link text is simply set to the target, the target being the external web page. For [[some_named_block]] the link text should then also be the name of the target, in that case the target being the source block. I tried to debug what happens during html export, and traced the link resolution to `org-html-link`, with the link type being "fuzzy". Then, it correctly identifies the link target(via `org-export-resolve-fuzzy-link`), but for some reason seems to do some form of generic numbering for the link text. I would probably add a case for (org-element-type destination) being "src-block", and then use the :name property of the link destination as link text. Does that route make sense? Regards, timor From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Fri, 17 Jun 2016 13:56:01 +0200 Message-ID: <87r3bwvxke.fsf@saiph.selenimh> References: <874m8sxngx.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDsNj-0000Qp-FX for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 07:56:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDsNd-0005WK-HW for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 07:56:14 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:35714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDsNd-0005W6-BP for emacs-orgmode@gnu.org; Fri, 17 Jun 2016 07:56:09 -0400 In-Reply-To: (timor's message of "Fri, 17 Jun 2016 12:46:26 +0200") 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.org@gnu.org Sender: "Emacs-orgmode" To: timor Cc: emacs-orgmode@gnu.org Hello, timor writes: > Why is the link text set to "1" in both cases? This is just a nonsensical number because Org does not know what to number. If you want to number source blocks, you need to add a caption to them. > Thanks for the pointer. I tried to see the effect of that variable, > but I noticed that for latex export, a \ref{orgsrcblock1} tag is > created, although the listing in the exported latex code does not > provide a "target" to link to at all. If `org-latex-prefer-user-labels' is non-nil, no \ref{orgsrcblock1} is created. > I was more thinking along the lines of treating internal links to > named blocks in the same way that external links in HTML export are > treated: > For [[http://some/url]], the link text is simply set to the target, > the target being the external web page. > For [[some_named_block]] the link text should then also be the name of > the target, in that case the target being the source block. I think the way to go is to create an equivalent to `org-latex-prefer-user-labels' and to turn it off by default. It boils down to creating a wrapper around `org-export-get-reference', e.g. `org-html--reference' and replace it in the file. It should also be tested when cross-referencing data in a published project. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: timor Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Mon, 20 Jun 2016 10:18:51 +0200 Message-ID: References: <874m8sxngx.fsf@saiph.selenimh> <87r3bwvxke.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEuQ3-0006j8-Bz for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 04:18:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEuQ2-0001xR-7e for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 04:18:55 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:36918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEuQ2-0001wX-0F for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 04:18:54 -0400 Received: by mail-wm0-x233.google.com with SMTP id a66so66930262wme.0 for ; Mon, 20 Jun 2016 01:18:52 -0700 (PDT) In-Reply-To: <87r3bwvxke.fsf@saiph.selenimh> 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.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr Ok, if I understand you correctly, implementing the mechanism akin to the latex one, setting a new variable `org-html-prefer-user-labels` would change the relevant exported HTML for the following piece of org: ---------------------- #+NAME: test_fun #+BEGIN_SRC js :exports code function test_fun() { } #+END_SRC Link to [[test_fun]] #+CAPTION: Caption of Another Test Fun #+NAME: another_test_fun #+BEGIN_SRC js function another_test_fun() { } #+END_SRC Link to [[another_test_fun]] ----------------------- from #+BEGIN_EXAMPLE html
  ...
  
  ...
  
Link to 1 Link to 1 #+END_EXAMPLE to #+BEGIN_EXAMPLE html
  ...
  
  ...
  
Link to 1 Link to 1 #+END_EXAMPLE Looking at `org-html-link`, `org-export-get-reference` is only called to get the _internal_ reference. That works perfectly fine already, and I am quite happy with the way org mode generates labels/ids for the exported code. That should, however, have no influence of the link description (called `desc` in the code in `org-html-link`), which is the thing that I actually want to change? In summary, my exported output is supposed to look like that: #+BEGIN_EXAMPLE html
  ...
  
  ...
  
Link to test_fun Link to another_test_fun #+END_EXAMPLE Regards, timor 2016-06-17 13:56 GMT+02:00 Nicolas Goaziou : > Hello, > > timor writes: > >> Why is the link text set to "1" in both cases? > > This is just a nonsensical number because Org does not know what to > number. If you want to number source blocks, you need to add a caption > to them. > >> Thanks for the pointer. I tried to see the effect of that variable, >> but I noticed that for latex export, a \ref{orgsrcblock1} tag is >> created, although the listing in the exported latex code does not >> provide a "target" to link to at all. > > If `org-latex-prefer-user-labels' is non-nil, no \ref{orgsrcblock1} is > created. > >> I was more thinking along the lines of treating internal links to >> named blocks in the same way that external links in HTML export are >> treated: >> For [[http://some/url]], the link text is simply set to the target, >> the target being the external web page. >> For [[some_named_block]] the link text should then also be the name of >> the target, in that case the target being the source block. > > I think the way to go is to create an equivalent to > `org-latex-prefer-user-labels' and to turn it off by default. > > It boils down to creating a wrapper around `org-export-get-reference', > e.g. `org-html--reference' and replace it in the file. > > It should also be tested when cross-referencing data in a published > project. > > Regards, > > -- > Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Mon, 20 Jun 2016 14:52:37 +0200 Message-ID: <87fus82fai.fsf@saiph.selenimh> References: <874m8sxngx.fsf@saiph.selenimh> <87r3bwvxke.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEyh3-0006JJ-Qn for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 08:52:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEyh2-0007Vp-WC for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 08:52:45 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:59873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEyh2-0007Vl-Pc for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 08:52:44 -0400 In-Reply-To: (timor's message of "Mon, 20 Jun 2016 10:18:51 +0200") 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.org@gnu.org Sender: "Emacs-orgmode" To: timor Cc: emacs-orgmode@gnu.org Hello, timor writes: > Ok, if I understand you correctly, implementing the mechanism akin to > the latex one, setting a new variable `org-html-prefer-user-labels` would > change the relevant exported HTML for the following piece of org: > > ---------------------- > #+NAME: test_fun > #+BEGIN_SRC js :exports code > function test_fun() { > > } #+END_SRC > > Link to [[test_fun]] > > #+CAPTION: Caption of Another Test Fun > #+NAME: another_test_fun > #+BEGIN_SRC js > function another_test_fun() { > > } > #+END_SRC > > Link to [[another_test_fun]] ----------------------- > > from > > #+BEGIN_EXAMPLE html > >
>   ...
>   
> >
>   ...
>   
> > Link to 1 > > Link to 1 > > #+END_EXAMPLE > > to > > #+BEGIN_EXAMPLE html > >
>   ...
>   
> >
>   ...
>   
> > Link to 1 > > Link to 1 > > #+END_EXAMPLE Correct. > Looking at `org-html-link`, `org-export-get-reference` is only called > to get the _internal_ reference. That works perfectly fine already, and I am > quite happy with the way org mode generates labels/ids for the exported > code. That should, however, have no influence of the link description > (called `desc` in the code in `org-html-link`), which is the thing > that I actually want to change? They have no influence over the link description (which is "1" in both cases, as you noticed). If you want to change the description, simply provide one: [[test_fun][whatever]] Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: timor Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Mon, 20 Jun 2016 15:07:53 +0200 Message-ID: References: <874m8sxngx.fsf@saiph.selenimh> <87r3bwvxke.fsf@saiph.selenimh> <87fus82fai.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEyvk-0003B4-Hm for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 09:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEyvj-0002LP-Dg for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 09:07:56 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:34796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEyvj-0002LL-6M for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 09:07:55 -0400 Received: by mail-wm0-x236.google.com with SMTP id 187so6726397wmz.1 for ; Mon, 20 Jun 2016 06:07:55 -0700 (PDT) In-Reply-To: <87fus82fai.fsf@saiph.selenimh> 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.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr Hello Nicolas, 2016-06-20 14:52 GMT+02:00 Nicolas Goaziou : > They have no influence over the link description (which is "1" in both > cases, as you noticed). If you want to change the description, simply > provide one: > > [[test_fun][whatever]] Sorry for not being able to express myself more clearly, since this is the exact thing I was making a suggestion about in the first place. The thing is, I have a lot of code blocks that define functions, which are named exactly after that function. And as I frequently want to reference one of those in the text, I don't want to say [[test_fun][test_fun]] .. [[another_long_function][another_long_function]]... everytime, since [[test_fun]] already contains all the information needed to generate the link, and the description. The description is always the same as the link target. That is why I would want to change the way that the default link description is generated in the case that none is provided. I think that would make sense, given that the way the default description is generated at the moment does not seem to provide any benefit. > Regards, > > -- > Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: HTML Export of Links to Source Blocks seems broken Date: Mon, 20 Jun 2016 22:23:54 +0200 Message-ID: <877fdjbodh.fsf@saiph.selenimh> References: <874m8sxngx.fsf@saiph.selenimh> <87r3bwvxke.fsf@saiph.selenimh> <87fus82fai.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF5jq-0008G3-An for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 16:24:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF5jo-0005oH-JM for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 16:24:05 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:47876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF5jo-0005nj-CY for emacs-orgmode@gnu.org; Mon, 20 Jun 2016 16:24:04 -0400 In-Reply-To: (timor's message of "Mon, 20 Jun 2016 15:07:53 +0200") 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.org@gnu.org Sender: "Emacs-orgmode" To: timor Cc: emacs-orgmode@gnu.org timor writes: > The thing is, I have a lot of code blocks that define functions, which > are named exactly after that function. And as I frequently want to > reference one of those in the text, I don't want to say > > [[test_fun][test_fun]] .. > [[another_long_function][another_long_function]]... > > everytime, since [[test_fun]] already contains all the information > needed to generate the link, and the description. The description is > always the same as the link target. That is why I would want to > change the way that the default link description is generated in the > case that none is provided. You can use a hook, which will work at the Org level, or a filter, to work at the HTML level. See, e.g., (info "(org) Advanced configuration"). > I think that would make sense, given that the way the default > description is generated at the moment does not seem to provide any > benefit. It does, but not in your example. See (info "(org) Internal links") for details. Regards,