Hello Nicolas, 2016-06-17 9:51 GMT+02:00 Nicolas Goaziou <m...@nicolasgoaziou.fr>: >> the exported html code creates to <a> tags, like this: >> >> ------------------------------------ >> Link to <a href="#orgsrcblock1">1</a> >> ------------------------------------ >> >> and this: >> >> ------------------------------------ >> Link to <a href="#orgsrcblock2">1</a> >> ------------------------------------ >> >> 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