@ideasonpurpose/build-tools-wordpress 2.6.5 → 2.6.6
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 +6 -0
- package/README.md +15 -1
- package/bin/format-wp-block-pattern.js +12 -0
- package/package.json +16 -16
- package/test/fixtures/format-wp-block-pattern/nested-list.php +25 -0
- package/test/fixtures/format-wp-block-pattern/nested-list__formatted.php +33 -0
- package/test/format-wp-block-pattern.test.js +17 -11
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### v2.6.5
|
|
8
|
+
|
|
9
|
+
> 5 April 2026
|
|
10
|
+
|
|
11
|
+
- fix: update setup-node action version to v6 for consistency
|
|
12
|
+
|
|
7
13
|
#### v2.6.4
|
|
8
14
|
|
|
9
15
|
> 5 April 2026
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ideasonpurpose/build-tools-wordpress
|
|
2
2
|
|
|
3
|
-
#### Version 2.6.
|
|
3
|
+
#### Version 2.6.6
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ideasonpurpose/build-tools-wordpress)
|
|
6
6
|
[](https://github.com/ideasonpurpose/build-tools-wordpress#readme)
|
|
@@ -41,6 +41,20 @@ Webpack handles SVG files differently based on import context:
|
|
|
41
41
|
|
|
42
42
|
Data URIs are generated as `data:image/svg+xml,<url-encoded-content>` using more efficient URL-encoding, not base64.
|
|
43
43
|
|
|
44
|
+
## Experimental formatting helpers
|
|
45
|
+
|
|
46
|
+
This package includes two experimental formatting scripts:
|
|
47
|
+
|
|
48
|
+
### `iop-html-php-prettier`
|
|
49
|
+
|
|
50
|
+
This uses [Prettier](https://prettier.io) to double-format mixed HTML and PHP files (like WordPress templates). PHP blocks are tokenized so Prettier can safely format the file as HTML, then PHP blocks are restored and the file is formatted again as PHP using [@prettier/plugin-php](https://github.com/prettier/plugin-php).
|
|
51
|
+
**Usage:** `npx iop-html-php-prettier path/to/file.php`
|
|
52
|
+
|
|
53
|
+
### `iop-format-wp-block-pattern`
|
|
54
|
+
|
|
55
|
+
A specialized formatter for WordPress PHP block patterns. This makes block markup easier to read, expands JSON settings, and adjusts whitespace to work around Block Editor quirks.
|
|
56
|
+
**Usage:** `npx iop-format-wp-block-pattern path/to/pattern.php`
|
|
57
|
+
|
|
44
58
|
## Local Development
|
|
45
59
|
|
|
46
60
|
Because this project makes use of bin scripts, conventional `npm link` workflows won't work correctly. To work on this code in a development project, change the project's package.json to install from a local file path, probably something like this:
|
|
@@ -141,6 +141,17 @@ export function trimInsideListElements(content) {
|
|
|
141
141
|
.replace(/\s*<\/li>/g, "</li>");
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Special whitespace handling inside <h1..h6> elements
|
|
146
|
+
* @param {string} content
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
export function trimInsideHeadings(content) {
|
|
150
|
+
return content
|
|
151
|
+
.replace(/(<h[1-6][^>]*>)\s*/g, "$1")
|
|
152
|
+
.replace(/\s*(<\/h[1-6]>)/g, "$1");
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
/**
|
|
145
156
|
* @param {string} content
|
|
146
157
|
* @returns {Promise<string>}
|
|
@@ -168,6 +179,7 @@ async function formatWPBlockPattern(filepath) {
|
|
|
168
179
|
normalizeCommentTagSpacing,
|
|
169
180
|
formatAllWpComments,
|
|
170
181
|
trimInsideListElements,
|
|
182
|
+
trimInsideHeadings,
|
|
171
183
|
normalizeNewlines,
|
|
172
184
|
];
|
|
173
185
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ideasonpurpose/build-tools-wordpress",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.6",
|
|
4
4
|
"description": "Build scripts and dependencies for IOP's WordPress development environments.",
|
|
5
5
|
"homepage": "https://github.com/ideasonpurpose/build-tools-wordpress#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"@rollup/plugin-json": "^6.1.0",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
43
43
|
"@svgr/webpack": "^8.1.0",
|
|
44
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
44
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.44.0",
|
|
45
45
|
"ansi-html": "^0.0.9",
|
|
46
46
|
"archiver": "^7.0.1",
|
|
47
47
|
"auto-changelog": "^2.5.0",
|
|
48
|
-
"autoprefixer": "^10.
|
|
48
|
+
"autoprefixer": "^10.5.0",
|
|
49
49
|
"babel-loader": "^10.1.1",
|
|
50
|
-
"caniuse-lite": "^1.0.
|
|
50
|
+
"caniuse-lite": "^1.0.30001791",
|
|
51
51
|
"chalk": "^5.6.2",
|
|
52
52
|
"chalk-cli": "^6.0.0",
|
|
53
53
|
"classnames": "^2.5.1",
|
|
@@ -56,25 +56,25 @@
|
|
|
56
56
|
"cosmiconfig": "^9.0.1",
|
|
57
57
|
"cross-env": "^10.1.0",
|
|
58
58
|
"css-loader": "^7.1.4",
|
|
59
|
-
"cssnano": "^7.1.
|
|
60
|
-
"dotenv": "^17.4.
|
|
59
|
+
"cssnano": "^7.1.7",
|
|
60
|
+
"dotenv": "^17.4.2",
|
|
61
61
|
"esbuild-loader": "^4.4.3",
|
|
62
|
-
"eslint": "^10.2.
|
|
63
|
-
"filesize": "^11.0.
|
|
62
|
+
"eslint": "^10.2.1",
|
|
63
|
+
"filesize": "^11.0.17",
|
|
64
64
|
"fs-extra": "^11.3.4",
|
|
65
65
|
"globby": "^16.2.0",
|
|
66
|
-
"html-webpack-plugin": "^5.6.
|
|
66
|
+
"html-webpack-plugin": "^5.6.7",
|
|
67
67
|
"http-proxy": "^1.18.1",
|
|
68
68
|
"humanize-duration": "^3.33.2",
|
|
69
69
|
"image-minimizer-webpack-plugin": "^5.0.0",
|
|
70
70
|
"is-text-path": "^3.0.0",
|
|
71
71
|
"lodash": "^4.18.1",
|
|
72
72
|
"mini-css-extract-plugin": "^2.10.2",
|
|
73
|
-
"ora": "^9.
|
|
74
|
-
"postcss": "^8.5.
|
|
73
|
+
"ora": "^9.4.0",
|
|
74
|
+
"postcss": "^8.5.12",
|
|
75
75
|
"postcss-loader": "^8.2.1",
|
|
76
76
|
"postcss-scss": "^4.0.9",
|
|
77
|
-
"prettier": "^3.8.
|
|
77
|
+
"prettier": "^3.8.3",
|
|
78
78
|
"pretty-hrtime": "^1.0.3",
|
|
79
79
|
"read-package-up": "^12.0.0",
|
|
80
80
|
"replacestream": "^4.0.3",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"svgo": "^4.0.1",
|
|
90
90
|
"svgo-loader": "^5.0.0",
|
|
91
91
|
"version-everything": "^0.12.2",
|
|
92
|
-
"webpack": "^5.
|
|
92
|
+
"webpack": "^5.106.2",
|
|
93
93
|
"webpack-bundle-analyzer": "^5.3.0",
|
|
94
|
-
"webpack-dev-middleware": "^8.0.
|
|
94
|
+
"webpack-dev-middleware": "^8.0.3",
|
|
95
95
|
"webpack-dev-server": "^5.2.3",
|
|
96
96
|
"webpack-manifest-plugin": "^6.0.1"
|
|
97
97
|
},
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"webpack-cli": "^6.0.1"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@vitest/coverage-v8": "^4.1.
|
|
103
|
-
"vitest": "^4.1.
|
|
102
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
103
|
+
"vitest": "^4.1.5"
|
|
104
104
|
},
|
|
105
105
|
"version-everything": {
|
|
106
106
|
"files": [
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!-- wp:list -->
|
|
2
|
+
<ul class="wp-block-list"><!-- wp:list-item -->
|
|
3
|
+
<li> UL Item 1 </li>
|
|
4
|
+
<!-- /wp:list-item -->
|
|
5
|
+
|
|
6
|
+
<!-- wp:list-item -->
|
|
7
|
+
<li>UL Item 2<!-- wp:list -->
|
|
8
|
+
<ul class="wp-block-list"><!-- wp:list-item -->
|
|
9
|
+
<li> UL Second level item 3<!-- wp:list -->
|
|
10
|
+
<ul class="wp-block-list">
|
|
11
|
+
|
|
12
|
+
<!-- wp:list-item -->
|
|
13
|
+
<li>
|
|
14
|
+
UL Third level item 4
|
|
15
|
+
</li>
|
|
16
|
+
<!-- /wp:list-item --></ul>
|
|
17
|
+
<!-- /wp:list --></li>
|
|
18
|
+
<!-- /wp:list-item --></ul>
|
|
19
|
+
<!-- /wp:list --></li>
|
|
20
|
+
<!-- /wp:list-item -->
|
|
21
|
+
|
|
22
|
+
<!-- wp:list-item -->
|
|
23
|
+
<li>UL Item 5</li>
|
|
24
|
+
<!-- /wp:list-item --></ul>
|
|
25
|
+
<!-- /wp:list -->
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!-- wp:list -->
|
|
2
|
+
<ul class="wp-block-list">
|
|
3
|
+
|
|
4
|
+
<!-- wp:list-item -->
|
|
5
|
+
<li>UL Item 1</li>
|
|
6
|
+
<!-- /wp:list-item -->
|
|
7
|
+
|
|
8
|
+
<!-- wp:list-item -->
|
|
9
|
+
<li>UL Item 2<!-- wp:list -->
|
|
10
|
+
<ul class="wp-block-list">
|
|
11
|
+
|
|
12
|
+
<!-- wp:list-item -->
|
|
13
|
+
<li>UL Second level item 3<!-- wp:list -->
|
|
14
|
+
<ul class="wp-block-list">
|
|
15
|
+
|
|
16
|
+
<!-- wp:list-item -->
|
|
17
|
+
<li>UL Third level item 4</li>
|
|
18
|
+
<!-- /wp:list-item -->
|
|
19
|
+
|
|
20
|
+
</ul>
|
|
21
|
+
<!-- /wp:list --></li>
|
|
22
|
+
<!-- /wp:list-item -->
|
|
23
|
+
|
|
24
|
+
</ul>
|
|
25
|
+
<!-- /wp:list --></li>
|
|
26
|
+
<!-- /wp:list-item -->
|
|
27
|
+
|
|
28
|
+
<!-- wp:list-item -->
|
|
29
|
+
<li>UL Item 5</li>
|
|
30
|
+
<!-- /wp:list-item -->
|
|
31
|
+
|
|
32
|
+
</ul>
|
|
33
|
+
<!-- /wp:list -->
|
|
@@ -37,16 +37,20 @@ describe("Format JSON in WP Block comments", () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test("Return short JSON for two-key wp:* comments", async () => {
|
|
40
|
-
const input =
|
|
41
|
-
|
|
40
|
+
const input =
|
|
41
|
+
'<!-- wp:group { "align": "full", "className": "group-name"} -->';
|
|
42
|
+
const expected =
|
|
43
|
+
'<!-- wp:group {"align":"full","className":"group-name"} -->';
|
|
42
44
|
|
|
43
45
|
const actual = formatWpCommentJson(input);
|
|
44
46
|
expect(actual).toBe(expected);
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
test("Prettyprint three-key wp:* comments", async () => {
|
|
48
|
-
const input =
|
|
49
|
-
|
|
50
|
+
const input =
|
|
51
|
+
'<!-- wp:group { "align": "full","isLink":true, "className": "group-name"} -->';
|
|
52
|
+
const expected =
|
|
53
|
+
'<!-- wp:group {\n "align": "full",\n "isLink": true,\n "className": "group-name"\n} -->';
|
|
50
54
|
|
|
51
55
|
const actual = formatWpCommentJson(input);
|
|
52
56
|
expect(actual).toBe(expected);
|
|
@@ -85,7 +89,6 @@ describe("Format WP Block Patterns", () => {
|
|
|
85
89
|
});
|
|
86
90
|
});
|
|
87
91
|
|
|
88
|
-
|
|
89
92
|
describe("Normalize whitespace", () => {
|
|
90
93
|
test("Fix Comment tag spacing", async () => {
|
|
91
94
|
const input = (
|
|
@@ -100,15 +103,18 @@ describe("Normalize whitespace", () => {
|
|
|
100
103
|
|
|
101
104
|
test("List handling", async () => {
|
|
102
105
|
const input = (
|
|
103
|
-
await readFile(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
await readFile("./test/fixtures/format-wp-block-pattern/nested-list.php")
|
|
107
|
+
).toString();
|
|
108
|
+
|
|
109
|
+
const expected = (
|
|
110
|
+
await readFile("./test/fixtures/format-wp-block-pattern/nested-list__formatted.php")
|
|
106
111
|
).toString();
|
|
107
112
|
|
|
108
113
|
const actual = trimInsideListElements(input);
|
|
109
|
-
|
|
114
|
+
expect(actual).toMatch(/<li>UL/);
|
|
115
|
+
|
|
116
|
+
expect(actual).toBe(expected);
|
|
110
117
|
});
|
|
111
118
|
});
|
|
112
119
|
|
|
113
|
-
|
|
114
|
-
// {"align":"full","className":"group-name"}
|
|
120
|
+
// {"align":"full","className":"group-name"}
|