@maizzle/framework 3.7.2 → 4.0.0-alpha.10
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/.github/workflows/nodejs.yml +28 -29
- package/bin/maizzle +3 -0
- package/package.json +91 -84
- package/src/commands/build.js +32 -0
- package/src/commands/serve.js +156 -0
- package/src/functions/plaintext.js +5 -0
- package/src/functions/render.js +5 -0
- package/src/generators/output/to-disk.js +120 -79
- package/src/generators/output/to-string.js +7 -8
- package/src/generators/plaintext.js +49 -52
- package/src/generators/postcss.js +29 -0
- package/src/generators/posthtml.js +66 -60
- package/src/generators/tailwindcss.js +116 -84
- package/src/index.js +14 -160
- package/src/transformers/{attribute-to-style.js → attributeToStyle.js} +0 -0
- package/src/transformers/baseUrl.js +69 -0
- package/src/transformers/{extra-attributes.js → extraAttributes.js} +0 -0
- package/src/transformers/filters/defaultFilters.js +126 -0
- package/src/transformers/filters/index.js +55 -0
- package/src/transformers/index.js +63 -57
- package/src/transformers/{inline.js → inlineCss.js} +1 -14
- package/src/transformers/minify.js +1 -1
- package/src/transformers/{posthtml-mso.js → posthtmlMso.js} +0 -0
- package/src/transformers/prettify.js +16 -9
- package/src/transformers/{prevent-widows.js → preventWidows.js} +0 -0
- package/src/transformers/{remove-attributes.js → removeAttributes.js} +1 -1
- package/src/transformers/{remove-inline-bgcolor.js → removeInlineBackgroundColor.js} +1 -1
- package/src/transformers/{remove-inline-sizes.js → removeInlineSizes.js} +0 -0
- package/src/transformers/removeInlinedSelectors.js +70 -0
- package/src/transformers/removeUnusedCss.js +40 -0
- package/src/transformers/{replace-strings.js → replaceStrings.js} +0 -0
- package/src/transformers/{safe-class-names.js → safeClassNames.js} +8 -2
- package/src/transformers/shorthandInlineCSS.js +19 -0
- package/src/transformers/sixHex.js +33 -0
- package/src/transformers/{url-params.js → urlParameters.js} +0 -0
- package/src/utils/helpers.js +2 -8
- package/test/expected/posthtml/component.html +13 -0
- package/test/expected/{inheritance.html → posthtml/extend-template.html} +2 -2
- package/test/expected/posthtml/fetch.html +5 -0
- package/test/expected/posthtml/layout.html +3 -0
- package/test/expected/transformers/atimport-in-style.html +15 -0
- package/test/expected/transformers/base-url.html +99 -0
- package/test/expected/transformers/filters.html +81 -0
- package/test/expected/transformers/preserve-transform-css.html +36 -0
- package/test/expected/useConfig.html +9 -0
- package/test/fixtures/basic.html +9 -9
- package/test/fixtures/posthtml/component.html +19 -0
- package/test/fixtures/{inheritance.html → posthtml/extend-template.html} +7 -7
- package/test/fixtures/posthtml/fetch.html +9 -0
- package/test/fixtures/posthtml/layout.html +11 -0
- package/test/fixtures/transformers/atimport-in-style.html +11 -0
- package/test/fixtures/transformers/base-url.html +101 -0
- package/test/fixtures/transformers/filters.html +87 -0
- package/test/fixtures/transformers/preserve-transform-css.html +25 -0
- package/test/fixtures/useConfig.html +9 -0
- package/test/stubs/components/component.html +5 -0
- package/test/stubs/data.json +14 -0
- package/test/stubs/layouts/basic.html +1 -0
- package/test/stubs/{layout.html → layouts/full.html} +0 -0
- package/test/stubs/{layout-basic.html → layouts/template.html} +5 -5
- package/test/stubs/post.css +6 -0
- package/test/stubs/tailwind/content-source.html +1 -0
- package/test/stubs/tailwind/tailwind.css +3 -0
- package/test/stubs/template.html +10 -10
- package/test/stubs/templates/1.html +1 -1
- package/test/stubs/templates/2.test +1 -0
- package/test/test-config.js +19 -19
- package/test/test-misc.js +8 -8
- package/test/test-postcss.js +8 -0
- package/test/test-posthtml.js +72 -0
- package/test/test-tailwindcss.js +117 -0
- package/test/test-todisk.js +142 -49
- package/test/test-tostring.js +148 -124
- package/test/test-transformers.js +510 -320
- package/xo.config.js +22 -19
- package/src/transformers/base-image-url.js +0 -9
- package/src/transformers/remove-unused-css.js +0 -20
- package/src/transformers/six-hex.js +0 -10
- package/src/transformers/transform.js +0 -24
- package/test/expected/transformers/base-image-url.html +0 -7
- package/test/fixtures/transformers/base-image-url.html +0 -7
- package/test/stubs/templates/2.html +0 -1
- package/test/stubs/templates/3.mzl +0 -1
- package/test/test-tailwind.js +0 -73
|
@@ -1,57 +1,63 @@
|
|
|
1
|
-
const inline = require('./
|
|
2
|
-
const minify = require('./minify')
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const removeUnusedCSS = require('./
|
|
13
|
-
const removeAttributes = require('./
|
|
14
|
-
const attributeToStyle = require('./
|
|
15
|
-
const removeInlineSizes = require('./
|
|
16
|
-
const applyExtraAttributes = require('./
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
html = await
|
|
23
|
-
html = await
|
|
24
|
-
html = await
|
|
25
|
-
html = await
|
|
26
|
-
html = await
|
|
27
|
-
html = await
|
|
28
|
-
html = await
|
|
29
|
-
html = await
|
|
30
|
-
html = await
|
|
31
|
-
html = await
|
|
32
|
-
html = await
|
|
33
|
-
html = await
|
|
34
|
-
html = await
|
|
35
|
-
html = await
|
|
36
|
-
html = await
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
57
|
-
exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true)
|
|
1
|
+
const inline = require('./inlineCss')
|
|
2
|
+
const minify = require('./minify')
|
|
3
|
+
const filters = require('./filters')
|
|
4
|
+
const markdown = require('./markdown')
|
|
5
|
+
const prettify = require('./prettify')
|
|
6
|
+
const ensureSixHEX = require('./sixHex')
|
|
7
|
+
const applyBaseImageUrl = require('./baseUrl')
|
|
8
|
+
const addURLParams = require('./urlParameters')
|
|
9
|
+
const preventWidows = require('./preventWidows')
|
|
10
|
+
const replaceStrings = require('./replaceStrings')
|
|
11
|
+
const safeClassNames = require('./safeClassNames')
|
|
12
|
+
const removeUnusedCSS = require('./removeUnusedCss')
|
|
13
|
+
const removeAttributes = require('./removeAttributes')
|
|
14
|
+
const attributeToStyle = require('./attributeToStyle')
|
|
15
|
+
const removeInlineSizes = require('./removeInlineSizes')
|
|
16
|
+
const applyExtraAttributes = require('./extraAttributes')
|
|
17
|
+
const shorthandInlineCSS = require('./shorthandInlineCSS')
|
|
18
|
+
const removeInlinedClasses = require('./removeInlinedSelectors')
|
|
19
|
+
const removeInlineBgColor = require('./removeInlineBackgroundColor')
|
|
20
|
+
|
|
21
|
+
exports.process = async (html, config) => {
|
|
22
|
+
html = await safeClassNames(html, config)
|
|
23
|
+
html = await filters(html, config)
|
|
24
|
+
html = await markdown(html, config)
|
|
25
|
+
html = await preventWidows(html, config)
|
|
26
|
+
html = await attributeToStyle(html, config)
|
|
27
|
+
html = await inline(html, config)
|
|
28
|
+
html = await shorthandInlineCSS(html, config)
|
|
29
|
+
html = await removeInlinedClasses(html, config)
|
|
30
|
+
html = await removeUnusedCSS(html, config)
|
|
31
|
+
html = await removeInlineSizes(html, config)
|
|
32
|
+
html = await removeInlineBgColor(html, config)
|
|
33
|
+
html = await removeAttributes(html, config)
|
|
34
|
+
html = await applyExtraAttributes(html, config)
|
|
35
|
+
html = await applyBaseImageUrl(html, config)
|
|
36
|
+
html = await addURLParams(html, config)
|
|
37
|
+
html = await ensureSixHEX(html, config)
|
|
38
|
+
html = await prettify(html, config)
|
|
39
|
+
html = await minify(html, config)
|
|
40
|
+
html = await replaceStrings(html, config)
|
|
41
|
+
|
|
42
|
+
return html
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.minify = (html, config) => minify(html, config, true)
|
|
46
|
+
exports.inlineCSS = (html, config) => inline(html, config, true)
|
|
47
|
+
exports.markdown = (html, config) => markdown(html, config, true)
|
|
48
|
+
exports.prettify = (html, config) => prettify(html, config, true)
|
|
49
|
+
exports.ensureSixHEX = (html, config) => ensureSixHEX(html, config)
|
|
50
|
+
exports.withFilters = (html, config) => filters(html, config, true)
|
|
51
|
+
exports.addURLParams = (html, config) => addURLParams(html, config, true)
|
|
52
|
+
exports.preventWidows = (html, config) => preventWidows(html, config, true)
|
|
53
|
+
exports.replaceStrings = (html, config) => replaceStrings(html, config, true)
|
|
54
|
+
exports.safeClassNames = (html, config) => safeClassNames(html, config, true)
|
|
55
|
+
exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config, true)
|
|
56
|
+
exports.removeAttributes = (html, config) => removeAttributes(html, config, true)
|
|
57
|
+
exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true)
|
|
58
|
+
exports.removeInlineSizes = (html, config) => removeInlineSizes(html, config, true)
|
|
59
|
+
exports.applyBaseImageUrl = (html, config) => applyBaseImageUrl(html, config, true)
|
|
60
|
+
exports.removeInlinedClasses = (html, config) => removeInlinedClasses(html, config)
|
|
61
|
+
exports.shorthandInlineCSS = (html, config) => shorthandInlineCSS(html, config, true)
|
|
62
|
+
exports.removeInlineBgColor = (html, config) => removeInlineBgColor(html, config, true)
|
|
63
|
+
exports.applyExtraAttributes = (html, config) => applyExtraAttributes(html, config, true)
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const juice = require('juice')
|
|
2
|
-
const posthtml = require('posthtml')
|
|
3
2
|
const {get, isObject, isEmpty} = require('lodash')
|
|
4
|
-
const mergeLonghand = require('posthtml-postcss-merge-longhand')
|
|
5
3
|
|
|
6
4
|
module.exports = async (html, config = {}, direct = false) => {
|
|
7
5
|
if (get(config, 'inlineCSS') === false) {
|
|
@@ -9,7 +7,7 @@ module.exports = async (html, config = {}, direct = false) => {
|
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
const options = direct ? config : get(config, 'inlineCSS', {})
|
|
12
|
-
const removeStyleTags = get(options, 'removeStyleTags',
|
|
10
|
+
const removeStyleTags = get(options, 'removeStyleTags', false)
|
|
13
11
|
const css = get(config, 'customCSS', false)
|
|
14
12
|
|
|
15
13
|
if (get(config, 'inlineCSS') === true || !isEmpty(options)) {
|
|
@@ -32,17 +30,6 @@ module.exports = async (html, config = {}, direct = false) => {
|
|
|
32
30
|
|
|
33
31
|
html = css ? juice.inlineContent(html, css, {removeStyleTags}) : juice(html, {removeStyleTags})
|
|
34
32
|
|
|
35
|
-
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
36
|
-
const mergeLonghandConfig = get(options, 'mergeLonghand', [])
|
|
37
|
-
|
|
38
|
-
if (typeof mergeLonghandConfig === 'boolean' && mergeLonghandConfig) {
|
|
39
|
-
html = await posthtml([mergeLonghand()]).process(html, posthtmlOptions).then(result => result.html)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (isObject(mergeLonghandConfig) && !isEmpty(mergeLonghandConfig)) {
|
|
43
|
-
html = await posthtml([mergeLonghand({tags: mergeLonghandConfig})]).process(html, posthtmlOptions).then(result => result.html)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
33
|
return html
|
|
47
34
|
}
|
|
48
35
|
|
|
File without changes
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
2
|
const pretty = require('pretty')
|
|
3
|
+
const {get, merge, isEmpty, isObject} = require('lodash')
|
|
3
4
|
|
|
4
5
|
module.exports = async (html, config = {}, direct = false) => {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
space_around_combinator: true, // Preserve space around CSS selector combinators
|
|
8
|
+
newline_between_rules: false, // Remove empty lines between CSS rules
|
|
9
|
+
indent_inner_html: false, // Helps reduce file size
|
|
10
|
+
extra_liners: [] // Don't add extra new line before any tag
|
|
7
11
|
}
|
|
8
12
|
|
|
9
|
-
config = direct ? config : get(config, 'prettify'
|
|
13
|
+
config = direct ? config : get(config, 'prettify')
|
|
10
14
|
|
|
11
|
-
if
|
|
12
|
-
|
|
15
|
+
// Don't prettify if not explicitly enabled in config
|
|
16
|
+
if (!config || (isObject(config) && isEmpty(config))) {
|
|
17
|
+
return html
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
if (
|
|
16
|
-
return pretty(html,
|
|
20
|
+
if (typeof config === 'boolean' && config) {
|
|
21
|
+
return pretty(html, defaultConfig)
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
config = merge(defaultConfig, config)
|
|
25
|
+
|
|
26
|
+
return pretty(html, config)
|
|
20
27
|
}
|
|
File without changes
|
|
@@ -8,7 +8,7 @@ module.exports = async (html, config = {}, direct = false) => {
|
|
|
8
8
|
|
|
9
9
|
attributes.push({name: 'style'}, {name: 'class'})
|
|
10
10
|
|
|
11
|
-
// Allow
|
|
11
|
+
// Allow omitting `value` key when removing empty attributes
|
|
12
12
|
attributes.forEach(attr => {
|
|
13
13
|
attr.value = attr.value || ''
|
|
14
14
|
})
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const {get, has, remove} = require('lodash')
|
|
2
|
+
const postcss = require('postcss')
|
|
3
|
+
const posthtml = require('posthtml')
|
|
4
|
+
const parseAttrs = require('posthtml-attrs-parser')
|
|
5
|
+
const matchHelper = require('posthtml-match-helper')
|
|
6
|
+
|
|
7
|
+
module.exports = async (html, config = {}) => {
|
|
8
|
+
if (get(config, 'removeInlinedClasses') === false) {
|
|
9
|
+
return html
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
13
|
+
return posthtml([plugin()]).process(html, posthtmlOptions).then(result => result.html)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const plugin = () => tree => {
|
|
17
|
+
const process = node => {
|
|
18
|
+
// For each style tag...
|
|
19
|
+
if (node.tag === 'style') {
|
|
20
|
+
const {root} = postcss().process(node.content)
|
|
21
|
+
|
|
22
|
+
root.walkRules(rule => {
|
|
23
|
+
// Skip media queries and such...
|
|
24
|
+
if (rule.parent.type === 'atrule') {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {selector} = rule
|
|
29
|
+
const prop = get(rule.nodes[0], 'prop')
|
|
30
|
+
|
|
31
|
+
// If we find the selector in the HTML...
|
|
32
|
+
tree.match(matchHelper(selector), n => {
|
|
33
|
+
const parsedAttrs = parseAttrs(n.attrs)
|
|
34
|
+
const classAttr = get(parsedAttrs, 'class', [])
|
|
35
|
+
const styleAttr = get(parsedAttrs, 'style', {})
|
|
36
|
+
|
|
37
|
+
// If the class is in the style attribute (inlined), remove it
|
|
38
|
+
if (has(styleAttr, prop)) {
|
|
39
|
+
// Remove the class attribute
|
|
40
|
+
remove(classAttr, s => selector.includes(s))
|
|
41
|
+
|
|
42
|
+
// Remove the rule in the <style> tag
|
|
43
|
+
rule.remove()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Remove from <style> selectors that were used to create shorthand declarations
|
|
48
|
+
* like `margin: 0 0 0 16px` (transformed with mergeLonghand when inlining).
|
|
49
|
+
*/
|
|
50
|
+
Object.keys(styleAttr).forEach(key => {
|
|
51
|
+
if (prop.includes(key)) {
|
|
52
|
+
rule.remove()
|
|
53
|
+
remove(classAttr, s => selector.includes(s))
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
n.attrs = parsedAttrs.compose()
|
|
58
|
+
|
|
59
|
+
return n
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
node.content = root.toString()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return node
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return tree.walk(process)
|
|
70
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const {comb} = require('email-comb')
|
|
2
|
+
const {get, isEmpty} = require('lodash')
|
|
3
|
+
|
|
4
|
+
module.exports = async (html, config = {}, direct = false) => {
|
|
5
|
+
if (get(config, 'removeUnusedCSS') === false) {
|
|
6
|
+
return html
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const options = direct ? config : get(config, 'removeUnusedCSS', {})
|
|
10
|
+
|
|
11
|
+
const safelist = [
|
|
12
|
+
'*body*', // Gmail
|
|
13
|
+
'.gmail*', // Gmail
|
|
14
|
+
'.apple*', // Apple Mail
|
|
15
|
+
'.ios*', // Mail on iOS
|
|
16
|
+
'.ox-*', // Open-Xchange
|
|
17
|
+
'.outlook*', // Outlook.com
|
|
18
|
+
'.ogs*', // Outlook.com
|
|
19
|
+
'.bloop_container', // Airmail
|
|
20
|
+
'.Singleton', // Apple Mail 10
|
|
21
|
+
'.unused', // Notes 8
|
|
22
|
+
'.moz-text-html', // Thunderbird
|
|
23
|
+
'.mail-detail-content', // Comcast, Libero webmail
|
|
24
|
+
'*edo*', // Edison (all)
|
|
25
|
+
'#*', // Freenet uses #msgBody
|
|
26
|
+
'.lang*' // Fenced code blocks
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
if (typeof options === 'boolean' && options) {
|
|
30
|
+
return comb(html, {whitelist: safelist}).result
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!isEmpty(options)) {
|
|
34
|
+
options.whitelist = [...get(options, 'whitelist', []), ...safelist]
|
|
35
|
+
|
|
36
|
+
return comb(html, options).result
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return html
|
|
40
|
+
}
|
|
File without changes
|
|
@@ -3,11 +3,17 @@ const posthtml = require('posthtml')
|
|
|
3
3
|
const safeClassNames = require('posthtml-safe-class-names')
|
|
4
4
|
|
|
5
5
|
module.exports = async (html, config = {}, direct = false) => {
|
|
6
|
-
|
|
6
|
+
const option = get(config, 'safeClassNames')
|
|
7
|
+
|
|
8
|
+
if (option === false) {
|
|
7
9
|
return html
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
/*
|
|
13
|
+
* Setting it to `true` in the config will run `safeClassNames`
|
|
14
|
+
* no matter the environment.
|
|
15
|
+
*/
|
|
16
|
+
if (config.env === 'local' && !option) {
|
|
11
17
|
return html
|
|
12
18
|
}
|
|
13
19
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const posthtml = require('posthtml')
|
|
2
|
+
const {get, isObject, isEmpty} = require('lodash')
|
|
3
|
+
const mergeLonghand = require('posthtml-postcss-merge-longhand')
|
|
4
|
+
|
|
5
|
+
module.exports = async (html, config, direct = false) => {
|
|
6
|
+
config = direct ? (isObject(config) ? config : true) : get(config, 'shorthandInlineCSS', [])
|
|
7
|
+
|
|
8
|
+
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
9
|
+
|
|
10
|
+
if (typeof config === 'boolean' && config) {
|
|
11
|
+
html = await posthtml([mergeLonghand()]).process(html, posthtmlOptions).then(result => result.html)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isObject(config) && !isEmpty(config)) {
|
|
15
|
+
html = await posthtml([mergeLonghand(config)]).process(html, posthtmlOptions).then(result => result.html)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return html
|
|
19
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const {get} = require('lodash')
|
|
2
|
+
const posthtml = require('posthtml')
|
|
3
|
+
const parseAttrs = require('posthtml-attrs-parser')
|
|
4
|
+
const {conv} = require('color-shorthand-hex-to-six-digit')
|
|
5
|
+
|
|
6
|
+
module.exports = async (html, config = {}) => {
|
|
7
|
+
if (get(config, 'sixHex') === false) {
|
|
8
|
+
return html
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
12
|
+
return posthtml([sixHex()]).process(html, posthtmlOptions).then(result => result.html)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sixHex = () => tree => {
|
|
16
|
+
const process = node => {
|
|
17
|
+
const attrs = parseAttrs(node.attrs)
|
|
18
|
+
|
|
19
|
+
const targets = ['bgcolor', 'color']
|
|
20
|
+
|
|
21
|
+
targets.forEach(attribute => {
|
|
22
|
+
if (attrs[attribute]) {
|
|
23
|
+
attrs[attribute] = conv(attrs[attribute])
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
node.attrs = attrs.compose()
|
|
28
|
+
|
|
29
|
+
return node
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return tree.walk(process)
|
|
33
|
+
}
|
|
File without changes
|
package/src/utils/helpers.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const readline = require('readline')
|
|
2
|
-
|
|
3
1
|
module.exports = {
|
|
4
2
|
asyncForEach: async (array, callback) => {
|
|
5
3
|
for (let index = 0; index < array.length; index++) {
|
|
@@ -14,10 +12,6 @@ module.exports = {
|
|
|
14
12
|
throw new Error(`could not load ${module}`)
|
|
15
13
|
}
|
|
16
14
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console.log(blank)
|
|
20
|
-
readline.cursorTo(process.stdout, 0, 0)
|
|
21
|
-
readline.clearScreenDown(process.stdout)
|
|
22
|
-
}
|
|
15
|
+
// https://github.com/lukeed/console-clear
|
|
16
|
+
clearConsole: () => process.stdout.write('\x1B[H\x1B[2J')
|
|
23
17
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Parent
|
|
2
|
-
Child in second.html
|
|
1
|
+
Parent
|
|
2
|
+
Child in second.html
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<style>.test {
|
|
4
|
+
background-image: url('https://example.com/image.jpg');
|
|
5
|
+
background: url('https://example.com/image.jpg');
|
|
6
|
+
background-image: url('https://preserve.me/image.jpg');
|
|
7
|
+
background: url('https://preserve.me/image.jpg');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.test-2 {
|
|
11
|
+
background-image: url("https://example.com/image.jpg");
|
|
12
|
+
background: url("https://example.com/image.jpg");
|
|
13
|
+
background-image: url("https://preserve.me/image.jpg");
|
|
14
|
+
background: url("https://preserve.me/image.jpg");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.test-3 {
|
|
18
|
+
background-image: url(https://example.com/image.jpg);
|
|
19
|
+
background: url(https://example.com/image.jpg);
|
|
20
|
+
background-image: url(https://preserve.me/image.jpg);
|
|
21
|
+
background: url(https://preserve.me/image.jpg);
|
|
22
|
+
}</style>
|
|
23
|
+
</head>
|
|
24
|
+
|
|
25
|
+
<body>
|
|
26
|
+
<img src="https://example.com/test.jpg">
|
|
27
|
+
<img src="https://example.com/test.jpg">
|
|
28
|
+
|
|
29
|
+
<img src="https://example.com/image1.jpg" srcset="https://example.com/image1-HD.jpg 2x, https://example.com/image1-phone.jpg 100w">
|
|
30
|
+
|
|
31
|
+
<img src="https://example.com/image2.jpg" srcset="https://example.com/image2-HD.jpg 2x, https://example.com/image2-phone.jpg 100w">
|
|
32
|
+
|
|
33
|
+
<picture>
|
|
34
|
+
<source media="(max-width: 799px)" srcset="https://example.com/elva-480w-close-portrait.jpg">
|
|
35
|
+
<source media="(min-width: 800px)" srcset="https://example.com/elva-800w.jpg">
|
|
36
|
+
<img src="https://example.com/elva-800w.jpg" alt="...">
|
|
37
|
+
</picture>
|
|
38
|
+
|
|
39
|
+
<video width="250" poster="https://example.com/flower.jpg">
|
|
40
|
+
<source src="https://example.com/media/flower.webm" type="video/webm">
|
|
41
|
+
<source src="https://example.tv/media/flower.mp4" type="video/mp4">
|
|
42
|
+
<track default="" kind="captions" srclang="en" src="https://example.com/media/tracks/friday.vtt">
|
|
43
|
+
</video>
|
|
44
|
+
|
|
45
|
+
<audio src="https://example.com/media/sample.mp3">
|
|
46
|
+
Fallback content
|
|
47
|
+
</audio>
|
|
48
|
+
|
|
49
|
+
<embed type="video/webm" src="https://example.com/media/flower.mp4" width="250" height="200">
|
|
50
|
+
|
|
51
|
+
<iframe width="300" height="200" src="https://example.com/embed.html"></iframe>
|
|
52
|
+
|
|
53
|
+
<input type="image" src="https://example.com/image.jpg" alt="">
|
|
54
|
+
|
|
55
|
+
<script src="https://example.com/javascript.js"></script>
|
|
56
|
+
|
|
57
|
+
<div>
|
|
58
|
+
<!--[if mso]>
|
|
59
|
+
<v:image xmlns:v="urn:schemas-microsoft-com:vml" src="https://example.com/image.jpg" style="width:600px;height:400px;" />
|
|
60
|
+
<v:rect fill="false" stroke="false" style="position:absolute;width:600px;height:400px;">
|
|
61
|
+
<v:textbox inset="0,0,0,0"><div><![endif]-->
|
|
62
|
+
<div>test</div>
|
|
63
|
+
<!--[if mso]></div></v:textbox></v:rect><![endif]-->
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<!--[if mso]>
|
|
67
|
+
<v:image src="https://example.com/image-2.jpg" xmlns:v="urn:schemas-microsoft-com:vml" style="width:600px;height:400px;" />
|
|
68
|
+
<![endif]-->
|
|
69
|
+
|
|
70
|
+
<!--[if mso]>
|
|
71
|
+
<v:image xmlns:v="urn:schemas-microsoft-com:vml" src="https://example.com/image-3.jpg" style="width:600px;height:400px;" />
|
|
72
|
+
<![endif]-->
|
|
73
|
+
|
|
74
|
+
<table>
|
|
75
|
+
<tr>
|
|
76
|
+
<td background="https://example.com/image.png" bgcolor="#7bceeb" width="120" height="92" valign="top">
|
|
77
|
+
<!--[if gte mso 9]>
|
|
78
|
+
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:120px;height:92px;">
|
|
79
|
+
<v:fill type="tile" src="https://example.com/image.png" color="#7bceeb" />
|
|
80
|
+
<v:textbox inset="0,0,0,0">
|
|
81
|
+
<![endif]-->
|
|
82
|
+
<div>test</div>
|
|
83
|
+
<!--[if gte mso 9]>
|
|
84
|
+
</v:textbox>
|
|
85
|
+
</v:rect>
|
|
86
|
+
<![endif]-->
|
|
87
|
+
</td>
|
|
88
|
+
</tr>
|
|
89
|
+
</table>
|
|
90
|
+
|
|
91
|
+
<!--[if mso]>
|
|
92
|
+
<v:fill type="tile" src="https://example.com/image.png" color="#7bceeb" />
|
|
93
|
+
<![endif]-->
|
|
94
|
+
|
|
95
|
+
<!--[if mso]>
|
|
96
|
+
<v:fill type="tile" src="https://example.com/image.png" color="#7bceeb" />
|
|
97
|
+
<![endif]-->
|
|
98
|
+
</body>
|
|
99
|
+
</html>
|