mirror of
https://github.com/sindresorhus/github-markdown-css.git
synced 2024-03-22 13:10:53 +08:00
merge duplicate .markdown-body
rules
This commit is contained in:
parent
ce827dda3c
commit
209ee6dd9f
|
@ -2,6 +2,13 @@
|
|||
font-family: sans-serif;
|
||||
-ms-text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
font: 13px Helvetica, arial, freesans, clean, sans-serif;
|
||||
line-height: 1.4;
|
||||
color: #333333;
|
||||
font-size: 15px;
|
||||
line-height: 1.7;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.markdown-body a {
|
||||
|
@ -52,15 +59,6 @@
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
.markdown-body {
|
||||
font: 13px Helvetica, arial, freesans, clean, sans-serif;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.markdown-body {
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.markdown-body * {
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
|
@ -164,13 +162,6 @@
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.markdown-body {
|
||||
font-size: 15px;
|
||||
line-height: 1.7;
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.markdown-body>*:first-child {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
|
22
index.js
22
index.js
|
@ -40,6 +40,7 @@ function getRenderedFixture(cb) {
|
|||
function cleanupCss(str) {
|
||||
var css = require('css');
|
||||
var style = css.parse(str);
|
||||
var mdBodyProps = [];
|
||||
|
||||
style.stylesheet.rules = style.stylesheet.rules.filter(function (el) {
|
||||
if (el.type === 'keyframes' || el.type === 'comment') {
|
||||
|
@ -60,10 +61,6 @@ function cleanupCss(str) {
|
|||
});
|
||||
}
|
||||
|
||||
if (el.declarations.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
el.selectors = el.selectors.map(function (selector) {
|
||||
if (/^(?:body|html)$/.test(selector)) {
|
||||
selector = '.markdown-body';
|
||||
|
@ -76,9 +73,26 @@ function cleanupCss(str) {
|
|||
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;
|
||||
});
|
||||
|
||||
// merge `.markdown-body` rules
|
||||
style.stylesheet.rules.unshift({
|
||||
type: 'rule',
|
||||
selectors: ['.markdown-body'],
|
||||
declarations: mdBodyProps
|
||||
});
|
||||
|
||||
return css.stringify(style);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user