sommark 4.5.1 → 4.5.3
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/constants/html_props.js +66 -1
- package/constants/svg_elements.js +31 -0
- package/core/helpers/lib.js +1 -1
- package/core/transpiler.js +11 -2
- package/dist/sommark.browser.js +121 -11
- package/dist/sommark.browser.lite.js +120 -10
- package/mappers/languages/html.js +13 -7
- package/package.json +1 -1
package/constants/html_props.js
CHANGED
|
@@ -97,5 +97,70 @@ export const HTML_PROPS = new Set([
|
|
|
97
97
|
"referrerpolicy",
|
|
98
98
|
"sizes",
|
|
99
99
|
"srcset",
|
|
100
|
-
"virtualkeyboardpolicy"
|
|
100
|
+
"virtualkeyboardpolicy",
|
|
101
|
+
|
|
102
|
+
// Links & navigation
|
|
103
|
+
"hreflang",
|
|
104
|
+
"ping",
|
|
105
|
+
"accept-charset",
|
|
106
|
+
|
|
107
|
+
// Forms
|
|
108
|
+
"accept",
|
|
109
|
+
"novalidate",
|
|
110
|
+
"dirname",
|
|
111
|
+
|
|
112
|
+
// Tables
|
|
113
|
+
"colspan",
|
|
114
|
+
"rowspan",
|
|
115
|
+
"scope",
|
|
116
|
+
"headers",
|
|
117
|
+
"span",
|
|
118
|
+
|
|
119
|
+
// Lists
|
|
120
|
+
"reversed",
|
|
121
|
+
"start",
|
|
122
|
+
|
|
123
|
+
// Interactive / structural
|
|
124
|
+
"open",
|
|
125
|
+
"size",
|
|
126
|
+
"cite",
|
|
127
|
+
"datetime",
|
|
128
|
+
|
|
129
|
+
// Media & track
|
|
130
|
+
"default",
|
|
131
|
+
"kind",
|
|
132
|
+
"label",
|
|
133
|
+
"srcdoc",
|
|
134
|
+
"srclang",
|
|
135
|
+
|
|
136
|
+
// Images
|
|
137
|
+
"ismap",
|
|
138
|
+
"usemap",
|
|
139
|
+
|
|
140
|
+
// Resource hints
|
|
141
|
+
"as",
|
|
142
|
+
"fetchpriority",
|
|
143
|
+
|
|
144
|
+
// Meta
|
|
145
|
+
"http-equiv",
|
|
146
|
+
|
|
147
|
+
// Meter
|
|
148
|
+
"high",
|
|
149
|
+
"low",
|
|
150
|
+
"optimum",
|
|
151
|
+
|
|
152
|
+
// Deprecated (still valid)
|
|
153
|
+
"align",
|
|
154
|
+
"bgcolor",
|
|
155
|
+
"border",
|
|
156
|
+
"color",
|
|
157
|
+
"coords",
|
|
158
|
+
"shape",
|
|
159
|
+
"summary",
|
|
160
|
+
|
|
161
|
+
// Experimental
|
|
162
|
+
"elementtiming",
|
|
163
|
+
"colorspace",
|
|
164
|
+
"alpha",
|
|
165
|
+
"csp",
|
|
101
166
|
]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const SVG_ELEMENTS = new Set([
|
|
2
|
+
// Basic shapes
|
|
3
|
+
"circle", "ellipse", "line", "path", "polygon", "polyline", "rect",
|
|
4
|
+
// Containers
|
|
5
|
+
"svg", "g", "defs", "symbol", "use", "marker", "mask", "pattern", "switch",
|
|
6
|
+
// Text
|
|
7
|
+
"text", "tspan", "textpath", "tref",
|
|
8
|
+
// Image
|
|
9
|
+
"image",
|
|
10
|
+
// Gradients
|
|
11
|
+
"lineargradient", "radialgradient", "stop", "solidcolor",
|
|
12
|
+
"meshgradient", "meshrow", "meshpatch",
|
|
13
|
+
// Hatch (SVG 2)
|
|
14
|
+
"hatch", "hatchpath",
|
|
15
|
+
// Filter container
|
|
16
|
+
"filter",
|
|
17
|
+
// Filter primitives
|
|
18
|
+
"feblend", "fecolormatrix", "fecomponenttransfer", "fecomposite",
|
|
19
|
+
"feconvolvematrix", "fediffuselighting", "fedisplacementmap", "fedropshadow",
|
|
20
|
+
"feflood", "fefunca", "fefuncb", "fefuncg", "fefuncr",
|
|
21
|
+
"fegaussianblur", "feimage", "femerge", "femergenode",
|
|
22
|
+
"femorphology", "feoffset", "fespecularlighting", "fetile", "feturbulence",
|
|
23
|
+
// Light sources
|
|
24
|
+
"fedistantlight", "fepointlight", "fespotlight",
|
|
25
|
+
// Animation
|
|
26
|
+
"animate", "animatemotion", "animatetransform", "set", "mpath", "discard",
|
|
27
|
+
// Descriptive
|
|
28
|
+
"desc", "title", "metadata",
|
|
29
|
+
// Other
|
|
30
|
+
"clippath", "foreignobject", "view", "cursor",
|
|
31
|
+
]);
|
package/core/helpers/lib.js
CHANGED
package/core/transpiler.js
CHANGED
|
@@ -5,6 +5,7 @@ import { matchedValue } from "../helpers/utils.js";
|
|
|
5
5
|
import { dedentBy } from "../helpers/dedent.js";
|
|
6
6
|
import { preprocessRuntimeLogic } from "./helpers/preprocessor.js";
|
|
7
7
|
import { wrapRuntimeLogic } from "./helpers/runtimeOutput.js";
|
|
8
|
+
import path from "pathe";
|
|
8
9
|
|
|
9
10
|
const randomBytesHex = (size) => {
|
|
10
11
|
const arr = new Uint8Array(size);
|
|
@@ -493,6 +494,14 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
493
494
|
settings.fs = instance.fs;
|
|
494
495
|
}
|
|
495
496
|
|
|
497
|
+
const fileBaseDir = (() => {
|
|
498
|
+
const filename = instance?.filename;
|
|
499
|
+
const cwd = instance?.cwd || "/";
|
|
500
|
+
if (!filename || filename === "anonymous") return cwd;
|
|
501
|
+
const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : path.resolve(cwd, filename);
|
|
502
|
+
return path.dirname(abs);
|
|
503
|
+
})();
|
|
504
|
+
|
|
496
505
|
const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
|
|
497
506
|
const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
|
|
498
507
|
const dualOutput = optionsOrAst?.dualOutput || false;
|
|
@@ -519,7 +528,7 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
519
528
|
}
|
|
520
529
|
|
|
521
530
|
// Initialize Logic Sandbox
|
|
522
|
-
await evaluator.init(
|
|
531
|
+
await evaluator.init(fileBaseDir, security, settings, targetMapper);
|
|
523
532
|
// Inject global data
|
|
524
533
|
const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
|
|
525
534
|
const variables = optionsOrAst?.variables || settings?.variables || {};
|
|
@@ -561,7 +570,7 @@ export async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
561
570
|
idState.idx = 0;
|
|
562
571
|
prev_was_silent = false;
|
|
563
572
|
|
|
564
|
-
await evaluator.init(
|
|
573
|
+
await evaluator.init(fileBaseDir, security, settings, targetMapper);
|
|
565
574
|
evaluator.inject(placeholders);
|
|
566
575
|
evaluator.inject(variables);
|
|
567
576
|
|
package/dist/sommark.browser.js
CHANGED
|
@@ -9184,7 +9184,7 @@ function registerHostSettings(settings) {
|
|
|
9184
9184
|
hostSettings = settings || {};
|
|
9185
9185
|
}
|
|
9186
9186
|
|
|
9187
|
-
const version = "4.5.
|
|
9187
|
+
const version = "4.5.3";
|
|
9188
9188
|
|
|
9189
9189
|
const SomMark$1 = {
|
|
9190
9190
|
version,
|
|
@@ -11024,6 +11024,14 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
11024
11024
|
settings.fs = instance.fs;
|
|
11025
11025
|
}
|
|
11026
11026
|
|
|
11027
|
+
const fileBaseDir = (() => {
|
|
11028
|
+
const filename = instance?.filename;
|
|
11029
|
+
const cwd = instance?.cwd || "/";
|
|
11030
|
+
if (!filename || filename === "anonymous") return cwd;
|
|
11031
|
+
const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : posix.resolve(cwd, filename);
|
|
11032
|
+
return posix.dirname(abs);
|
|
11033
|
+
})();
|
|
11034
|
+
|
|
11027
11035
|
const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
|
|
11028
11036
|
const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
|
|
11029
11037
|
const dualOutput = optionsOrAst?.dualOutput || false;
|
|
@@ -11050,7 +11058,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
11050
11058
|
}
|
|
11051
11059
|
|
|
11052
11060
|
// Initialize Logic Sandbox
|
|
11053
|
-
await Evaluator$1.init(
|
|
11061
|
+
await Evaluator$1.init(fileBaseDir, security, settings, targetMapper);
|
|
11054
11062
|
// Inject global data
|
|
11055
11063
|
const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
|
|
11056
11064
|
const variables = optionsOrAst?.variables || settings?.variables || {};
|
|
@@ -11092,7 +11100,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
11092
11100
|
idState.idx = 0;
|
|
11093
11101
|
prev_was_silent = false;
|
|
11094
11102
|
|
|
11095
|
-
await Evaluator$1.init(
|
|
11103
|
+
await Evaluator$1.init(fileBaseDir, security, settings, targetMapper);
|
|
11096
11104
|
Evaluator$1.inject(placeholders);
|
|
11097
11105
|
Evaluator$1.inject(variables);
|
|
11098
11106
|
|
|
@@ -11312,7 +11320,72 @@ const HTML_PROPS = new Set([
|
|
|
11312
11320
|
"referrerpolicy",
|
|
11313
11321
|
"sizes",
|
|
11314
11322
|
"srcset",
|
|
11315
|
-
"virtualkeyboardpolicy"
|
|
11323
|
+
"virtualkeyboardpolicy",
|
|
11324
|
+
|
|
11325
|
+
// Links & navigation
|
|
11326
|
+
"hreflang",
|
|
11327
|
+
"ping",
|
|
11328
|
+
"accept-charset",
|
|
11329
|
+
|
|
11330
|
+
// Forms
|
|
11331
|
+
"accept",
|
|
11332
|
+
"novalidate",
|
|
11333
|
+
"dirname",
|
|
11334
|
+
|
|
11335
|
+
// Tables
|
|
11336
|
+
"colspan",
|
|
11337
|
+
"rowspan",
|
|
11338
|
+
"scope",
|
|
11339
|
+
"headers",
|
|
11340
|
+
"span",
|
|
11341
|
+
|
|
11342
|
+
// Lists
|
|
11343
|
+
"reversed",
|
|
11344
|
+
"start",
|
|
11345
|
+
|
|
11346
|
+
// Interactive / structural
|
|
11347
|
+
"open",
|
|
11348
|
+
"size",
|
|
11349
|
+
"cite",
|
|
11350
|
+
"datetime",
|
|
11351
|
+
|
|
11352
|
+
// Media & track
|
|
11353
|
+
"default",
|
|
11354
|
+
"kind",
|
|
11355
|
+
"label",
|
|
11356
|
+
"srcdoc",
|
|
11357
|
+
"srclang",
|
|
11358
|
+
|
|
11359
|
+
// Images
|
|
11360
|
+
"ismap",
|
|
11361
|
+
"usemap",
|
|
11362
|
+
|
|
11363
|
+
// Resource hints
|
|
11364
|
+
"as",
|
|
11365
|
+
"fetchpriority",
|
|
11366
|
+
|
|
11367
|
+
// Meta
|
|
11368
|
+
"http-equiv",
|
|
11369
|
+
|
|
11370
|
+
// Meter
|
|
11371
|
+
"high",
|
|
11372
|
+
"low",
|
|
11373
|
+
"optimum",
|
|
11374
|
+
|
|
11375
|
+
// Deprecated (still valid)
|
|
11376
|
+
"align",
|
|
11377
|
+
"bgcolor",
|
|
11378
|
+
"border",
|
|
11379
|
+
"color",
|
|
11380
|
+
"coords",
|
|
11381
|
+
"shape",
|
|
11382
|
+
"summary",
|
|
11383
|
+
|
|
11384
|
+
// Experimental
|
|
11385
|
+
"elementtiming",
|
|
11386
|
+
"colorspace",
|
|
11387
|
+
"alpha",
|
|
11388
|
+
"csp",
|
|
11316
11389
|
]);
|
|
11317
11390
|
|
|
11318
11391
|
const VOID_ELEMENTS = new Set([
|
|
@@ -12260,6 +12333,38 @@ function registerSharedOutputs(mapper) {
|
|
|
12260
12333
|
|
|
12261
12334
|
}
|
|
12262
12335
|
|
|
12336
|
+
const SVG_ELEMENTS = new Set([
|
|
12337
|
+
// Basic shapes
|
|
12338
|
+
"circle", "ellipse", "line", "path", "polygon", "polyline", "rect",
|
|
12339
|
+
// Containers
|
|
12340
|
+
"svg", "g", "defs", "symbol", "use", "marker", "mask", "pattern", "switch",
|
|
12341
|
+
// Text
|
|
12342
|
+
"text", "tspan", "textpath", "tref",
|
|
12343
|
+
// Image
|
|
12344
|
+
"image",
|
|
12345
|
+
// Gradients
|
|
12346
|
+
"lineargradient", "radialgradient", "stop", "solidcolor",
|
|
12347
|
+
"meshgradient", "meshrow", "meshpatch",
|
|
12348
|
+
// Hatch (SVG 2)
|
|
12349
|
+
"hatch", "hatchpath",
|
|
12350
|
+
// Filter container
|
|
12351
|
+
"filter",
|
|
12352
|
+
// Filter primitives
|
|
12353
|
+
"feblend", "fecolormatrix", "fecomponenttransfer", "fecomposite",
|
|
12354
|
+
"feconvolvematrix", "fediffuselighting", "fedisplacementmap", "fedropshadow",
|
|
12355
|
+
"feflood", "fefunca", "fefuncb", "fefuncg", "fefuncr",
|
|
12356
|
+
"fegaussianblur", "feimage", "femerge", "femergenode",
|
|
12357
|
+
"femorphology", "feoffset", "fespecularlighting", "fetile", "feturbulence",
|
|
12358
|
+
// Light sources
|
|
12359
|
+
"fedistantlight", "fepointlight", "fespotlight",
|
|
12360
|
+
// Animation
|
|
12361
|
+
"animate", "animatemotion", "animatetransform", "set", "mpath", "discard",
|
|
12362
|
+
// Descriptive
|
|
12363
|
+
"desc", "title", "metadata",
|
|
12364
|
+
// Other
|
|
12365
|
+
"clippath", "foreignobject", "view", "cursor",
|
|
12366
|
+
]);
|
|
12367
|
+
|
|
12263
12368
|
/**
|
|
12264
12369
|
* Helper to format an HTML tag with attributes and content.
|
|
12265
12370
|
*
|
|
@@ -12270,15 +12375,20 @@ function registerSharedOutputs(mapper) {
|
|
|
12270
12375
|
*/
|
|
12271
12376
|
const renderHtmlTag = function (id, args, content, isSelfClosing) {
|
|
12272
12377
|
const element = this.tag(id);
|
|
12378
|
+
const idLower = id.toLowerCase();
|
|
12273
12379
|
|
|
12274
|
-
|
|
12380
|
+
if (SVG_ELEMENTS.has(idLower)) {
|
|
12381
|
+
element.attributes(args);
|
|
12382
|
+
} else {
|
|
12383
|
+
element.smartAttributes(args, this.customProps, this.options);
|
|
12384
|
+
}
|
|
12275
12385
|
|
|
12276
12386
|
let finalContent = content;
|
|
12277
|
-
if (
|
|
12387
|
+
if (idLower === "script" && args.scoped === true) {
|
|
12278
12388
|
finalContent = `(function(){\n${content}\n})();`;
|
|
12279
12389
|
}
|
|
12280
12390
|
|
|
12281
|
-
if (VOID_ELEMENTS.has(
|
|
12391
|
+
if (VOID_ELEMENTS.has(idLower) || isSelfClosing) {
|
|
12282
12392
|
return element.selfClose();
|
|
12283
12393
|
}
|
|
12284
12394
|
|
|
@@ -12349,12 +12459,12 @@ const HTML = Mapper.define({
|
|
|
12349
12459
|
* @returns {Object} - A virtual id registration for fallback rendering.
|
|
12350
12460
|
*/
|
|
12351
12461
|
getUnknownTag(node) {
|
|
12352
|
-
const
|
|
12353
|
-
const isVoid = VOID_ELEMENTS.has(
|
|
12354
|
-
const isCodeStyleOrScript = ["code", "style", "script"].includes(
|
|
12462
|
+
const idLower = node.id.toLowerCase();
|
|
12463
|
+
const isVoid = VOID_ELEMENTS.has(idLower);
|
|
12464
|
+
const isCodeStyleOrScript = ["code", "style", "script"].includes(idLower);
|
|
12355
12465
|
|
|
12356
12466
|
return {
|
|
12357
|
-
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, id, args, content, isSelfClosing); },
|
|
12467
|
+
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, node.id, args, content, isSelfClosing); },
|
|
12358
12468
|
options: {
|
|
12359
12469
|
type: isCodeStyleOrScript ? ["Block", "AtBlock"] : ["Block", "Inline"],
|
|
12360
12470
|
escape: !isCodeStyleOrScript,
|
|
@@ -9932,6 +9932,14 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
9932
9932
|
settings.fs = instance.fs;
|
|
9933
9933
|
}
|
|
9934
9934
|
|
|
9935
|
+
const fileBaseDir = (() => {
|
|
9936
|
+
const filename = instance?.filename;
|
|
9937
|
+
const cwd = instance?.cwd || "/";
|
|
9938
|
+
if (!filename || filename === "anonymous") return cwd;
|
|
9939
|
+
const abs = /^(\/|[a-zA-Z]:\\|https?:\/\/)/.test(filename) ? filename : posix.resolve(cwd, filename);
|
|
9940
|
+
return posix.dirname(abs);
|
|
9941
|
+
})();
|
|
9942
|
+
|
|
9935
9943
|
const generateRuntimeOutput = optionsOrAst?.generateRuntimeOutput || false;
|
|
9936
9944
|
const hideRuntimeOutput = optionsOrAst?.hideRuntimeOutput || false;
|
|
9937
9945
|
const dualOutput = optionsOrAst?.dualOutput || false;
|
|
@@ -9958,7 +9966,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
9958
9966
|
}
|
|
9959
9967
|
|
|
9960
9968
|
// Initialize Logic Sandbox
|
|
9961
|
-
await Evaluator.init(
|
|
9969
|
+
await Evaluator.init(fileBaseDir, security, settings, targetMapper);
|
|
9962
9970
|
// Inject global data
|
|
9963
9971
|
const placeholders = optionsOrAst?.placeholders || settings?.placeholders || {};
|
|
9964
9972
|
const variables = optionsOrAst?.variables || settings?.variables || {};
|
|
@@ -10000,7 +10008,7 @@ async function transpiler(optionsOrAst, format, mapperFile) {
|
|
|
10000
10008
|
idState.idx = 0;
|
|
10001
10009
|
prev_was_silent = false;
|
|
10002
10010
|
|
|
10003
|
-
await Evaluator.init(
|
|
10011
|
+
await Evaluator.init(fileBaseDir, security, settings, targetMapper);
|
|
10004
10012
|
Evaluator.inject(placeholders);
|
|
10005
10013
|
Evaluator.inject(variables);
|
|
10006
10014
|
|
|
@@ -10220,7 +10228,72 @@ const HTML_PROPS = new Set([
|
|
|
10220
10228
|
"referrerpolicy",
|
|
10221
10229
|
"sizes",
|
|
10222
10230
|
"srcset",
|
|
10223
|
-
"virtualkeyboardpolicy"
|
|
10231
|
+
"virtualkeyboardpolicy",
|
|
10232
|
+
|
|
10233
|
+
// Links & navigation
|
|
10234
|
+
"hreflang",
|
|
10235
|
+
"ping",
|
|
10236
|
+
"accept-charset",
|
|
10237
|
+
|
|
10238
|
+
// Forms
|
|
10239
|
+
"accept",
|
|
10240
|
+
"novalidate",
|
|
10241
|
+
"dirname",
|
|
10242
|
+
|
|
10243
|
+
// Tables
|
|
10244
|
+
"colspan",
|
|
10245
|
+
"rowspan",
|
|
10246
|
+
"scope",
|
|
10247
|
+
"headers",
|
|
10248
|
+
"span",
|
|
10249
|
+
|
|
10250
|
+
// Lists
|
|
10251
|
+
"reversed",
|
|
10252
|
+
"start",
|
|
10253
|
+
|
|
10254
|
+
// Interactive / structural
|
|
10255
|
+
"open",
|
|
10256
|
+
"size",
|
|
10257
|
+
"cite",
|
|
10258
|
+
"datetime",
|
|
10259
|
+
|
|
10260
|
+
// Media & track
|
|
10261
|
+
"default",
|
|
10262
|
+
"kind",
|
|
10263
|
+
"label",
|
|
10264
|
+
"srcdoc",
|
|
10265
|
+
"srclang",
|
|
10266
|
+
|
|
10267
|
+
// Images
|
|
10268
|
+
"ismap",
|
|
10269
|
+
"usemap",
|
|
10270
|
+
|
|
10271
|
+
// Resource hints
|
|
10272
|
+
"as",
|
|
10273
|
+
"fetchpriority",
|
|
10274
|
+
|
|
10275
|
+
// Meta
|
|
10276
|
+
"http-equiv",
|
|
10277
|
+
|
|
10278
|
+
// Meter
|
|
10279
|
+
"high",
|
|
10280
|
+
"low",
|
|
10281
|
+
"optimum",
|
|
10282
|
+
|
|
10283
|
+
// Deprecated (still valid)
|
|
10284
|
+
"align",
|
|
10285
|
+
"bgcolor",
|
|
10286
|
+
"border",
|
|
10287
|
+
"color",
|
|
10288
|
+
"coords",
|
|
10289
|
+
"shape",
|
|
10290
|
+
"summary",
|
|
10291
|
+
|
|
10292
|
+
// Experimental
|
|
10293
|
+
"elementtiming",
|
|
10294
|
+
"colorspace",
|
|
10295
|
+
"alpha",
|
|
10296
|
+
"csp",
|
|
10224
10297
|
]);
|
|
10225
10298
|
|
|
10226
10299
|
const VOID_ELEMENTS = new Set([
|
|
@@ -11168,6 +11241,38 @@ function registerSharedOutputs(mapper) {
|
|
|
11168
11241
|
|
|
11169
11242
|
}
|
|
11170
11243
|
|
|
11244
|
+
const SVG_ELEMENTS = new Set([
|
|
11245
|
+
// Basic shapes
|
|
11246
|
+
"circle", "ellipse", "line", "path", "polygon", "polyline", "rect",
|
|
11247
|
+
// Containers
|
|
11248
|
+
"svg", "g", "defs", "symbol", "use", "marker", "mask", "pattern", "switch",
|
|
11249
|
+
// Text
|
|
11250
|
+
"text", "tspan", "textpath", "tref",
|
|
11251
|
+
// Image
|
|
11252
|
+
"image",
|
|
11253
|
+
// Gradients
|
|
11254
|
+
"lineargradient", "radialgradient", "stop", "solidcolor",
|
|
11255
|
+
"meshgradient", "meshrow", "meshpatch",
|
|
11256
|
+
// Hatch (SVG 2)
|
|
11257
|
+
"hatch", "hatchpath",
|
|
11258
|
+
// Filter container
|
|
11259
|
+
"filter",
|
|
11260
|
+
// Filter primitives
|
|
11261
|
+
"feblend", "fecolormatrix", "fecomponenttransfer", "fecomposite",
|
|
11262
|
+
"feconvolvematrix", "fediffuselighting", "fedisplacementmap", "fedropshadow",
|
|
11263
|
+
"feflood", "fefunca", "fefuncb", "fefuncg", "fefuncr",
|
|
11264
|
+
"fegaussianblur", "feimage", "femerge", "femergenode",
|
|
11265
|
+
"femorphology", "feoffset", "fespecularlighting", "fetile", "feturbulence",
|
|
11266
|
+
// Light sources
|
|
11267
|
+
"fedistantlight", "fepointlight", "fespotlight",
|
|
11268
|
+
// Animation
|
|
11269
|
+
"animate", "animatemotion", "animatetransform", "set", "mpath", "discard",
|
|
11270
|
+
// Descriptive
|
|
11271
|
+
"desc", "title", "metadata",
|
|
11272
|
+
// Other
|
|
11273
|
+
"clippath", "foreignobject", "view", "cursor",
|
|
11274
|
+
]);
|
|
11275
|
+
|
|
11171
11276
|
/**
|
|
11172
11277
|
* Helper to format an HTML tag with attributes and content.
|
|
11173
11278
|
*
|
|
@@ -11178,15 +11283,20 @@ function registerSharedOutputs(mapper) {
|
|
|
11178
11283
|
*/
|
|
11179
11284
|
const renderHtmlTag = function (id, args, content, isSelfClosing) {
|
|
11180
11285
|
const element = this.tag(id);
|
|
11286
|
+
const idLower = id.toLowerCase();
|
|
11181
11287
|
|
|
11182
|
-
|
|
11288
|
+
if (SVG_ELEMENTS.has(idLower)) {
|
|
11289
|
+
element.attributes(args);
|
|
11290
|
+
} else {
|
|
11291
|
+
element.smartAttributes(args, this.customProps, this.options);
|
|
11292
|
+
}
|
|
11183
11293
|
|
|
11184
11294
|
let finalContent = content;
|
|
11185
|
-
if (
|
|
11295
|
+
if (idLower === "script" && args.scoped === true) {
|
|
11186
11296
|
finalContent = `(function(){\n${content}\n})();`;
|
|
11187
11297
|
}
|
|
11188
11298
|
|
|
11189
|
-
if (VOID_ELEMENTS.has(
|
|
11299
|
+
if (VOID_ELEMENTS.has(idLower) || isSelfClosing) {
|
|
11190
11300
|
return element.selfClose();
|
|
11191
11301
|
}
|
|
11192
11302
|
|
|
@@ -11257,12 +11367,12 @@ const HTML = Mapper.define({
|
|
|
11257
11367
|
* @returns {Object} - A virtual id registration for fallback rendering.
|
|
11258
11368
|
*/
|
|
11259
11369
|
getUnknownTag(node) {
|
|
11260
|
-
const
|
|
11261
|
-
const isVoid = VOID_ELEMENTS.has(
|
|
11262
|
-
const isCodeStyleOrScript = ["code", "style", "script"].includes(
|
|
11370
|
+
const idLower = node.id.toLowerCase();
|
|
11371
|
+
const isVoid = VOID_ELEMENTS.has(idLower);
|
|
11372
|
+
const isCodeStyleOrScript = ["code", "style", "script"].includes(idLower);
|
|
11263
11373
|
|
|
11264
11374
|
return {
|
|
11265
|
-
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, id, args, content, isSelfClosing); },
|
|
11375
|
+
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, node.id, args, content, isSelfClosing); },
|
|
11266
11376
|
options: {
|
|
11267
11377
|
type: isCodeStyleOrScript ? ["Block", "AtBlock"] : ["Block", "Inline"],
|
|
11268
11378
|
escape: !isCodeStyleOrScript,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Mapper from "../mapper.js";
|
|
2
2
|
import { VOID_ELEMENTS } from "../../constants/void_elements.js";
|
|
3
|
+
import { SVG_ELEMENTS } from "../../constants/svg_elements.js";
|
|
3
4
|
import { registerSharedOutputs } from "../shared/index.js";
|
|
4
5
|
import kebabize from "../../helpers/kebabize.js";
|
|
5
6
|
|
|
@@ -13,15 +14,20 @@ import kebabize from "../../helpers/kebabize.js";
|
|
|
13
14
|
*/
|
|
14
15
|
const renderHtmlTag = function (id, args, content, isSelfClosing) {
|
|
15
16
|
const element = this.tag(id);
|
|
17
|
+
const idLower = id.toLowerCase();
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
if (SVG_ELEMENTS.has(idLower)) {
|
|
20
|
+
element.attributes(args);
|
|
21
|
+
} else {
|
|
22
|
+
element.smartAttributes(args, this.customProps, this.options);
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
let finalContent = content;
|
|
20
|
-
if (
|
|
26
|
+
if (idLower === "script" && args.scoped === true) {
|
|
21
27
|
finalContent = `(function(){\n${content}\n})();`;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
if (VOID_ELEMENTS.has(
|
|
30
|
+
if (VOID_ELEMENTS.has(idLower) || isSelfClosing) {
|
|
25
31
|
return element.selfClose();
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -92,12 +98,12 @@ const HTML = Mapper.define({
|
|
|
92
98
|
* @returns {Object} - A virtual id registration for fallback rendering.
|
|
93
99
|
*/
|
|
94
100
|
getUnknownTag(node) {
|
|
95
|
-
const
|
|
96
|
-
const isVoid = VOID_ELEMENTS.has(
|
|
97
|
-
const isCodeStyleOrScript = ["code", "style", "script"].includes(
|
|
101
|
+
const idLower = node.id.toLowerCase();
|
|
102
|
+
const isVoid = VOID_ELEMENTS.has(idLower);
|
|
103
|
+
const isCodeStyleOrScript = ["code", "style", "script"].includes(idLower);
|
|
98
104
|
|
|
99
105
|
return {
|
|
100
|
-
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, id, args, content, isSelfClosing); },
|
|
106
|
+
render: function ({ args, content, isSelfClosing }) { return renderHtmlTag.call(this, node.id, args, content, isSelfClosing); },
|
|
101
107
|
options: {
|
|
102
108
|
type: isCodeStyleOrScript ? ["Block", "AtBlock"] : ["Block", "Inline"],
|
|
103
109
|
escape: !isCodeStyleOrScript,
|
package/package.json
CHANGED