Skip to content

Commit 2b28bb4

Browse files
committed
scroll to highlighted element for ranges too
1 parent 244d3e4 commit 2b28bb4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

root/source.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,4 @@
7171
<% IF module.sloc > 0 %>
7272
togglePod();
7373
<% END %>
74-
if(document.location.hash)
75-
document.location.href = document.location.href;
76-
});
7774
</script>

root/static/js/syntaxhighlighter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ $(function () {
157157
$(el).contents().wrap('<a href="#'+id+'" id="'+id+'"></a>');
158158
}
159159
});
160+
161+
var res;
162+
if (res = document.location.hash.match(/^(#L\d+)(-|,|$)/)) {
163+
var el = $(res[1]);
164+
$('html, body').scrollTop(el.offset().top);
165+
}
160166
}
161167
});
162168

0 commit comments

Comments
 (0)