@csstools/postcss-content-alt-text 1.0.0 → 2.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 CHANGED
@@ -1,8 +1,14 @@
1
1
  # Changes to PostCSS Content Alt Text
2
2
 
3
- ### 1.0.0
3
+ ### 2.0.0
4
4
 
5
- _July 7, 2024_
5
+ _August 3, 2024_
6
6
 
7
- - Initial version
8
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.3.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#330) (minor)
7
+ - Updated: Support for Node v18+ (major).
8
+ - Add specific handling of `content: ">" / "";` as this pattern is used in the same way as `<img alt="">`, i.e. to represent an item that does not need a text alternative.
9
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#300) (major)
10
+ - Updated [`@csstools/utilities`](https://github.com/csstools/postcss-plugins/tree/main/packages/utilities) to [`2.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/utilities/CHANGELOG.md#200) (major)
11
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#300) (major)
12
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`4.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#400) (major)
13
+
14
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-content-alt-text/CHANGELOG.md)
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
1
  # PostCSS Content Alt Text [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]
2
2
 
3
- [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-content-alt-text.svg" height="20">][npm-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]<br><br>[<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/content-alt-text.svg" height="20">][css-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/content-alt-text.svg" height="20">][css-url]
4
-
5
- ```bash
6
- npm install @csstools/postcss-content-alt-text --save-dev
7
- ```
3
+ `npm install @csstools/postcss-content-alt-text --save-dev`
8
4
 
9
5
  [PostCSS Content Alt Text] generates fallback values for `content` with alt text following the [CSS Generated Content Module].
10
6
 
@@ -13,12 +9,21 @@ npm install @csstools/postcss-content-alt-text --save-dev
13
9
  content: url(tree.jpg) / "A beautiful tree in a dark forest";
14
10
  }
15
11
 
12
+ .bar {
13
+ content: ">" / "";
14
+ }
15
+
16
16
  /* becomes */
17
17
 
18
18
  .foo {
19
19
  content: url(tree.jpg) "A beautiful tree in a dark forest";
20
20
  content: url(tree.jpg) / "A beautiful tree in a dark forest";
21
21
  }
22
+
23
+ .bar {
24
+ content: ">" ;
25
+ content: ">" / "";
26
+ }
22
27
  ```
23
28
 
24
29
  ## Usage
@@ -40,16 +45,7 @@ postcss([
40
45
  ]).process(YOUR_CSS /*, processOptions */);
41
46
  ```
42
47
 
43
- [PostCSS Content Alt Text] runs in all Node environments, with special
44
- instructions for:
45
48
 
46
- - [Node](INSTALL.md#node)
47
- - [PostCSS CLI](INSTALL.md#postcss-cli)
48
- - [PostCSS Load Config](INSTALL.md#postcss-load-config)
49
- - [Webpack](INSTALL.md#webpack)
50
- - [Next.js](INSTALL.md#nextjs)
51
- - [Gulp](INSTALL.md#gulp)
52
- - [Grunt](INSTALL.md#grunt)
53
49
 
54
50
  ## Options
55
51
 
@@ -67,11 +63,19 @@ postcssContentAltText({ preserve: false })
67
63
  content: url(tree.jpg) / "A beautiful tree in a dark forest";
68
64
  }
69
65
 
66
+ .bar {
67
+ content: ">" / "";
68
+ }
69
+
70
70
  /* becomes */
71
71
 
72
72
  .foo {
73
73
  content: url(tree.jpg) "A beautiful tree in a dark forest";
74
74
  }
75
+
76
+ .bar {
77
+ content: ">" ;
78
+ }
75
79
  ```
76
80
 
77
81
  ### stripAltText
@@ -91,12 +95,21 @@ postcssContentAltText({ stripAltText: true })
91
95
  content: url(tree.jpg) / "A beautiful tree in a dark forest";
92
96
  }
93
97
 
98
+ .bar {
99
+ content: ">" / "";
100
+ }
101
+
94
102
  /* becomes */
95
103
 
96
104
  .foo {
97
105
  content: url(tree.jpg) ;
98
106
  content: url(tree.jpg) / "A beautiful tree in a dark forest";
99
107
  }
108
+
109
+ .bar {
110
+ content: ">" ;
111
+ content: ">" / "";
112
+ }
100
113
  ```
101
114
 
102
115
  [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/css-parser-algorithms"),s=require("@csstools/css-tokenizer"),t=require("@csstools/postcss-progressive-custom-properties"),o=require("@csstools/utilities");const r={test:e=>e.includes("content:")&&e.includes("/")},basePlugin=t=>({postcssPlugin:"postcss-content-alt-text",Declaration(n){if("content"!==n.prop||!n.value.includes("/"))return;if(o.hasFallback(n))return;if(o.hasSupportsAtRuleAncestor(n,r))return;const i=e.parseListOfComponentValues(s.tokenize({css:n.value}));let c=0;for(let o=i.length-1;o>=0;o--){const r=i[o];if(!e.isTokenNode(r))continue;const n=r.value;s.isTokenDelim(n)&&("/"===n[4].value&&(c++,!0===t?.stripAltText?i.splice(o,i.length):i.splice(o,1)))}if(1!==c)return;const l=e.stringify([i]);l!==n.value&&(n.cloneBefore({value:l}),!1===t?.preserve&&n.remove())}});basePlugin.postcss=!0;const creator=e=>{const s=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},e);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[t(),basePlugin(s)]}:basePlugin(s)};creator.postcss=!0,module.exports=creator;
1
+ "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/utilities"),t=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");function transform(e,s){const o=e[0];if(!o.length)return"";if(s)return t.stringify([o]);const n=e[1].filter((e=>!t.isWhiteSpaceOrCommentNode(e)));return 1===n.length&&t.isTokenNode(n[0])&&r.isTokenString(n[0].value)&&""===n[0].value[4].value?t.stringify([o]):t.stringify([[...o,...e[1]]])}function parse(e){const s=t.parseListOfComponentValues(r.tokenize({css:e})),o=[];let n=0;for(let e=s.length-1;e>=0;e--){const i=s[e];if(!t.isTokenNode(i))continue;const l=i.value;r.isTokenDelim(l)&&("/"===l[4].value&&(o.push(s.slice(n,e)),n=e+1))}return 0!==n&&o.push(s.slice(n,s.length)),o}const o={test:e=>e.includes("content:")&&e.includes("/")},basePlugin=e=>({postcssPlugin:"postcss-content-alt-text",Declaration(t){if("content"!==t.prop||!t.value.includes("/"))return;if(s.hasFallback(t))return;if(s.hasSupportsAtRuleAncestor(t,o))return;const r=parse(t.value);if(2!==r.length)return;const n=transform(r,e?.stripAltText);n!==t.value&&(t.cloneBefore({value:n}),!1===e?.preserve&&t.remove())}});basePlugin.postcss=!0;const creator=s=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},s);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[e(),basePlugin(t)]}:basePlugin(t)};creator.postcss=!0,module.exports=creator;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{parseListOfComponentValues as s,isTokenNode as e,stringify as t}from"@csstools/css-parser-algorithms";import{tokenize as o,isTokenDelim as r}from"@csstools/css-tokenizer";import n from"@csstools/postcss-progressive-custom-properties";import{hasFallback as c,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";const l={test:s=>s.includes("content:")&&s.includes("/")},basePlugin=n=>({postcssPlugin:"postcss-content-alt-text",Declaration(p){if("content"!==p.prop||!p.value.includes("/"))return;if(c(p))return;if(i(p,l))return;const u=s(o({css:p.value}));let a=0;for(let s=u.length-1;s>=0;s--){const t=u[s];if(!e(t))continue;const o=t.value;r(o)&&("/"===o[4].value&&(a++,!0===n?.stripAltText?u.splice(s,u.length):u.splice(s,1)))}if(1!==a)return;const m=t([u]);m!==p.value&&(p.cloneBefore({value:m}),!1===n?.preserve&&p.remove())}});basePlugin.postcss=!0;const creator=s=>{const e=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},s);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[n(),basePlugin(e)]}:basePlugin(e)};creator.postcss=!0;export{creator as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import{hasFallback as t,hasSupportsAtRuleAncestor as e}from"@csstools/utilities";import{stringify as r,isWhiteSpaceOrCommentNode as o,isTokenNode as n,parseListOfComponentValues as c}from"@csstools/css-parser-algorithms";import{isTokenString as l,tokenize as i,isTokenDelim as u}from"@csstools/css-tokenizer";function transform(s,t){const e=s[0];if(!e.length)return"";if(t)return r([e]);const c=s[1].filter((s=>!o(s)));return 1===c.length&&n(c[0])&&l(c[0].value)&&""===c[0].value[4].value?r([e]):r([[...e,...s[1]]])}function parse(s){const t=c(i({css:s})),e=[];let r=0;for(let s=t.length-1;s>=0;s--){const o=t[s];if(!n(o))continue;const c=o.value;u(c)&&("/"===c[4].value&&(e.push(t.slice(r,s)),r=s+1))}return 0!==r&&e.push(t.slice(r,t.length)),e}const p={test:s=>s.includes("content:")&&s.includes("/")},basePlugin=s=>({postcssPlugin:"postcss-content-alt-text",Declaration(r){if("content"!==r.prop||!r.value.includes("/"))return;if(t(r))return;if(e(r,p))return;const o=parse(r.value);if(2!==o.length)return;const n=transform(o,s?.stripAltText);n!==r.value&&(r.cloneBefore({value:n}),!1===s?.preserve&&r.remove())}});basePlugin.postcss=!0;const creator=t=>{const e=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0,stripAltText:!1},t);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-content-alt-text",plugins:[s(),basePlugin(e)]}:basePlugin(e)};creator.postcss=!0;export{creator as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-content-alt-text",
3
3
  "description": "Generate fallback values for content with alt text",
4
- "version": "1.0.0",
4
+ "version": "2.0.0",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -25,7 +25,7 @@
25
25
  }
26
26
  ],
27
27
  "engines": {
28
- "node": "^14 || ^16 || >=18"
28
+ "node": ">=18"
29
29
  },
30
30
  "type": "module",
31
31
  "main": "dist/index.cjs",
@@ -48,10 +48,10 @@
48
48
  "dist"
49
49
  ],
50
50
  "dependencies": {
51
- "@csstools/css-parser-algorithms": "^2.7.1",
52
- "@csstools/css-tokenizer": "^2.4.1",
53
- "@csstools/postcss-progressive-custom-properties": "^3.3.0",
54
- "@csstools/utilities": "^1.0.0"
51
+ "@csstools/css-parser-algorithms": "^3.0.0",
52
+ "@csstools/css-tokenizer": "^3.0.0",
53
+ "@csstools/postcss-progressive-custom-properties": "^4.0.0",
54
+ "@csstools/utilities": "^2.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "postcss": "^8.4"