mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27: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.
|
// Unwrap elements containing only text.
|
||||||
$('.highlight :not([class])').each(function() {
|
$('.highlight :not([class])').each(function() {
|
||||||
const $el = $(this);
|
let $el = $(this);
|
||||||
if (_.every($(el).children(), ['type', 'text'])) {
|
while ($el[0] && _.every($el.children(), ['type', 'text'])) {
|
||||||
$el.replaceWith($el.text());
|
$el.replaceWith($el.text());
|
||||||
|
$el = $el.parent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Consolidate hightlights comments.
|
// Collapse hightlights comments.
|
||||||
$('.highlight [class~="comment"] > [class~="comment"]').each(function() {
|
$('.highlight [class~="comment"] > [class~="comment"]').each(function() {
|
||||||
const $parent = $(this).parent();
|
const $parent = $(this).parent();
|
||||||
$parent.text($parent.text());
|
$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 = [
|
const html = [
|
||||||
// Append YAML front matter.
|
// Append YAML front matter.
|
||||||
'---',
|
'---',
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
"ecstatic": "^2.1.0",
|
"ecstatic": "^2.1.0",
|
||||||
"fs-extra": "~0.30.0",
|
"fs-extra": "~0.30.0",
|
||||||
"glob": "^7.0.6",
|
"glob": "^7.0.6",
|
||||||
"html-minifier": "^3.0.2",
|
|
||||||
"istanbul": "0.4.5",
|
"istanbul": "0.4.5",
|
||||||
"jquery": "^3.1.0",
|
"jquery": "^3.1.0",
|
||||||
"jscs": "^3.0.7",
|
"jscs": "^3.0.7",
|
||||||
|
|||||||
Reference in New Issue
Block a user