mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Refine ext detection.
This commit is contained in:
@@ -28,6 +28,8 @@ const highlights = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exts = _.keys(highlights);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts Lodash method references into documentation links.
|
* Converts Lodash method references into documentation links.
|
||||||
*
|
*
|
||||||
@@ -117,7 +119,8 @@ function tidyHighlights($) {
|
|||||||
$('.highlight').each(function() {
|
$('.highlight').each(function() {
|
||||||
let $spans;
|
let $spans;
|
||||||
const $parent = $(this);
|
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);
|
$parent.addClass(ext);
|
||||||
|
|
||||||
@@ -132,7 +135,7 @@ function tidyHighlights($) {
|
|||||||
$parent.find('[class]').each(function() {
|
$parent.find('[class]').each(function() {
|
||||||
const $element = $(this);
|
const $element = $(this);
|
||||||
const classes = $element.attr('class').split(' ');
|
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);
|
$element.attr('class', attr || null);
|
||||||
});
|
});
|
||||||
// Collapse nested comment highlights.
|
// Collapse nested comment highlights.
|
||||||
|
|||||||
Reference in New Issue
Block a user