@maizzle/framework 4.2.2 → 4.2.4

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.
Files changed (41) hide show
  1. package/package.json +2 -3
  2. package/src/generators/output/to-string.js +1 -4
  3. package/src/generators/plaintext.js +40 -6
  4. package/src/generators/posthtml/defaultConfig.js +3 -0
  5. package/src/generators/{posthtml.js → posthtml/index.js} +2 -1
  6. package/src/generators/tailwindcss.js +9 -2
  7. package/src/transformers/attributeToStyle.js +3 -2
  8. package/src/transformers/baseUrl.js +27 -26
  9. package/src/transformers/extraAttributes.js +3 -2
  10. package/src/transformers/filters/index.js +8 -2
  11. package/src/transformers/index.js +5 -3
  12. package/src/transformers/markdown.js +2 -1
  13. package/src/transformers/posthtmlMso.js +3 -2
  14. package/src/transformers/preventWidows.js +75 -7
  15. package/src/transformers/removeAttributes.js +48 -9
  16. package/src/transformers/removeInlineBackgroundColor.js +8 -4
  17. package/src/transformers/removeInlineSizes.js +8 -5
  18. package/src/transformers/removeInlinedSelectors.js +19 -5
  19. package/src/transformers/removeUnusedCss.js +12 -12
  20. package/src/transformers/replaceStrings.js +1 -1
  21. package/src/transformers/safeClassNames.js +7 -3
  22. package/src/transformers/shorthandInlineCSS.js +3 -2
  23. package/src/transformers/sixHex.js +13 -14
  24. package/src/transformers/urlParameters.js +3 -2
  25. package/src/utils/helpers.js +2 -1
  26. package/test/expected/transformers/base-url.html +1 -1
  27. package/test/fixtures/posthtml/component.html +2 -2
  28. package/test/stubs/breaking/bad.html +2 -2
  29. package/test/stubs/components/component.html +2 -2
  30. package/test/stubs/events/before-create.html +1 -1
  31. package/test/stubs/plaintext/plaintext.html +1 -1
  32. package/test/stubs/templates/1.html +1 -1
  33. package/test/stubs/templates/2.html +1 -0
  34. package/test/stubs/templates/2.test +1 -1
  35. package/test/test-posthtml.js +20 -31
  36. package/test/test-tailwindcss.js +6 -6
  37. package/test/test-todisk.js +14 -64
  38. package/test/test-tostring.js +20 -15
  39. package/test/test-transformers.js +113 -21
  40. package/test/expected/posthtml/fetch.html +0 -5
  41. package/test/fixtures/posthtml/fetch.html +0 -9
@@ -1,4 +1,4 @@
1
- const {isEmpty, get} = require('lodash')
1
+ const {get, isEmpty} = require('lodash')
2
2
 
3
3
  module.exports = async (html, config = {}, direct = false) => {
4
4
  const replacements = direct ? config : get(config, 'replaceStrings', {})
@@ -1,6 +1,7 @@
1
- const {get} = require('lodash')
2
1
  const posthtml = require('posthtml')
2
+ const {get, merge} = require('lodash')
3
3
  const safeClassNames = require('posthtml-safe-class-names')
4
+ const defaultConfig = require('../generators/posthtml/defaultConfig')
4
5
 
5
6
  module.exports = async (html, config = {}, direct = false) => {
6
7
  const option = get(config, 'safeClassNames')
@@ -17,8 +18,11 @@ module.exports = async (html, config = {}, direct = false) => {
17
18
  return html
18
19
  }
19
20
 
20
- const posthtmlOptions = get(config, 'build.posthtml.options', {})
21
- const replacements = direct ? config : get(config, 'safeClassNames', {})
21
+ const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
22
+ const replacements = direct ? config : get(config, 'safeClassNames', {
23
+ '{': '{',
24
+ '}': '}'
25
+ })
22
26
 
23
27
  return posthtml([safeClassNames({replacements})]).process(html, posthtmlOptions).then(result => result.html)
24
28
  }
@@ -1,11 +1,12 @@
1
1
  const posthtml = require('posthtml')
2
- const {get, isObject, isEmpty} = require('lodash')
2
+ const {get, merge, isObject, isEmpty} = require('lodash')
3
3
  const mergeLonghand = require('posthtml-postcss-merge-longhand')
4
+ const defaultConfig = require('../generators/posthtml/defaultConfig')
4
5
 
5
6
  module.exports = async (html, config, direct = false) => {
6
7
  config = direct ? (isObject(config) ? config : true) : get(config, 'shorthandInlineCSS', [])
7
8
 
8
- const posthtmlOptions = get(config, 'build.posthtml.options', {})
9
+ const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
9
10
 
10
11
  if (typeof config === 'boolean' && config) {
11
12
  html = await posthtml([mergeLonghand()]).process(html, posthtmlOptions).then(result => result.html)
@@ -1,30 +1,29 @@
1
- const {get} = require('lodash')
2
1
  const posthtml = require('posthtml')
3
- const parseAttrs = require('posthtml-attrs-parser')
2
+ const {get, merge} = require('lodash')
4
3
  const {conv} = require('color-shorthand-hex-to-six-digit')
4
+ const defaultConfig = require('../generators/posthtml/defaultConfig')
5
5
 
6
6
  module.exports = async (html, config = {}) => {
7
7
  if (get(config, 'sixHex') === false) {
8
8
  return html
9
9
  }
10
10
 
11
- const posthtmlOptions = get(config, 'build.posthtml.options', {})
11
+ const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
12
+
12
13
  return posthtml([sixHex()]).process(html, posthtmlOptions).then(result => result.html)
13
14
  }
14
15
 
15
16
  const sixHex = () => tree => {
16
- const process = node => {
17
- const attrs = parseAttrs(node.attrs)
18
-
19
- const targets = ['bgcolor', 'color']
17
+ const targets = new Set(['bgcolor', 'color'])
20
18
 
21
- targets.forEach(attribute => {
22
- if (attrs[attribute]) {
23
- attrs[attribute] = conv(attrs[attribute])
24
- }
25
- })
26
-
27
- node.attrs = attrs.compose()
19
+ const process = node => {
20
+ if (node.attrs) {
21
+ Object.entries(node.attrs).forEach(([name, value]) => {
22
+ if (targets.has(name) && node.attrs[name]) {
23
+ node.attrs[name] = conv(value)
24
+ }
25
+ })
26
+ }
28
27
 
29
28
  return node
30
29
  }
@@ -1,12 +1,13 @@
1
1
  const posthtml = require('posthtml')
2
- const {get, isEmpty} = require('lodash')
2
+ const {get, merge, isEmpty} = require('lodash')
3
3
  const urlParams = require('posthtml-url-parameters')
4
+ const defaultConfig = require('../generators/posthtml/defaultConfig')
4
5
 
5
6
  module.exports = async (html, config = {}, direct = false) => {
6
7
  const urlParameters = direct ? config : get(config, 'urlParameters', {})
7
8
 
8
9
  if (!isEmpty(urlParameters)) {
9
- const posthtmlOptions = get(config, 'build.posthtml.options', {})
10
+ const posthtmlOptions = merge(defaultConfig, get(config, 'build.posthtml.options', {}))
10
11
  const {_options, ...parameters} = urlParameters
11
12
  const tags = get(_options, 'tags', ['a'])
12
13
  const strict = get(_options, 'strict', true)
@@ -13,5 +13,6 @@ module.exports = {
13
13
  }
14
14
  },
15
15
  // https://github.com/lukeed/console-clear
16
- clearConsole: () => process.stdout.write('\x1B[H\x1B[2J')
16
+ clearConsole: () => process.stdout.write('\x1B[H\x1B[2J'),
17
+ toStyleString: (object = {}) => Object.entries(object).map(([k, v]) => `${k}: ${v}`).join('; ')
17
18
  }
@@ -39,7 +39,7 @@
39
39
  <video width="250" poster="https://example.com/flower.jpg">
40
40
  <source src="https://example.com/media/flower.webm" type="video/webm">
41
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">
42
+ <track default kind="captions" srclang="en" src="https://example.com/media/tracks/friday.vtt">
43
43
  </video>
44
44
 
45
45
  <audio src="https://example.com/media/sample.mp3">
@@ -5,7 +5,7 @@
5
5
  "foo": "bar"
6
6
  }'
7
7
  >
8
- Variable from page: [[ page.env ]]
8
+ <p>Variable from page: [[ page.env ]]</p>
9
9
 
10
10
  <component
11
11
  src="test/stubs/components/component.html"
@@ -14,6 +14,6 @@ Variable from page: [[ page.env ]]
14
14
  "foo": "bar (nested)"
15
15
  }'
16
16
  >
17
- Variable from page (nested): [[ page.env ]]
17
+ <p>Variable from page (nested): [[ page.env ]]</p>
18
18
  </component>
19
19
  </component>
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: [THIS] should break
2
+ title: [THIS] should break the build
3
3
  ---
4
4
 
5
- <div>{{ page.title }}</div>
5
+ <div class="inline">{{ page.title }}</div>
@@ -1,5 +1,5 @@
1
- Variable from attribute: [[ text ]]
1
+ <p>Variable from attribute: [[ text ]]</p>
2
2
 
3
- Variable from locals attribute: [[ foo ]]
3
+ <p>Variable from locals attribute: [[ foo ]]</p>
4
4
 
5
5
  <content></content>
@@ -1 +1 @@
1
- Foo is {{ page.foo }}
1
+ <div class="inline">Foo is {{ page.foo }}</div>
@@ -1,5 +1,5 @@
1
1
  <div>Show in HTML</div>
2
2
  <plaintext>Show in plaintext</plaintext>
3
3
  <not-plaintext>
4
- <table><tr><td>Remove from plaintext</td></tr></table>
4
+ <p>Do not show <a href="url">this</a> in plaintext.</p>
5
5
  </not-plaintext>
@@ -1 +1 @@
1
- html
1
+ <div class="inline">html</div>
@@ -0,0 +1 @@
1
+ <div class="inline">html modified</div>
@@ -1 +1 @@
1
- test
1
+ test
@@ -1,17 +1,7 @@
1
1
  const test = require('ava')
2
- const Maizzle = require('../src')
2
+ const {render} = require('../src')
3
3
 
4
- const path = require('path')
5
- const fs = require('fs')
6
-
7
- const readFile = (dir, filename) => fs.promises
8
- .readFile(path.join(__dirname, dir, `${filename}.html`), 'utf8')
9
- .then(html => html.trim())
10
-
11
- const fixture = file => readFile('fixtures', file)
12
- const expected = file => readFile('expected', file)
13
-
14
- const renderString = (string, options = {}) => Maizzle.render(string, options).then(({html}) => html)
4
+ const renderString = (string, options = {}) => render(string, options).then(({html}) => html)
15
5
 
16
6
  test('layouts', async t => {
17
7
  const source = `---
@@ -58,7 +48,7 @@ test('components', async t => {
58
48
  "foo": "bar"
59
49
  }'
60
50
  >
61
- Variable from page: [[ page.env ]]
51
+ <p class="hidden">Variable from page: [[ page.env ]]</p>
62
52
 
63
53
  <component
64
54
  src="test/stubs/components/component.html"
@@ -67,7 +57,7 @@ Variable from page: [[ page.env ]]
67
57
  "foo": "bar (nested)"
68
58
  }'
69
59
  >
70
- Variable from page (nested): [[ page.env ]]
60
+ <p>Variable from page (nested): [[ page.env ]]</p>
71
61
  </component>
72
62
  </component>`
73
63
 
@@ -86,23 +76,23 @@ Variable from page (nested): [[ page.env ]]
86
76
 
87
77
  const html = await renderString(source, options)
88
78
 
89
- t.is(html.trim(), `Variable from attribute: Example
90
-
91
- Variable from locals attribute: bar
92
-
93
-
94
- Variable from page: prod
95
-
96
- Variable from attribute: Nested component
97
-
98
- Variable from locals attribute: bar (nested)
99
-
100
-
101
- Variable from page (nested): prod`)
79
+ t.is(html.trim(), `<p>Variable from attribute: Example</p>
80
+ <p>Variable from locals attribute: bar</p><p class="hidden">Variable from page: prod</p>
81
+ <p>Variable from attribute: Nested component</p>
82
+ <p>Variable from locals attribute: bar (nested)</p><p>Variable from page (nested): prod</p>`)
102
83
  })
103
84
 
104
85
  test('fetch component', async t => {
105
- const source = await fixture('posthtml/fetch')
86
+ const source = `<extends src="test/stubs/layouts/basic.html">
87
+ <block name="template">
88
+ <fetch url="test/stubs/data.json">
89
+ <each loop="user in response">
90
+ [[ user.name + (loop.last ? '' : ', ') ]]
91
+ </each>
92
+ </fetch>
93
+ </block>
94
+ </extends>`
95
+
106
96
  const options = {
107
97
  maizzle: {
108
98
  env: 'maizzle-ci',
@@ -116,8 +106,7 @@ test('fetch component', async t => {
116
106
  }
117
107
  }
118
108
 
119
- let html = await renderString(source, options)
120
- html = html.replace(/[^\S\r\n]+$/gm, '')
109
+ const html = await renderString(source, options)
121
110
 
122
- t.is(html.trim(), await expected('posthtml/fetch'))
111
+ t.is(html.trim(), 'Leanne Graham, Ervin Howell, Clementine Bauch')
123
112
  })
@@ -3,7 +3,7 @@ const Tailwind = require('../src/generators/tailwindcss')
3
3
 
4
4
  test('throws on compile error', async t => {
5
5
  await t.throwsAsync(async () => {
6
- await Tailwind.compile('.test {@apply inexistent;}', '<div class="test">Test</a>', {}, {})
6
+ await Tailwind.compile('div {@apply inexistent;}', '<div class="inline">Test</a>', {}, {})
7
7
  }, {instanceOf: SyntaxError})
8
8
  })
9
9
 
@@ -51,7 +51,7 @@ test('works with custom `content` sources', async t => {
51
51
  test('works with custom `files` sources', async t => {
52
52
  const css = await Tailwind.compile(
53
53
  '@tailwind utilities;',
54
- '<div></div>',
54
+ '<div class="inline"></div>',
55
55
  {
56
56
  content: {
57
57
  files: ['./test/stubs/tailwind/*.*']
@@ -65,7 +65,7 @@ test('works with custom `files` sources', async t => {
65
65
  test('uses maizzle template path as content source', async t => {
66
66
  const css = await Tailwind.compile(
67
67
  '@tailwind utilities;',
68
- '<div></div>',
68
+ '<div class="inline"></div>',
69
69
  {},
70
70
  {
71
71
  build: {
@@ -82,7 +82,7 @@ test('uses maizzle template path as content source', async t => {
82
82
  test('uses maizzle template path as content source (single file)', async t => {
83
83
  const css = await Tailwind.compile(
84
84
  '@tailwind utilities;',
85
- '<div></div>',
85
+ '<div class="inline"></div>',
86
86
  {},
87
87
  {
88
88
  build: {
@@ -108,8 +108,8 @@ test('uses custom postcss plugins from the maizzle config', async t => {
108
108
  }
109
109
  }
110
110
 
111
- const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
111
+ const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test inline">Test</a>', {}, maizzleConfig)
112
112
 
113
113
  t.not(css, undefined)
114
- t.is(css.trim(), '.test {-webkit-transform: scale(0.5);transform: scale(0.5)}')
114
+ t.is(css.trim(), '.inline {display: inline !important} .test {-webkit-transform: scale(0.5);transform: scale(0.5)}')
115
115
  })
@@ -30,11 +30,6 @@ test('skips if no templates found', async t => {
30
30
  destination: {
31
31
  path: t.context.folder
32
32
  }
33
- },
34
- tailwind: {
35
- config: {
36
- purge: false
37
- }
38
33
  }
39
34
  }
40
35
  })
@@ -68,8 +63,8 @@ test('outputs files at the correct location', async t => {
68
63
  })
69
64
 
70
65
  t.true(await fs.pathExists(t.context.folder))
71
- t.is(string.length, 2)
72
- t.is(array.length, 2)
66
+ t.is(string.length, 3)
67
+ t.is(array.length, 3)
73
68
  })
74
69
 
75
70
  test('outputs files at the correct location if multiple template sources are used', async t => {
@@ -94,7 +89,7 @@ test('outputs files at the correct location if multiple template sources are use
94
89
  })
95
90
 
96
91
  t.true(await fs.pathExists(t.context.folder))
97
- t.is(files.length, 5)
92
+ t.is(files.length, 6)
98
93
  })
99
94
 
100
95
  test('copies all files in the `filetypes` option to destination', async t => {
@@ -107,11 +102,6 @@ test('copies all files in the `filetypes` option to destination', async t => {
107
102
  destination: {
108
103
  path: t.context.folder
109
104
  }
110
- },
111
- tailwind: {
112
- config: {
113
- purge: false
114
- }
115
105
  }
116
106
  }
117
107
  })
@@ -130,11 +120,6 @@ test('outputs files with the correct extension', async t => {
130
120
  path: t.context.folder,
131
121
  extension: 'blade.php'
132
122
  }
133
- },
134
- tailwind: {
135
- config: {
136
- purge: false
137
- }
138
123
  }
139
124
  }
140
125
  })
@@ -168,7 +153,7 @@ test('outputs plaintext files', async t => {
168
153
 
169
154
  t.is(
170
155
  await fs.readFile(`${t.context.folder}/plaintext.html`, 'utf8'),
171
- '<div>Show in HTML</div>\n\n\n <table><tr><td>Remove from plaintext</td></tr></table>\n\n'
156
+ '<div>Show in HTML</div>\n\n\n <p>Do not show <a href="url">this</a> in plaintext.</p>\n\n'
172
157
  )
173
158
  })
174
159
 
@@ -240,11 +225,6 @@ test('copies assets to destination', async t => {
240
225
  source: 'test/stubs/assets',
241
226
  destination: 'images'
242
227
  }
243
- },
244
- tailwind: {
245
- config: {
246
- purge: false
247
- }
248
228
  }
249
229
  }
250
230
  })
@@ -264,11 +244,6 @@ test('runs the `beforeCreate` event', async t => {
264
244
  destination: {
265
245
  path: t.context.folder
266
246
  }
267
- },
268
- tailwind: {
269
- config: {
270
- purge: false
271
- }
272
247
  }
273
248
  },
274
249
  events: {
@@ -281,7 +256,7 @@ test('runs the `beforeCreate` event', async t => {
281
256
  const filename = await fs.readdir(t.context.folder)
282
257
  const html = await fs.readFile(`${t.context.folder}/${filename[0]}`, 'utf8')
283
258
 
284
- t.is(html.trim(), 'Foo is bar')
259
+ t.is(html.trim(), '<div class="inline">Foo is bar</div>')
285
260
  })
286
261
 
287
262
  test('runs the `afterBuild` event', async t => {
@@ -293,11 +268,6 @@ test('runs the `afterBuild` event', async t => {
293
268
  destination: {
294
269
  path: t.context.folder
295
270
  }
296
- },
297
- tailwind: {
298
- config: {
299
- purge: false
300
- }
301
271
  }
302
272
  },
303
273
  events: {
@@ -325,11 +295,6 @@ test('supports multiple asset paths', async t => {
325
295
  source: ['test/stubs/assets', 'test/stubs/plaintext', 'test/stubs/invalid'],
326
296
  destination: 'extras'
327
297
  }
328
- },
329
- tailwind: {
330
- config: {
331
- purge: false
332
- }
333
298
  }
334
299
  }
335
300
  })
@@ -347,11 +312,6 @@ test('warns if a template cannot be rendered and `fail` option is undefined', as
347
312
  destination: {
348
313
  path: t.context.folder
349
314
  }
350
- },
351
- tailwind: {
352
- config: {
353
- purge: false
354
- }
355
315
  }
356
316
  }
357
317
  })
@@ -368,11 +328,6 @@ test('warns if a template cannot be rendered and `fail` option is `verbose`', as
368
328
  destination: {
369
329
  path: t.context.folder
370
330
  }
371
- },
372
- tailwind: {
373
- config: {
374
- purge: false
375
- }
376
331
  }
377
332
  }
378
333
  })
@@ -389,11 +344,6 @@ test('warns if a template cannot be rendered and `fail` option is `silent`', asy
389
344
  destination: {
390
345
  path: t.context.folder
391
346
  }
392
- },
393
- tailwind: {
394
- config: {
395
- purge: false
396
- }
397
347
  }
398
348
  }
399
349
  })
@@ -428,12 +378,12 @@ test('local server does not compile unwanted file types', async t => {
428
378
  t.true(await fs.pathExists(`${t.context.folder}/2.test`))
429
379
 
430
380
  // Tests watching changes to files
431
- await fs.outputFile('test/stubs/templates/1.html', 'html\n')
432
- t.is(await fs.readFile('test/stubs/templates/1.html', 'utf8'), 'html\n')
381
+ await fs.outputFile('test/stubs/templates/2.html', '<div class="inline">html modified</div>')
382
+ t.is(await fs.readFile('test/stubs/templates/2.html', 'utf8'), '<div class="inline">html modified</div>')
433
383
 
434
- // Don't trigger rebuilds on files not in filetypes
435
- await fs.outputFile('test/stubs/templates/2.test', 'test\n')
436
- t.is(await fs.readFile('test/stubs/templates/2.test', 'utf8'), 'test\n')
384
+ // Don't trigger rebuilds on files not in `filetypes`
385
+ await fs.outputFile('test/stubs/templates/2.test', 'test')
386
+ t.is(await fs.readFile('test/stubs/templates/2.test', 'utf8'), 'test')
437
387
  })
438
388
 
439
389
  test('throws if it cannot spin up local development server', async t => {
@@ -456,7 +406,7 @@ test('works with templates.source defined as function (string paths)', async t =
456
406
  })
457
407
 
458
408
  t.true(await fs.pathExists(t.context.folder))
459
- t.is(files.length, 2)
409
+ t.is(files.length, 3)
460
410
  })
461
411
 
462
412
  test('works with templates.source defined as function (array paths)', async t => {
@@ -476,7 +426,7 @@ test('works with templates.source defined as function (array paths)', async t =>
476
426
  })
477
427
 
478
428
  t.true(await fs.pathExists(t.context.folder))
479
- t.is(files.length, 2)
429
+ t.is(files.length, 3)
480
430
  })
481
431
 
482
432
  test('throws if templates path is invalid', async t => {
@@ -535,9 +485,9 @@ test('sets config.build.current.path', async t => {
535
485
  path: {
536
486
  root: '',
537
487
  dir: t.context.folder,
538
- base: '1.html',
488
+ base: '2.html',
539
489
  ext: '.html',
540
- name: '1'
490
+ name: '2'
541
491
  }
542
492
  })
543
493
  })
@@ -4,7 +4,7 @@ const Maizzle = require('../src')
4
4
  const renderString = (string, options = {}) => Maizzle.render(string, options).then(({html}) => html)
5
5
 
6
6
  test('uses environment config file(s) if available', async t => {
7
- const source = `<div>{{ page.mail }}</div>`
7
+ const source = `<div class="inline">{{ page.mail }}</div>`
8
8
 
9
9
  const html = await renderString(source, {
10
10
  maizzle: {
@@ -12,7 +12,7 @@ test('uses environment config file(s) if available', async t => {
12
12
  }
13
13
  })
14
14
 
15
- t.is(html, '<div>puzzle</div>')
15
+ t.is(html, '<div class="inline">puzzle</div>')
16
16
  })
17
17
 
18
18
  test('throws if first argument is not an HTML string', async t => {
@@ -28,7 +28,7 @@ test('throws if first argument is an empty string', async t => {
28
28
  })
29
29
 
30
30
  test('runs the `beforeRender` event', async t => {
31
- const html = await renderString(`<div>{{ page.foo }}</div>`, {
31
+ const html = await renderString(`<div class="inline">{{ page.foo }}</div>`, {
32
32
  beforeRender(html, config) {
33
33
  config.foo = 'bar'
34
34
 
@@ -36,11 +36,11 @@ test('runs the `beforeRender` event', async t => {
36
36
  }
37
37
  })
38
38
 
39
- t.is(html, `<div>bar</div>`)
39
+ t.is(html, `<div class="inline">bar</div>`)
40
40
  })
41
41
 
42
42
  test('runs the `afterRender` event', async t => {
43
- const result = await renderString(`<div>foo</div>`, {
43
+ const result = await renderString(`<div class="inline">foo</div>`, {
44
44
  afterRender(html, config) {
45
45
  config.replaceStrings = {
46
46
  foo: 'baz'
@@ -50,11 +50,11 @@ test('runs the `afterRender` event', async t => {
50
50
  }
51
51
  })
52
52
 
53
- t.is(result, `<div>baz</div>`)
53
+ t.is(result, `<div class="inline">baz</div>`)
54
54
  })
55
55
 
56
56
  test('runs the `afterTransformers` event', async t => {
57
- const result = await renderString(`<div>foo</div>`, {
57
+ const result = await renderString(`<div class="inline">foo</div>`, {
58
58
  maizzle: {
59
59
  title: 'bar'
60
60
  },
@@ -63,11 +63,11 @@ test('runs the `afterTransformers` event', async t => {
63
63
  }
64
64
  })
65
65
 
66
- t.is(result, `<div>bar</div>`)
66
+ t.is(result, `<div class="inline">bar</div>`)
67
67
  })
68
68
 
69
69
  test('locals work when defined in all supported places', async t => {
70
- const result = await renderString(`{{ page.one }}, {{ two }}, {{ three }}`, {
70
+ const result = await renderString(`{{ page.one }}, {{ two }}, {{ three }}, {{ inline }}`, {
71
71
  maizzle: {
72
72
  one: 1,
73
73
  build: {
@@ -85,11 +85,11 @@ test('locals work when defined in all supported places', async t => {
85
85
  }
86
86
  })
87
87
 
88
- t.is(result, `1, 2, 3`)
88
+ t.is(result, `1, 2, 3, undefined`)
89
89
  })
90
90
 
91
91
  test('prevents overwriting page object', async t => {
92
- const result = await renderString(`{{ page.one }}, {{ two }}, {{ three }}`, {
92
+ const result = await renderString(`{{ page.one }}, {{ two }}, {{ three }}, {{ inline }}`, {
93
93
  maizzle: {
94
94
  one: 1,
95
95
  build: {
@@ -111,7 +111,7 @@ test('prevents overwriting page object', async t => {
111
111
  }
112
112
  })
113
113
 
114
- t.is(result, `1, undefined, undefined`)
114
+ t.is(result, `1, undefined, undefined, undefined`)
115
115
  })
116
116
 
117
117
  test('preserves css in marked style tags (tailwindcss)', async t => {
@@ -124,6 +124,9 @@ test('preserves css in marked style tags (tailwindcss)', async t => {
124
124
  [data-ogsc] .inexistent {
125
125
  color: #ef4444;
126
126
  }
127
+ [data-ogsc] .ogsc:hidden {
128
+ display: none;
129
+ }
127
130
  div > u + .body .gmail-android-block {
128
131
  display: block !important;
129
132
  }
@@ -144,16 +147,18 @@ test('preserves css in marked style tags (tailwindcss)', async t => {
144
147
  }
145
148
  })
146
149
 
147
- t.true(html.includes('[data-ogsc] .inexistent'))
150
+ t.true(html.includes('[data-ogsc] .ogsc:hidden'))
151
+ t.false(html.includes('[data-ogsc] .inexistent'))
152
+
148
153
  t.true(html.includes('div > u + .body .gmail-android-block'))
149
154
  t.true(html.includes('u + #body a'))
150
155
  })
151
156
 
152
157
  test('@import css files in marked style tags', async t => {
153
- const source = `<style postcss>@import "test/stubs/post.css";</style>`
158
+ const source = `<style class="inline" postcss>@import "test/stubs/post.css";</style>`
154
159
  const html = await renderString(source)
155
160
 
156
- t.is(html, `<style>div {
161
+ t.is(html, `<style class="inline">div {
157
162
  margin: 1px 2px 3px 4px;
158
163
  }</style>`)
159
164
  })