postcss-normalize-charset 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -7
- package/LICENSE +20 -20
- package/README.md +44 -44
- package/index.js +37 -35
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
# 1.1.
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
# 1.1.1
|
|
2
|
+
|
|
3
|
+
* Performance tweaks; test that `node.parent` is equal to the AST rather than
|
|
4
|
+
checking its type is `root`, and use the AST directly to prepend the
|
|
5
|
+
`@charset` to, rather than using the superfluous `root()` method.
|
|
6
|
+
|
|
7
|
+
# 1.1.0
|
|
8
|
+
|
|
9
|
+
* Added `add` option (thanks to @ben-eb)
|
|
10
|
+
|
|
11
|
+
# 1.0.0
|
|
12
|
+
|
|
13
|
+
* Initial release.
|
package/LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright 2015 Bogdan Chadkin <trysound@yandex.ru>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright 2015 Bogdan Chadkin <trysound@yandex.ru>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
# postcss-normalize-charset [![Build Status][ci-img]][ci]
|
|
2
|
-
|
|
3
|
-
Add necessary or remove extra charset with PostCSS
|
|
4
|
-
|
|
5
|
-
```css
|
|
6
|
-
a{
|
|
7
|
-
content: "©";
|
|
8
|
-
}
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
```css
|
|
12
|
-
@charset "utf-8";
|
|
13
|
-
a{
|
|
14
|
-
content: "©";
|
|
15
|
-
}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## API
|
|
19
|
-
|
|
20
|
-
### normalizeCharset([options])
|
|
21
|
-
|
|
22
|
-
#### options
|
|
23
|
-
|
|
24
|
-
##### add
|
|
25
|
-
|
|
26
|
-
Type: `boolean`
|
|
27
|
-
Default: `true`
|
|
28
|
-
|
|
29
|
-
Pass `false` to stop the module from adding a `@charset` declaration if it was
|
|
30
|
-
missing from the file (and the file contained non-ascii characters).
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
postcss([ require('postcss-normalize-charset') ])
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
See [PostCSS] docs for examples for your environment.
|
|
39
|
-
|
|
40
|
-
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
|
41
|
-
|
|
42
|
-
[PostCSS]: https://github.com/postcss/postcss
|
|
43
|
-
[ci-img]: https://travis-ci.org/
|
|
44
|
-
[ci]: https://travis-ci.org/
|
|
1
|
+
# postcss-normalize-charset [![Build Status][ci-img]][ci]
|
|
2
|
+
|
|
3
|
+
Add necessary or remove extra charset with PostCSS
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
a{
|
|
7
|
+
content: "©";
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
@charset "utf-8";
|
|
13
|
+
a{
|
|
14
|
+
content: "©";
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## API
|
|
19
|
+
|
|
20
|
+
### normalizeCharset([options])
|
|
21
|
+
|
|
22
|
+
#### options
|
|
23
|
+
|
|
24
|
+
##### add
|
|
25
|
+
|
|
26
|
+
Type: `boolean`
|
|
27
|
+
Default: `true`
|
|
28
|
+
|
|
29
|
+
Pass `false` to stop the module from adding a `@charset` declaration if it was
|
|
30
|
+
missing from the file (and the file contained non-ascii characters).
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
postcss([ require('postcss-normalize-charset') ])
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See [PostCSS] docs for examples for your environment.
|
|
39
|
+
|
|
40
|
+
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
|
41
|
+
|
|
42
|
+
[PostCSS]: https://github.com/postcss/postcss
|
|
43
|
+
[ci-img]: https://travis-ci.org/ben-eb/postcss-normalize-charset.svg
|
|
44
|
+
[ci]: https://travis-ci.org/ben-eb/postcss-normalize-charset
|
package/index.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
var postcss = require('postcss');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
1
|
+
var postcss = require('postcss');
|
|
2
|
+
|
|
3
|
+
var charset = 'charset';
|
|
4
|
+
|
|
5
|
+
module.exports = postcss.plugin('postcss-normalize-' + charset, function (opts) {
|
|
6
|
+
opts = opts || {};
|
|
7
|
+
|
|
8
|
+
return function (css) {
|
|
9
|
+
var charsetRule;
|
|
10
|
+
var nonAsciiNode;
|
|
11
|
+
var nonAscii = /[^\x00-\x7F]/;
|
|
12
|
+
|
|
13
|
+
css.walk(function (node) {
|
|
14
|
+
if (node.type === 'atrule' && node.name === charset) {
|
|
15
|
+
if (!charsetRule) {
|
|
16
|
+
charsetRule = node;
|
|
17
|
+
}
|
|
18
|
+
node.remove();
|
|
19
|
+
} else if (!nonAsciiNode && node.parent === css && nonAscii.test(node)) {
|
|
20
|
+
nonAsciiNode = node;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (nonAsciiNode) {
|
|
25
|
+
if (!charsetRule && opts.add !== false) {
|
|
26
|
+
charsetRule = postcss.atRule({
|
|
27
|
+
name: charset,
|
|
28
|
+
params: '"utf-8"'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (charsetRule) {
|
|
32
|
+
charsetRule.source = nonAsciiNode.source;
|
|
33
|
+
css.prepend(charsetRule);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-normalize-charset",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Add necessary or remove extra charset with PostCSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postcss",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
"index.js"
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"repository": "
|
|
16
|
+
"repository": "ben-eb/postcss-charset",
|
|
17
17
|
"bugs": {
|
|
18
|
-
"url": "https://github.com/
|
|
18
|
+
"url": "https://github.com/ben-eb/postcss-charset/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://github.com/
|
|
20
|
+
"homepage": "https://github.com/ben-eb/postcss-charset",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"postcss": "^5.0.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
+
"ava": "^0.16.0",
|
|
25
26
|
"eslint": "^1.4.1",
|
|
26
|
-
"
|
|
27
|
-
"tape": "^4.2.0"
|
|
27
|
+
"postcss-devtools": "^1.1.1"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"test": "eslint index.js test &&
|
|
30
|
+
"test": "eslint index.js test && ava"
|
|
31
31
|
}
|
|
32
32
|
}
|