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