Move html-minifier use to lodash.github.io.

This commit is contained in:
John-David Dalton
2016-09-04 01:23:16 -07:00
parent 1344803e7e
commit 9dd291a96e
2 changed files with 4 additions and 23 deletions

View File

@@ -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.
'---',

View File

@@ -38,7 +38,6 @@
"ecstatic": "^2.1.0",
"fs-extra": "~0.30.0",
"glob": "^7.0.6",
"html-minifier": "^3.0.2",
"istanbul": "0.4.5",
"jquery": "^3.1.0",
"jscs": "^3.0.7",