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: Mon, 20 Jun 2016 10:18:51 +0200	[thread overview]
Message-ID: <CAAX25XD+4kDzEEW=dMRWEzYkJwjafOUNbnups_nd2CGbUoz=3w@mail.gmail.com> (raw)
In-Reply-To: <87r3bwvxke.fsf@saiph.selenimh>

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

  <pre class="src src-js" id="orgsrcblock1">
  ...
  </pre>

  <pre class="src src-js" id="orgsrcblock2">
  ...
  </pre>

  Link to <a href="#orgsrcblock1">1</a>

  Link to <a href="#orgsrcblock2">1</a>

#+END_EXAMPLE

to

#+BEGIN_EXAMPLE html

  <pre class="src src-js" id="test_fun">
  ...
  </pre>

  <pre class="src src-js" id="another_test_fun">
  ...
  </pre>

  Link to <a href="#test_fun">1</a>

  Link to <a href="#another_test_fun">1</a>

#+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

  <pre class="src src-js" id="orgsrcblock1">
  ...
  </pre>

  <pre class="src src-js" id="orgsrcblock2">
  ...
  </pre>

  Link to <a href="#orgsrcblock1">test_fun</a>

  Link to <a href="#orgsrcblock2">another_test_fun</a>

#+END_EXAMPLE

Regards,
timor

2016-06-17 13:56 GMT+02:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:
> Hello,
>
> timor <timor.dd@gmail.com> 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

  reply	other threads:[~2016-06-20  8:18 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
2016-06-17 11:56     ` Nicolas Goaziou
2016-06-20  8:18       ` timor [this message]
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='CAAX25XD+4kDzEEW=dMRWEzYkJwjafOUNbnups_nd2CGbUoz=3w@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).