mirror of
https://github.com/sindresorhus/github-markdown-css.git
synced 2024-03-22 13:10:53 +08:00
don't need to write to disk anymore
UnCSS now accepts an HTML string as input
This commit is contained in:
parent
bfa19de865
commit
672d44b98a
12
index.js
12
index.js
|
@ -2,7 +2,6 @@
|
|||
var got = require('got');
|
||||
var cheerio = require('cheerio');
|
||||
var uncss = require('uncss');
|
||||
var tempWrite = require('temp-write');
|
||||
|
||||
function getCss(cb) {
|
||||
got('https://github.com', function (err, data) {
|
||||
|
@ -26,14 +25,17 @@ function getCss(cb) {
|
|||
}
|
||||
|
||||
function getRenderedFixture(cb) {
|
||||
got('https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md', function (err, data) {
|
||||
var url = 'https://github.com/sindresorhus/github-markdown-css/blob/gh-pages/fixture.md';
|
||||
|
||||
got(url, function (err, data) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
var $ = cheerio.load(data);
|
||||
var html = $('.markdown-body').parent().html();
|
||||
|
||||
cb(null, tempWrite.sync($('.markdown-body').parent().html()));
|
||||
cb(null, html);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -99,7 +101,7 @@ function cleanupCss(str) {
|
|||
}
|
||||
|
||||
module.exports = function (cb) {
|
||||
getRenderedFixture(function (err, fixture) {
|
||||
getRenderedFixture(function (err, html) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -109,7 +111,7 @@ module.exports = function (cb) {
|
|||
return cb(err);
|
||||
}
|
||||
|
||||
uncss([fixture], {
|
||||
uncss(html, {
|
||||
stylesheets: stylesheets,
|
||||
ignore: [/^\.highlight/]
|
||||
}, function (err, css) {
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
"dependencies": {
|
||||
"cheerio": "^0.17.0",
|
||||
"css": "^2.0.0",
|
||||
"got": "^0.3.0",
|
||||
"temp-write": "^0.3.1",
|
||||
"got": "^1.0.0",
|
||||
"uncss": "^0.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user