mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Move html-minifier use to lodash.github.io.
This commit is contained in:
@@ -96,37 +96,19 @@ function build(type) {
|
||||
|
||||
// Unwrap elements containing only text.
|
||||
$('.highlight :not([class])').each(function() {
|
||||
const $el = $(this);
|
||||
if (_.every($(el).children(), ['type', 'text'])) {
|
||||
let $el = $(this);
|
||||
while ($el[0] && _.every($el.children(), ['type', 'text'])) {
|
||||
$el.replaceWith($el.text());
|
||||
$el = $el.parent();
|
||||
}
|
||||
});
|
||||
|
||||
// Consolidate hightlights comments.
|
||||
// Collapse hightlights comments.
|
||||
$('.highlight [class~="comment"] > [class~="comment"]').each(function() {
|
||||
const $parent = $(this).parent();
|
||||
$parent.text($parent.text());
|
||||
});
|
||||
|
||||
// Minify hightlights snippets.
|
||||
$('.highlight').each(function() {
|
||||
const $div = $(this);
|
||||
$div.html(minify($div.html(), {
|
||||
'collapseBooleanAttributes': true,
|
||||
'collapseInlineTagWhitespace': true,
|
||||
'collapseWhitespace': true,
|
||||
'removeAttributeQuotes': true,
|
||||
'removeComments': true,
|
||||
'removeEmptyAttributes': true,
|
||||
'removeEmptyElements': true,
|
||||
'removeOptionalTags': true,
|
||||
'removeRedundantAttributes': true
|
||||
})
|
||||
.replace(/(?:<span>[^<]+<\/span>){2,}/g, match =>
|
||||
match.replace(/<\/?span>/g, '')
|
||||
));
|
||||
});
|
||||
|
||||
const html = [
|
||||
// Append YAML front matter.
|
||||
'---',
|
||||
|
||||
Reference in New Issue
Block a user