├── .gitignore ├── .jshintrc ├── .travis.yml ├── README.md ├── html-autoprefixer.png ├── lib └── main.js ├── package.json └── test ├── .jshintrc └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | node_modules 3 | npm-debug.log 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "strict": true 4 | } 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 5 4 | - 4 5 | - 0.12 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # html-autoprefixer 2 | 3 | ![html-autoprefixer](../master/html-autoprefixer.png?raw=true) 4 | 5 | Autoprefix all CSS inside an html page - CSS inside style tags and inside style attributes. 6 | 7 | [![BuildStatus](https://travis-ci.org/Rebelmail/html-autoprefixer.png?branch=master)](https://travis-ci.org/Rebelmail/html-autoprefixer) 8 | [![NPM version](https://badge.fury.io/js/html-autoprefixer.png)](http://badge.fury.io/js/html-autoprefixer) 9 | 10 | ```javascript 11 | var prefixed = htmlAutoprefixer.process(htmlString); 12 | ``` 13 | 14 | ## Installation 15 | 16 | ``` 17 | npm install html-autoprefixer --save 18 | ``` 19 | 20 | ## Usage 21 | 22 | You pass an html string to `.process` and it returns the processed html. 23 | 24 | ```javascript 25 | var htmlAutoprefixer = require("html-autoprefixer"); 26 | var htmlString = "

Hello

"; 27 | 28 | var prefixed = htmlAutoprefixer.process(htmlString); 29 | ``` 30 | 31 | You can optionally pass [cheerio options](https://github.com/cheeriojs/cheerio#loading). 32 | 33 | ```javascript 34 | var htmlString = ""; 35 | 36 | var prefixed = htmlAutoprefixer.process(htmlString, { lowerCaseTags: true } ); 37 | // 38 | ``` 39 | 40 | ### Gulp 41 | 42 | [![](https://raw.githubusercontent.com/RebelMail/gulp-html-autoprefixer/master/gulp-html-autoprefixer.png)](https://github.com/RebelMail/gulp-html-autoprefixer) 43 | 44 | Using [Gulp](http://gulpjs.com)? Use [gulp-html-autoprefixer](https://github.com/RebelMail/gulp-html-autoprefixer). 45 | 46 | ```javascript 47 | var gulp = require( "gulp" ); 48 | var htmlAutoprefixer = require( "gulp-html-autoprefixer" ); 49 | 50 | gulp.task( "html-autoprefix", function( ) { 51 | return gulp.src( "./path/to/index-or-other.html" ) 52 | .pipe( htmlAutoprefixer( ) ) 53 | .pipe( gulp.dest( "dist" ) ); 54 | } ); 55 | ``` 56 | 57 | ## Contributing 58 | 59 | 1. Fork it 60 | 2. Create your feature branch (`git checkout -b my-new-feature`) 61 | 3. Commit your changes (`git commit -am 'Added some feature'`) 62 | 4. Push to the branch (`git push origin my-new-feature`) 63 | 5. Create new Pull Request 64 | 65 | ## Running tests 66 | 67 | ``` 68 | npm install 69 | npm test 70 | ``` 71 | -------------------------------------------------------------------------------- /html-autoprefixer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinus/html-autoprefixer/2830cc1369b7e6f8acf4791a15890220da15b92c/html-autoprefixer.png -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var HTMLPostCSS = require('html-postcss'); 4 | var autoprefixer = require('autoprefixer'); 5 | 6 | module.exports = new HTMLPostCSS([autoprefixer]); 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "html-autoprefixer", 3 | "version": "0.3.8", 4 | "description": "Autoprefix all CSS inside an html page - CSS inside style tags and inside style attributes", 5 | "main": "lib/main.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "istanbul test _mocha -- --recursive" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/rebelmail/html-autoprefixer.git" 15 | }, 16 | "keywords": [ 17 | "autoprefixer", 18 | "html", 19 | "html-autoprefixer", 20 | "auto-prefixer", 21 | "css", 22 | "postcss" 23 | ], 24 | "readmeFilename": "README.md", 25 | "author": "motdotla", 26 | "license": "ISC", 27 | "devDependencies": { 28 | "chai": "^3.4.1", 29 | "istanbul": "^0.4.1", 30 | "mocha": "^2.3.4" 31 | }, 32 | "dependencies": { 33 | "autoprefixer": "^6.1.1", 34 | "html-postcss": "^0.1.2" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "strict": true, 4 | "expr": true, 5 | "predef": [ 6 | "before", 7 | "beforeEach", 8 | "after", 9 | "afterEach", 10 | "describe", 11 | "it" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var expect = require('chai').expect; 4 | 5 | var htmlAutoprefixer = require('../'); 6 | 7 | describe('html-autoprefixer', function() { 8 | describe('#process', function() { 9 | it('autoprefixes inside of style tags', function( ) { 10 | var htmlString = ''; 11 | var prefixedResult = ''; 12 | 13 | var prefixed = htmlAutoprefixer.process(htmlString); 14 | expect(prefixed).to.equal(prefixedResult); 15 | }); 16 | 17 | it('autoprefixes nested elements inside of style tags', function( ) { 18 | var htmlString = ''; 19 | var prefixedResult = ''; 20 | 21 | var prefixed = htmlAutoprefixer.process(htmlString); 22 | expect(prefixed).to.equal(prefixedResult); 23 | }); 24 | 25 | it('autoprefixes nested elements when doing SVG hack', function( ) { 26 | var htmlString = ''; 27 | var prefixedResult = ''; 28 | 29 | var prefixed = htmlAutoprefixer.process(htmlString); 30 | expect(prefixed).to.equal(prefixedResult); 31 | }); 32 | 33 | it('autoprefixes inside of style attributes', function() { 34 | var htmlString = '

Hello

World

'; 35 | var prefixedResult = '

Hello

World

'; 36 | 37 | var prefixed = htmlAutoprefixer.process(htmlString); 38 | expect(prefixed).to.equal(prefixedResult); 39 | }); 40 | 41 | it('can pass cheerio options', function() { 42 | var htmlString = 'Hello'; 43 | var prefixedResult = 'Hello'; 44 | 45 | var prefixed = htmlAutoprefixer.process(htmlString, { lowerCaseTags: true }); 46 | expect(prefixed).to.equal(prefixedResult); 47 | }); 48 | }); 49 | }); 50 | --------------------------------------------------------------------------------