Refine ext detection.

This commit is contained in:
John-David Dalton
2016-09-25 12:10:57 -07:00
parent 4d6aade733
commit fac9501840

View File

@@ -28,6 +28,8 @@ const highlights = {
]
};
const exts = _.keys(highlights);
/**
* Converts Lodash method references into documentation links.
*
@@ -117,7 +119,8 @@ function tidyHighlights($) {
$('.highlight').each(function() {
let $spans;
const $parent = $(this);
const ext = $parent.find('.source,.text').first().attr('class').split(' ').pop();
const classes = $parent.find('.source,.text').first().attr('class').split(' ');
const ext = _(classes).intersection(exts).last();
$parent.addClass(ext);
@@ -132,7 +135,7 @@ function tidyHighlights($) {
$parent.find('[class]').each(function() {
const $element = $(this);
const classes = $element.attr('class').split(' ');
const attr = _.intersection(classes, highlights[ext]).join(' ');
const attr = _(classes).intersection(highlights[ext]).join(' ');
$element.attr('class', attr || null);
});
// Collapse nested comment highlights.