@maizzle/framework 5.0.0-beta.27 → 5.0.0-beta.29
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/package.json +5 -5
- package/src/commands/build.js +5 -3
- package/src/transformers/index.js +12 -12
- package/src/transformers/preventWidows.js +15 -64
- package/types/widowWords.d.ts +16 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maizzle/framework",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.29",
|
|
4
4
|
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"morphdom": "^2.7.4",
|
|
68
68
|
"ora": "^8.1.0",
|
|
69
69
|
"pathe": "^1.1.2",
|
|
70
|
-
"postcss": "^8.4.
|
|
71
|
-
"postcss-custom-properties": "^14.0.
|
|
70
|
+
"postcss": "^8.4.49",
|
|
71
|
+
"postcss-custom-properties": "^14.0.4",
|
|
72
72
|
"postcss-import": "^16.1.0",
|
|
73
73
|
"postcss-safe-parser": "^7.0.0",
|
|
74
74
|
"posthtml": "^0.16.6",
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"posthtml-render": "^3.0.0",
|
|
88
88
|
"posthtml-safe-class-names": "^4.1.0",
|
|
89
89
|
"posthtml-url-parameters": "^3.1.0",
|
|
90
|
+
"posthtml-widows": "^1.0.0",
|
|
90
91
|
"pretty": "^2.0.0",
|
|
91
|
-
"string-remove-widows": "^4.0.22",
|
|
92
92
|
"string-strip-html": "^13.4.8",
|
|
93
|
-
"tailwindcss": "^3.4.
|
|
93
|
+
"tailwindcss": "^3.4.15",
|
|
94
94
|
"ws": "^8.18.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
package/src/commands/build.js
CHANGED
|
@@ -159,11 +159,11 @@ export default async (config = {}) => {
|
|
|
159
159
|
relativePath = path.relative('.', file)
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const targetPath = path.join(
|
|
162
|
+
const targetPath = path.join(buildOutputPath, relativePath)
|
|
163
163
|
await copyFileAsync(file, targetPath)
|
|
164
164
|
}
|
|
165
165
|
} catch (error) {
|
|
166
|
-
console.error(
|
|
166
|
+
console.error('Error while processing pattern:', error)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -181,7 +181,9 @@ export default async (config = {}) => {
|
|
|
181
181
|
/**
|
|
182
182
|
* Create a list of templates to compile
|
|
183
183
|
*/
|
|
184
|
-
const extensions = outputExtensions.size > 1
|
|
184
|
+
const extensions = outputExtensions.size > 1
|
|
185
|
+
? `{${[...outputExtensions].join(',')}}`
|
|
186
|
+
: [...outputExtensions][0] || 'html'
|
|
185
187
|
|
|
186
188
|
const templatesToCompile = await fg.glob(
|
|
187
189
|
path.join(
|
|
@@ -218,35 +218,35 @@ export async function run(html = '', config = {}) {
|
|
|
218
218
|
posthtmlPlugins.push(templateTag())
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
* 17.
|
|
221
|
+
* 17. Replace strings
|
|
222
222
|
*
|
|
223
|
-
*
|
|
223
|
+
* Replace strings through regular expressions.
|
|
224
224
|
*/
|
|
225
|
-
if (get(config, '
|
|
225
|
+
if (get(config, 'replaceStrings')) {
|
|
226
226
|
posthtmlPlugins.push(
|
|
227
|
-
|
|
227
|
+
replaceStrings(get(config, 'replaceStrings', {}))
|
|
228
228
|
)
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
* 18.
|
|
232
|
+
* 18. Prettify
|
|
233
233
|
*
|
|
234
|
-
*
|
|
234
|
+
* Pretty-print HTML using js-beautify.
|
|
235
235
|
*/
|
|
236
|
-
if (get(config, '
|
|
236
|
+
if (get(config, 'prettify')) {
|
|
237
237
|
posthtmlPlugins.push(
|
|
238
|
-
|
|
238
|
+
prettify(get(config, 'prettify', {}))
|
|
239
239
|
)
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
243
|
-
* 19.
|
|
243
|
+
* 19. Minify
|
|
244
244
|
*
|
|
245
|
-
*
|
|
245
|
+
* Minify HTML using html-crush.
|
|
246
246
|
*/
|
|
247
|
-
if (get(config, '
|
|
247
|
+
if (get(config, 'minify')) {
|
|
248
248
|
posthtmlPlugins.push(
|
|
249
|
-
|
|
249
|
+
minify(get(config, 'minify', {}))
|
|
250
250
|
)
|
|
251
251
|
}
|
|
252
252
|
|
|
@@ -1,86 +1,37 @@
|
|
|
1
1
|
import posthtml from 'posthtml'
|
|
2
|
+
import posthtmlWidows from 'posthtml-widows'
|
|
2
3
|
import { defu as merge } from 'defu'
|
|
3
|
-
import { removeWidows } from 'string-remove-widows'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export default function posthtmlPlugin(options = {}) {
|
|
6
6
|
options = merge(options, {
|
|
7
|
-
|
|
8
|
-
attrName: 'no-widows'
|
|
7
|
+
minWords: 3
|
|
9
8
|
})
|
|
10
9
|
|
|
11
|
-
//
|
|
10
|
+
// Custom ignores
|
|
12
11
|
const mappings = [
|
|
13
|
-
// Jinja-like
|
|
14
|
-
{
|
|
15
|
-
heads: '{{',
|
|
16
|
-
tails: '}}'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
heads: ['{% if', '{%- if'],
|
|
20
|
-
tails: ['{% endif', '{%- endif']
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
heads: ['{% for', '{%- for'],
|
|
24
|
-
tails: ['{% endfor', '{%- endfor']
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
heads: ['{%', '{%-'],
|
|
28
|
-
tails: ['%}', '-%}']
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
heads: '{#',
|
|
32
|
-
tails: '#}'
|
|
33
|
-
},
|
|
34
|
-
// ASP/Hexo-like
|
|
35
|
-
{
|
|
36
|
-
heads: ['<%', '<%=', '<%-'],
|
|
37
|
-
tails: ['%>', '=%>', '-%>']
|
|
38
|
-
},
|
|
39
12
|
// MSO comments
|
|
40
13
|
{
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
start: '<!--[',
|
|
15
|
+
end: ']>'
|
|
43
16
|
},
|
|
44
17
|
// <![endif]-->
|
|
45
18
|
{
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
start: '<![',
|
|
20
|
+
end: ']--><'
|
|
48
21
|
}
|
|
49
22
|
]
|
|
50
23
|
|
|
51
24
|
if (Array.isArray(options.ignore)) {
|
|
52
|
-
options.ignore
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (typeof options.ignore !== 'string') {
|
|
56
|
-
options.ignore = mappings
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const process = node => {
|
|
60
|
-
if (node.attrs && Object.keys(node.attrs).includes(options.attrName)) {
|
|
61
|
-
const widowsRemovedString = removeWidows(tree.render(node.content), options).res
|
|
62
|
-
node.content = tree.render(tree.parser(widowsRemovedString))
|
|
63
|
-
delete node.attrs[options.attrName]
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return node
|
|
25
|
+
options.ignore = options.ignore.concat(mappings)
|
|
67
26
|
}
|
|
68
27
|
|
|
69
|
-
return
|
|
28
|
+
return posthtmlWidows(options)
|
|
70
29
|
}
|
|
71
30
|
|
|
72
|
-
export default posthtmlPlugin
|
|
73
|
-
|
|
74
31
|
export async function preventWidows(html = '', options = {}, posthtmlOptions = {}) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.process(html, posthtmlOptions)
|
|
81
|
-
.then(result => result.html)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Apply to all elements
|
|
85
|
-
return removeWidows(html, options).res
|
|
32
|
+
return posthtml([
|
|
33
|
+
posthtmlPlugin(options)
|
|
34
|
+
])
|
|
35
|
+
.process(html, posthtmlOptions)
|
|
36
|
+
.then(result => result.html)
|
|
86
37
|
}
|
package/types/widowWords.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type { Opts } from 'string-remove-widows';
|
|
2
|
-
|
|
3
1
|
export default interface WidowWordsConfig {
|
|
4
2
|
/**
|
|
5
3
|
The attribute name to use.
|
|
6
4
|
|
|
7
|
-
@default 'prevent-widows'
|
|
5
|
+
@default ['prevent-widows', 'no-widows']
|
|
8
6
|
*/
|
|
9
|
-
|
|
7
|
+
attributes?: Array<string>;
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
Replace all widow word `nbsp;` instances with a single space.
|
|
@@ -14,45 +12,27 @@ export default interface WidowWordsConfig {
|
|
|
14
12
|
|
|
15
13
|
@default false
|
|
16
14
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
Convert the space entity to the `targetLanguage`.
|
|
21
|
-
|
|
22
|
-
@default true
|
|
23
|
-
*/
|
|
24
|
-
convertEntities?: Opts['convertEntities'];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
Language to encode non-breaking spaces in.
|
|
28
|
-
|
|
29
|
-
@default 'html'
|
|
30
|
-
*/
|
|
31
|
-
targetLanguage?: Opts['targetLanguage'];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
Should whitespace in front of dashes (-), n-dashes (–) or m-dashes (—) be replaced with a ` `.
|
|
35
|
-
|
|
36
|
-
@default true
|
|
37
|
-
*/
|
|
38
|
-
hyphens?: Opts['hyphens'];
|
|
15
|
+
createWidows?: Boolean;
|
|
39
16
|
|
|
40
17
|
/**
|
|
41
18
|
The minimum amount of words in a target string, in order to trigger the transformer.
|
|
42
19
|
|
|
43
20
|
@default 3
|
|
44
21
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
The minimum amount non-whitespace characters in a target string, in order to trigger the transformer.
|
|
49
|
-
|
|
50
|
-
@default 20
|
|
51
|
-
*/
|
|
52
|
-
minCharCount?: Opts['minCharCount'];
|
|
22
|
+
minWords?: Number;
|
|
53
23
|
|
|
54
24
|
/**
|
|
55
25
|
Start/end pairs of strings that will prevent the transformer from removing widow words inside them.
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
|
|
27
|
+
@default [
|
|
28
|
+
{ start: '{{', end: '}}' }, // Handlebars, Liquid, Nunjucks, Twig, Jinja2, Mustache
|
|
29
|
+
{ start: '{%', end: '%}' }, // Liquid, Nunjucks, Twig, Jinja2
|
|
30
|
+
{ start: '<%=', end: '%>' }, // EJS, ERB
|
|
31
|
+
{ start: '<%', end: '%>' }, // EJS, ERB
|
|
32
|
+
{ start: '{$', end: '}' }, // Smarty
|
|
33
|
+
{ start: '<\\?', end: '\\?>' }, // PHP
|
|
34
|
+
{ start: '#{', end: '}' } // Pug
|
|
35
|
+
]
|
|
36
|
+
*/
|
|
37
|
+
ignore?: Array<{ start: string; end: string }>;
|
|
58
38
|
}
|