Skip to content

Commit e13b9d6

Browse files
committed
re-highlight rows when location hash changes
1 parent 3cbd848 commit e13b9d6

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
@@ -162,6 +162,19 @@ $(function () {
162162
var el = $(res[1]);
163163
$('html, body').scrollTop(el.offset().top);
164164
}
165+
166+
$(window).on('hashchange', function() {
167+
var lineMatch;
168+
if (lineMatch = document.location.hash.match(/^#L(\d+(-\d+)?(,\d+(-\d+)?)*)$/) ) {
169+
source.attr('data-line', lineMatch[1]);
170+
var selector = $.map(
171+
parseLines(lineMatch[1]),
172+
function (e, i) { return '.number' + e }
173+
).join(', ');
174+
source.find('.highlighted').removeClass('highlighted');
175+
source.find('.syntaxhighlighter .line').filter(selector).addClass('highlighted');
176+
}
177+
});
165178
}
166179
});
167180

0 commit comments

Comments
 (0)