bump deps and refactor code

This commit is contained in:
Sindre Sorhus 2014-06-22 19:10:18 +02:00
parent 209ee6dd9f
commit 688be4daf6
2 changed files with 38 additions and 34 deletions

View File

@ -43,46 +43,48 @@ function cleanupCss(str) {
var mdBodyProps = [];
style.stylesheet.rules = style.stylesheet.rules.filter(function (el) {
if (el.type === 'keyframes' || el.type === 'comment') {
if (el.type === 'keyframes' || el.type === 'comment' || el.type === 'font-face') {
return false;
}
if (el.type === 'rule' && /::-webkit-validation|:-moz-placeholder|^\.integrations-slide-content|^\.prose-diff|@font-face|^\.octicon|^button::|^\.markdown-body .+(:hover|\.octicon)|^article$/.test(el.selectors[0])) {
return false;
}
if (el.type ==='rule') {
if (/::-webkit-validation|:-moz-placeholder|^\.integrations-slide-content|^\.prose-diff|@font-face|^\.octicon|^button::|^\.markdown-body .+(:hover|\.octicon)|^article$/.test(el.selectors[0])) {
return false;
}
if (el.selectors.length === 1 && /^(?:html|body)$/.test(el.selectors[0])) {
el.declarations = el.declarations.filter(function (declaration) {
if (!/^font|^(?:line-height|color)$|text-size-adjust$/.test(declaration.property)) {
return false;
if (el.selectors.length === 1 && /^(?:html|body)$/.test(el.selectors[0])) {
el.declarations = el.declarations.filter(function (declaration) {
if (!/^font|^(?:line-height|color)$|text-size-adjust$/.test(declaration.property)) {
return false;
}
return true;
});
}
el.selectors = el.selectors.map(function (selector) {
if (/^(?:body|html)$/.test(selector)) {
selector = '.markdown-body';
}
return true;
if (!/\.markdown-body/.test(selector)) {
selector = '.markdown-body ' + selector;
}
return selector;
});
// collect `.markdown-body` rules
if (el.selectors.length === 1 && el.selectors[0] === '.markdown-body') {
[].push.apply(mdBodyProps, el.declarations);
return false;
}
}
el.selectors = el.selectors.map(function (selector) {
if (/^(?:body|html)$/.test(selector)) {
selector = '.markdown-body';
}
if (!/\.markdown-body/.test(selector)) {
selector = '.markdown-body ' + selector;
}
return selector;
});
if (el.declarations.length === 0) {
return false;
}
// collect `.markdown-body` rules
if (el.selectors.length === 1 && el.selectors[0] === '.markdown-body') {
[].push.apply(mdBodyProps, el.declarations);
return false;
}
return true;
});

View File

@ -12,11 +12,13 @@
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"contributors": [{
"name": "Benjamin Tan",
"email": "demoneaux@gmail.com",
"url": "http://d10.github.io/"
}],
"contributors": [
{
"name": "Benjamin Tan",
"email": "demoneaux@gmail.com",
"url": "http://d10.github.io/"
}
],
"engines": {
"node": ">=0.10.0"
},
@ -40,8 +42,8 @@
"stylesheet"
],
"dependencies": {
"cheerio": "^0.16.0",
"css": "^1.6.0",
"cheerio": "^0.17.0",
"css": "^2.0.0",
"got": "^0.3.0",
"temp-write": "^0.3.0",
"uncss": "^0.8.1"