Skip to content

Commit 9011ed6

Browse files
committed
scroll to highlighted element for ranges too
1 parent 023c37f commit 9011ed6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

root/source.html

-3
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

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

0 commit comments

Comments
 (0)