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