8000 bump deps and refactor code · akoenig/github-markdown-css@688be4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 688be4d

Browse files
committed
bump deps and refactor code
1 parent 209ee6d commit 688be4d

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

index.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,45 @@ function cleanupCss(str) {
4343
var mdBodyProps = [];
4444

4545
style.stylesheet.rules = style.stylesheet.rules.filter(function (el) {
46-
if (el.type === 'keyframes' || el.type === 'comment') {
46+
if (el.type === 'keyframes' || el.type === 'comment' || el.type === 'font-face') {
4747
return false;
4848
}
4949

50-
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])) {
51-
return false;
52-
}
50+
if (el.type ==='rule') {
51+
if (/::-webkit-validation|:-moz-placeholder|^\.integrations-slide-content|^\.prose-diff|@font-face|^\.octicon|^button::|^\.markdown-body .+(:hover|\.octicon)|^article$/.test(el.selectors[0])) {
52+
return false;
53+
}
5354

54-
if (el.selectors.length === 1 && /^(?:html|body)$/.test(el.selectors[0])) {
55-
el.declarations = el.declarations.filter(function (declaration) {
56-
if (!/^font|^(?:line-height|color)$|text-size-adjust$/.test(declaration.property)) {
57-
return false;
58-
}
55+
if (el.selectors.length === 1 && /^(?:html|body)$/.test(el.selectors[0])) {
56+
el.declarations = el.declarations.filter(function (declaration) {
57+
if (!/^font|^(?:line-height|color)$|text-size-adjust$/.test(declaration.property)) {
58+
return false;
59+
}
5960

60-
return true;
61-
});
62-
}
63-
64-
el.selectors = el.selectors.map(function (selector) {
65-
if (/^(?:body|html)$/.test(selector)) {
66-
selector = '.markdown-body';
61+
return true;
62+
});
6763
}
6864

69-
if (!/\.markdown-body/.test(selector)) {
70-
selector = '.markdown-body ' + selector;
71-
}
65+
el.selectors = el.selectors.map(function (selector) {
66+
if (/^(?:body|html)$/.test(selector)) {
67+
selector = '.markdown-body';
68+
}
7269

73-
return selector;
74-
});
70+
if (!/\.markdown-body/.test(selector)) {
71+
selector = '.markdown-body ' + selector;
72+
}
7573

76-
if (el.declarations.length === 0) {
77-
return false;
74+
return selector;
75+
});
76+
77+
// collect `.markdown-body` rules
78+
if (el.selectors.length === 1 && el.selectors[0] === '.markdown-body') {
79+
[].push.apply(mdBodyProps, el.declarations);
80+
return false;
81+
}
7882
}
7983

80-
// collect `.markdown-body` rules
81-
if (el.selectors.length === 1 && el.selectors[0] === '.markdown-body') {
82-
[].push.apply(mdBodyProps, el.declarations);
84+
if (el.declarations.length === 0) {
8385
return false;
8486
}
8587

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
"email": "sindresorhus@gmail.com",
1313
"url": "http://sindresorhus.com"
1414
},
15-
"contributors": [{
16-
"name": "Benjamin Tan",
17-
"email": "demoneaux@gmail.com",
18-
"url": "http://d10.github.io/"
19-
}],
15+
"contributors": [
16+
{
17+
"name": "Benjamin Tan",
18+
"email": "demoneaux@gmail.com",
19+
"url": "http://d10.github.io/"
20+
}
21+
],
2022
"engines": {
2123
"node": ">=0.10.0"
2224
},
@@ -40,8 +42,8 @@
4042
"stylesheet"
4143
],
4244
"dependencies": {
43-
"cheerio": "^0.16.0",
44-
"css": "^1.6.0",
45+
"cheerio": "^0.17.0",
46+
"css": "^2.0.0",
4547
"got": "^0.3.0",
4648
"temp-write": "^0.3.0",
4749
"uncss": "^0.8.1"

0 commit comments

Comments
 (0)
0