We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e13b9d6 commit d91656aCopy full SHA for d91656a
root/static/js/syntaxhighlighter.js
@@ -150,10 +150,19 @@ $(function () {
150
151
if (source.length) {
152
source.find('.syntaxhighlighter .gutter .line').each(function(i, el) {
153
+ var line = $(el);
154
var res;
- if (res = el.className.match(/(^|\s)number(\d+)(\s|$)/)) {
155
- var id = 'L' + res[2];
156
- $(el).contents().wrap('<a href="#'+id+'" id="'+id+'"></a>');
+ if (res = line.attr('class').match(/(^|\s)number(\d+)(\s|$)/)) {
+ var linenr = res[2];
157
+ var id = 'L' + linenr;
158
+ line.contents().wrap('<a href="#'+id+'" id="'+id+'"></a>');
159
+ var link = line.children('a');
160
+ link.click(function(e) {
161
+ e.preventDefault();
162
+ link.removeAttr('id');
163
+ document.location.hash = '#' + id;
164
+ link.attr('id', id);
165
+ });
166
}
167
});
168
0 commit comments