Skip to content

Commit ded2ec9

Browse files
committed
re-highlight rows when location hash changes
1 parent 4b9b410 commit ded2ec9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

root/static/js/syntaxhighlighter.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ $(function () {
163163
var el = $(res[1]);
164164
$('html, body').scrollTop(el.offset().top);
165165
}
166+
167+
$(window).on('hashchange', function() {
168+
var lineMatch;
169+
if (lineMatch = document.location.hash.match(/^#L(\d+(-\d+)?(,\d+(-\d+)?)*)$/) ) {
170+
source.attr('data-line', lineMatch[1]);
171+
var selector = $.map(
172+
parseLines(lineMatch[1]),
173+
function (e, i) { return '.number' + e }
174+
).join(', ');
175+
source.find('.highlighted').removeClass('highlighted');
176+
source.find('.syntaxhighlighter .line').filter(selector).addClass('highlighted');
177+
}
178+
});
166179
}
167180
});
168181

0 commit comments

Comments
 (0)