@newlogic-digital/core 0.9.5 → 0.9.8
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/modules/Core.js +2 -1
- package/modules/Emails.js +2 -2
- package/modules/Templates.js +49 -8
- package/modules/Utils.js +15 -0
- package/package.json +3 -2
package/modules/Core.js
CHANGED
package/modules/Emails.js
CHANGED
@@ -20,7 +20,7 @@ export class Emails {
|
|
20
20
|
removeStyleTags: Config.emails.inlineOnly
|
21
21
|
}
|
22
22
|
|
23
|
-
const buildCss = lazypipe().pipe(() => gulpif("*.css", postcss(new Utils().
|
23
|
+
const buildCss = lazypipe().pipe(() => gulpif("*.css", postcss(new Utils().postcssPluginsEmails(Config.emails.postcss, [postcssCustomProperties({
|
24
24
|
preserve: false
|
25
25
|
}), autoprefixer])))
|
26
26
|
).pipe(() => gulpif("*.less", Modules.less.module()))
|
@@ -107,4 +107,4 @@ export class Emails {
|
|
107
107
|
resolve();
|
108
108
|
})
|
109
109
|
}
|
110
|
-
}
|
110
|
+
}
|
package/modules/Templates.js
CHANGED
@@ -8,6 +8,9 @@ import gulp from "gulp";
|
|
8
8
|
import plumber from "gulp-plumber";
|
9
9
|
import minifier from "html-minifier";
|
10
10
|
import through from "through2";
|
11
|
+
import Prism from 'prismjs'
|
12
|
+
import loadLanguages from 'prismjs/components/index.js'
|
13
|
+
import NormalizeWhitespace from 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js'
|
11
14
|
import {Config, Exists, Functions, Modules, root} from "./Core.js";
|
12
15
|
|
13
16
|
export class Templates {
|
@@ -236,16 +239,54 @@ export class Templates {
|
|
236
239
|
type = type.replace(":mirror", "")
|
237
240
|
}
|
238
241
|
|
242
|
+
loadLanguages(['markup', 'css', 'javascript'])
|
243
|
+
|
244
|
+
const Normalize = new NormalizeWhitespace({
|
245
|
+
'remove-trailing': true,
|
246
|
+
'remove-indent': true,
|
247
|
+
'left-trim': true,
|
248
|
+
'right-trim': true,
|
249
|
+
});
|
250
|
+
|
251
|
+
const wrap = (code, lang) => {
|
252
|
+
return `<pre class="language-${lang}"><code>${code}</code></pre>`
|
253
|
+
}
|
254
|
+
|
255
|
+
const highlight = (str, lang) => {
|
256
|
+
if (!lang) {
|
257
|
+
return wrap(str, 'text')
|
258
|
+
}
|
259
|
+
lang = lang.toLowerCase()
|
260
|
+
const rawLang = lang
|
261
|
+
if (lang === 'vue' || lang === 'html') {
|
262
|
+
lang = 'markup'
|
263
|
+
}
|
264
|
+
if (lang === 'md') {
|
265
|
+
lang = 'markdown'
|
266
|
+
}
|
267
|
+
if (lang === 'ts') {
|
268
|
+
lang = 'typescript'
|
269
|
+
}
|
270
|
+
if (lang === 'py') {
|
271
|
+
lang = 'python'
|
272
|
+
}
|
273
|
+
if (!Prism.languages[lang]) {
|
274
|
+
try {
|
275
|
+
loadLanguages([lang])
|
276
|
+
} catch (e) {
|
277
|
+
console.warn(`Syntax highlight for language "${lang}" is not supported.`)
|
278
|
+
}
|
279
|
+
}
|
280
|
+
if (Prism.languages[lang]) {
|
281
|
+
const code = Prism.highlight(Normalize.normalize(str), Prism.languages[lang], lang)
|
282
|
+
return wrap(code, rawLang)
|
283
|
+
}
|
284
|
+
return wrap(str, 'text')
|
285
|
+
}
|
286
|
+
|
239
287
|
return {
|
240
288
|
chain: chain,
|
241
|
-
output: `${mirror ? output : ""}
|
242
|
-
<pre style="width: 100%">
|
243
|
-
<code class="language-${type}">
|
244
|
-
<xmp>
|
245
|
-
${output}
|
246
|
-
</xmp>
|
247
|
-
</code>
|
248
|
-
</pre>`
|
289
|
+
output: `${mirror ? output : ""}${highlight(output, type)}`
|
249
290
|
};
|
250
291
|
}
|
251
292
|
});
|
package/modules/Utils.js
CHANGED
@@ -279,6 +279,21 @@ export class Utils {
|
|
279
279
|
return config;
|
280
280
|
}
|
281
281
|
|
282
|
+
return plugins.concat(after);
|
283
|
+
}
|
284
|
+
postcssPluginsEmails(config, after) {
|
285
|
+
let plugins = [postcssImport, postcssNesting({
|
286
|
+
noIsPseudoSelector: true
|
287
|
+
}), postcssCustomMedia, postcssCustomSelectors];
|
288
|
+
|
289
|
+
if (Exists.postcssConfig) {
|
290
|
+
return {config: root}
|
291
|
+
} else if (typeof config.extend !== "undefined") {
|
292
|
+
plugins = plugins.concat(config.extend)
|
293
|
+
} else if (Array.isArray(config) && config.length !== 0) {
|
294
|
+
return config;
|
295
|
+
}
|
296
|
+
|
282
297
|
return plugins.concat(after);
|
283
298
|
}
|
284
299
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.9.
|
4
|
+
"version": "0.9.8",
|
5
5
|
"main": "index.js",
|
6
6
|
"author": "New Logic Studio s.r.o.",
|
7
7
|
"description": "Set of tools that can be used to create modern web applications",
|
@@ -47,7 +47,8 @@
|
|
47
47
|
"rollup": "^2.66.1",
|
48
48
|
"rollup-plugin-import-map": "^2.2.2",
|
49
49
|
"rollup-plugin-terser": "^7.0.2",
|
50
|
-
"vite": "~2.7.13"
|
50
|
+
"vite": "~2.7.13",
|
51
|
+
"prismjs": "^1.26.0"
|
51
52
|
},
|
52
53
|
"peerDependencies": {
|
53
54
|
"autoprefixer": "^10.4.2",
|