diff --git a/github-markdown.css b/github-markdown.css index 97b7547..f23fe99 100644 --- a/github-markdown.css +++ b/github-markdown.css @@ -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; } diff --git a/index.js b/index.js index 2414fe7..322dc24 100644 --- a/index.js +++ b/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); }