Section Markup for Rich Contents/Literal Examples
in org documentation contains the following text:
In literal examples, Org interprets strings like ‘(ref:name)’ as labels, and use them as targets for special hyperlinks like ‘[[(name)]]’—i.e., the reference name enclosed in single parenthesis. In HTML, hovering the mouse over such a link remote-highlights the corresponding code line, which is kind of cool.
It then uses the following example:
#+BEGIN_SRC emacs-lisp -n -r
(save-excursion (ref:sc)
(goto-char (point-min)) (ref:jump)
#+END_SRC
In line [[(sc)]] we remember the current position. [[(jump)][Line (jump)]] jumps to point-min.
I remember to have had it work, but it doesn't work any more. I mean, when I put the mouse on the link in the generated html, nothing is highlighted.
Looking at the generated html I can see referenced lines are put in a span
<div class="org-src-container">
<pre class="src src-emacs-lisp"><span id="coderef-sc" class="coderef-off"><span class="linenr">1: </span> (<span style="color: #531ab6;">save-excursion</span></span>
<span id="coderef-jump" class="coderef-off"><span class="linenr">2: </span> (goto-char (point-min))</span>
</pre>
</div>
<p>
And the reference is given an onmouseover
event calling a CodeHighlightOn
javascript function:
In line <a href="#coderef-sc" class="coderef" onmouseover="CodeHighlightOn(this, 'coderef-sc');" onmouseout="CodeHighlightOff(this, 'coderef-sc');">1</a> we remember the current position. <a href="#coderef-jump" class="coderef" onmouseover="CodeHighlightOn(this, 'coderef-jump');" onmouseout="CodeHighlightOff(this, 'coderef-jump');">Line 2</a>
jumps to point-min.
So I guess the problem is I lack the javascript code defining these CodeHighlightOn
and CodeHighlightOff
functions.
So the question is: where are these functions defined? (and why don't I have them, the documentation suggests it should work out of the box).
This is org mode 9.6.11 on emacs 30.0.50.
org-html-head-include-scripts
: it'st
by default but maybe you have turned it off?org-html-scripts
at the top ofox-html.el
, which is inlined into the HTML file byorg-html--build-head
iforg-html-head-include-scripts
is non-nil.nil
in the sense thatemacs -Q
starts with that value. But I'm tired and confused and need sleep, so maybe this is all wrong.org-html-head-include-scripts
tot
does solve the issue. Thanks!