@csstools/postcss-syntax-descriptor-syntax-production 1.0.0
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 +7 -0
- package/LICENSE.md +18 -0
- package/README.md +79 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +1 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT No Attribution (MIT-0)
|
|
2
|
+
|
|
3
|
+
Copyright © CSSTools Contributors
|
|
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
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# PostCSS Syntax Descriptor Syntax Production [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
|
|
2
|
+
|
|
3
|
+
`npm install @csstools/postcss-syntax-descriptor-syntax-production --save-dev`
|
|
4
|
+
|
|
5
|
+
[PostCSS Syntax Descriptor Syntax Production] lets you use the `<syntax>` production in `syntax` descriptors following the [CSS Specification].
|
|
6
|
+
|
|
7
|
+
```css
|
|
8
|
+
@property --color {
|
|
9
|
+
inherits: true;
|
|
10
|
+
initial-value: black;
|
|
11
|
+
syntax: <color>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* becomes */
|
|
15
|
+
|
|
16
|
+
@property --color {
|
|
17
|
+
inherits: true;
|
|
18
|
+
initial-value: black;
|
|
19
|
+
color: "<color>";
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Add [PostCSS Syntax Descriptor Syntax Production] to your project:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install postcss @csstools/postcss-syntax-descriptor-syntax-production --save-dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Use it as a [PostCSS] plugin:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const postcss = require('postcss');
|
|
35
|
+
const postcssSyntaxDescriptorSyntaxProduction = require('@csstools/postcss-syntax-descriptor-syntax-production');
|
|
36
|
+
|
|
37
|
+
postcss([
|
|
38
|
+
postcssSyntaxDescriptorSyntaxProduction(/* pluginOptions */)
|
|
39
|
+
]).process(YOUR_CSS /*, processOptions */);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Options
|
|
45
|
+
|
|
46
|
+
### preserve
|
|
47
|
+
|
|
48
|
+
The `preserve` option determines whether the original notation
|
|
49
|
+
is preserved. By default, it is not preserved.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
postcssSyntaxDescriptorSyntaxProduction({ preserve: true })
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
@property --color {
|
|
57
|
+
inherits: true;
|
|
58
|
+
initial-value: black;
|
|
59
|
+
syntax: <color>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* becomes */
|
|
63
|
+
|
|
64
|
+
@property --color {
|
|
65
|
+
inherits: true;
|
|
66
|
+
initial-value: black;
|
|
67
|
+
color: "<color>";
|
|
68
|
+
syntax: <color>;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|
73
|
+
[css-url]: https://cssdb.org/#syntax-descriptor-syntax-production
|
|
74
|
+
[discord]: https://discord.gg/bUadyRwkJS
|
|
75
|
+
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-syntax-descriptor-syntax-production
|
|
76
|
+
|
|
77
|
+
[PostCSS]: https://github.com/postcss/postcss
|
|
78
|
+
[PostCSS Syntax Descriptor Syntax Production]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-syntax-descriptor-syntax-production
|
|
79
|
+
[CSS Specification]: https://github.com/w3c/csswg-drafts/issues/11426#issuecomment-3657538113
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@csstools/css-tokenizer");const s=/^property$/i,c=/^syntax$/i,creator=a=>{const t=Object.assign({preserve:!1},a);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(a){if(!c.test(a.prop))return;if(!a.parent||"atrule"!==a.parent.type)return;if(!s.test(a.parent.name))return;const o=a.value,r=e.tokenize({css:a.value});let n="";r.forEach(s=>{e.isTokenComment(s)||(e.isTokenWhitespace(s)?n+=" ":n+=s[1])});let i='"';for(const e of n){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:i+=String.fromCodePoint(65533);break;case 34:case 92:i+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:i+="\\"+s.toString(16)+" ";break;default:i+=String.fromCodePoint(s)}}i+='"',o!==i&&(a.cloneBefore({prop:"color",value:i}),t.preserve||a.remove())}}};creator.postcss=!0,module.exports=creator;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginCreator } from 'postcss';
|
|
2
|
+
|
|
3
|
+
declare const creator: PluginCreator<pluginOptions>;
|
|
4
|
+
export default creator;
|
|
5
|
+
|
|
6
|
+
/** postcss-syntax-descriptor-syntax-production plugin options */
|
|
7
|
+
export declare type pluginOptions = {
|
|
8
|
+
/** Preserve the original notation. default: false */
|
|
9
|
+
preserve?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tokenize as e,isTokenComment as s,isTokenWhitespace as a}from"@csstools/css-tokenizer";const c=/^property$/i,t=/^syntax$/i,creator=r=>{const o=Object.assign({preserve:!1},r);return{postcssPlugin:"postcss-syntax-descriptor-syntax-production",Declaration(r){if(!t.test(r.prop))return;if(!r.parent||"atrule"!==r.parent.type)return;if(!c.test(r.parent.name))return;const n=r.value,i=e({css:r.value});let p="";i.forEach(e=>{s(e)||(a(e)?p+=" ":p+=e[1])});let f='"';for(const e of p){const s=e.codePointAt(0);if(void 0!==s)switch(s){case 0:f+=String.fromCodePoint(65533);break;case 34:case 92:f+="\\"+String.fromCodePoint(s);break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 127:f+="\\"+s.toString(16)+" ";break;default:f+=String.fromCodePoint(s)}}f+='"',n!==f&&(r.cloneBefore({prop:"color",value:f}),o.preserve||r.remove())}}};creator.postcss=!0;export{creator as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@csstools/postcss-syntax-descriptor-syntax-production",
|
|
3
|
+
"description": "Use the syntax production in syntax descriptors",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Antonio Laguna",
|
|
8
|
+
"email": "antonio@laguna.es",
|
|
9
|
+
"url": "https://antonio.laguna.es"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Romain Menke",
|
|
13
|
+
"email": "romainmenke@gmail.com"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT-0",
|
|
17
|
+
"funding": [
|
|
18
|
+
{
|
|
19
|
+
"type": "github",
|
|
20
|
+
"url": "https://github.com/sponsors/csstools"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "opencollective",
|
|
24
|
+
"url": "https://opencollective.com/csstools"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "dist/index.cjs",
|
|
32
|
+
"module": "dist/index.mjs",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"default": "./dist/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"default": "./dist/index.cjs"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"CHANGELOG.md",
|
|
46
|
+
"LICENSE.md",
|
|
47
|
+
"README.md",
|
|
48
|
+
"dist"
|
|
49
|
+
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@csstools/css-tokenizer": "^3.0.4"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"postcss": "^8.4"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {},
|
|
57
|
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-syntax-descriptor-syntax-production#readme",
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
|
61
|
+
"directory": "plugins/postcss-syntax-descriptor-syntax-production"
|
|
62
|
+
},
|
|
63
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
64
|
+
"keywords": [
|
|
65
|
+
"postcss-plugin"
|
|
66
|
+
]
|
|
67
|
+
}
|