malinajs 0.7.16 → 0.7.17
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/malina.js +21 -4
- package/package.json +1 -1
package/malina.js
CHANGED
|
@@ -972,7 +972,21 @@
|
|
|
972
972
|
function parseHTML(source) {
|
|
973
973
|
const reader = new Reader(source);
|
|
974
974
|
|
|
975
|
-
const readScript = (reader) => {
|
|
975
|
+
const readScript = (reader, tag) => {
|
|
976
|
+
tag.type = 'script';
|
|
977
|
+
|
|
978
|
+
let isJS = true;
|
|
979
|
+
for (let a of tag.attributes) {
|
|
980
|
+
if (a.name == 'lang' || a.name == 'language' || a.name == 'type') {
|
|
981
|
+
isJS = a.value.indexOf('javascript') >= 0 || a.value.indexOf('ecmascript') >= 0;
|
|
982
|
+
tag.lang = a.value;
|
|
983
|
+
break;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
tag.content = isJS ? readScriptJS(reader) : readScriptRaw();
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
const readScriptJS = (reader) => {
|
|
976
990
|
class ScriptParser extends acorn__default["default"].Parser {
|
|
977
991
|
readToken_lt_gt(code) {
|
|
978
992
|
if (this.input.slice(this.pos, this.pos + 9) == '</script>') {
|
|
@@ -997,6 +1011,10 @@
|
|
|
997
1011
|
return reader.sub(start, end);
|
|
998
1012
|
};
|
|
999
1013
|
|
|
1014
|
+
const readScriptRaw = () => {
|
|
1015
|
+
return reader.read(/^(.*?)<\/script>/s);
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1000
1018
|
const readStyle = () => {
|
|
1001
1019
|
return reader.read(/^(.*?)<\/style>/s);
|
|
1002
1020
|
};
|
|
@@ -1054,8 +1072,7 @@
|
|
|
1054
1072
|
let tag = readTag(reader);
|
|
1055
1073
|
push(tag);
|
|
1056
1074
|
if(tag.name === 'script') {
|
|
1057
|
-
tag
|
|
1058
|
-
tag.content = readScript(reader);
|
|
1075
|
+
readScript(reader, tag);
|
|
1059
1076
|
continue;
|
|
1060
1077
|
} else if(tag.name === 'template') {
|
|
1061
1078
|
tag.type = 'template';
|
|
@@ -6887,7 +6904,7 @@
|
|
|
6887
6904
|
});
|
|
6888
6905
|
}
|
|
6889
6906
|
|
|
6890
|
-
const version = '0.7.
|
|
6907
|
+
const version = '0.7.17';
|
|
6891
6908
|
|
|
6892
6909
|
|
|
6893
6910
|
async function compile(source, config = {}) {
|