-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
220 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
var gulp = require('gulp'), | ||
jshint = require('gulp-jshint'), | ||
mocha = require('gulp-mocha'); | ||
|
||
var paths = { | ||
scripts: ['./*.js', '!./gulpfile.js'] | ||
}; | ||
|
||
gulp.task('lint', function() { | ||
return gulp.src(paths.scripts) | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('default')); | ||
}); | ||
|
||
gulp.task('test', function() { | ||
return gulp.src('./test/*.js') | ||
.pipe(mocha({reporter: 'dot'})); | ||
}); | ||
|
||
gulp.task('watch', function () { | ||
gulp.watch(paths.scripts, ['lint', 'test']); | ||
}); | ||
|
||
gulp.task('default', ['lint', 'test', 'watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
|
||
</head> | ||
<body style="font-family: Arial;"> | ||
<h1 style="border: 1px solid #ccc; color: blue;">Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline" style="font-size: 24px; padding: 5px;">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
|
||
</head> | ||
<body style="font-family: Arial;"> | ||
<h1 style="border: 1px solid #ccc; color: red;">Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline" style="font-size: 24px; padding: 5px;">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
|
||
|
||
</head> | ||
<body style="font-family: Arial;"> | ||
<h1 style="border: 1px solid #ccc; color: blue;">Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline" style="font-size: 24px; padding: 5px;">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
font-family: Arial; | ||
} | ||
h1 { | ||
color: blue; | ||
} | ||
.headline { | ||
font-size: 24px; | ||
} | ||
|
||
td { | ||
padding: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
border: 1px solid #ccc; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="file.css"/> | ||
</head> | ||
<body> | ||
<h1>Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
font-family: Arial; | ||
} | ||
h1 { | ||
color: blue; | ||
} | ||
.headline { | ||
font-size: 24px; | ||
} | ||
|
||
td { | ||
padding: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
border: 1px solid #ccc; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="file.css"/> | ||
</head> | ||
<body> | ||
<h1>Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
body { | ||
font-family: Arial; | ||
} | ||
h1 { | ||
color: red; | ||
} | ||
.headline { | ||
font-size: 24px; | ||
} | ||
|
||
td { | ||
padding: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
h1 { | ||
border: 1px solid #ccc; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="file.css"/> | ||
</head> | ||
<body> | ||
<h1>Hi</h1> | ||
<table> | ||
<tr> | ||
<td class="headline">Some Headline</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* jshint node: true */ | ||
/* global describe, it */ | ||
|
||
'use strict'; | ||
|
||
var should = require('should'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
gutil = require('gulp-util'), | ||
inlineCss = require('../index'); | ||
|
||
function getFile(filePath) { | ||
return new gutil.File({ | ||
path: path.resolve(filePath), | ||
cwd: './test/', | ||
base: path.dirname(filePath), | ||
contents: new Buffer(String(fs.readFileSync(filePath))) | ||
}); | ||
} | ||
|
||
function compare(fixturePath, expectedPath, options, done) { | ||
var file = getFile(fixturePath); | ||
|
||
options.url = 'file://' + file.path; | ||
|
||
inlineCss(file.contents.toString('utf8'), options, function (err, html) { | ||
html.should.be.equal(String(fs.readFileSync(expectedPath))); | ||
|
||
done(); | ||
}); | ||
} | ||
|
||
describe('inline-css', function() { | ||
it('Should convert linked css to inline css', function(done) { | ||
var options = {}; | ||
compare(path.join('test', 'fixtures', 'in.html'), path.join('test', 'expected', 'out.html'), options, done); | ||
}); | ||
|
||
it('Should inline css in multiple HTML files', function(done) { | ||
var options = {}; | ||
compare(path.join('test', 'fixtures', 'multiple', 'one', 'in.html'), path.join('test', 'expected', 'multiple', 'one', 'out.html'), options, function () {}); | ||
compare(path.join('test', 'fixtures', 'multiple', 'two', 'in.html'), path.join('test', 'expected', 'multiple', 'two', 'out.html'), options, done); | ||
}); | ||
}); |