emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: timor <timor.dd@gmail.com>
To: emacs-orgmode@gnu.org, mail@nicolasgoaziou.fr
Subject: Re: HTML Export of Links to Source Blocks seems broken
Date: Fri, 17 Jun 2016 12:46:26 +0200	[thread overview]
Message-ID: <CAAX25XDAETVCrUp=PR7humTDDL2cDTbS5muWESGLb6s3h6YwKQ@mail.gmail.com> (raw)
In-Reply-To: <874m8sxngx.fsf@saiph.selenimh>

Hello Nicolas,

2016-06-17 9:51 GMT+02:00 Nicolas Goaziou <mail@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

  reply	other threads:[~2016-06-17 10:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 10:18 HTML Export of Links to Source Blocks seems broken timor
2016-06-17  7:51 ` Nicolas Goaziou
2016-06-17 10:46   ` timor [this message]
2016-06-17 11:56     ` Nicolas Goaziou
2016-06-20  8:18       ` timor
2016-06-20 12:52         ` Nicolas Goaziou
2016-06-20 13:07           ` timor
2016-06-20 20:23             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAX25XDAETVCrUp=PR7humTDDL2cDTbS5muWESGLb6s3h6YwKQ@mail.gmail.com' \
    --to=timor.dd@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).