Files
YelayMaths/Parser/trees/cssHandler.wxs
T
2026-01-05 18:08:52 +08:00

32 lines
1.1 KiB
XML

// Parser/trees/cssHandler.wxs
module.exports = {
getStyle: function(style, display) {
var res = "";
var reg = getRegExp("float\s*:\s*[^;]*", "i");
if (reg.test(style)) res += reg.exec(style)[0];
reg = getRegExp("margin[^;]*auto", "i");
if (reg.test(style)) res += (";" + reg.exec(style)[0]);
reg = getRegExp("display\s*:\s*([^;]*)", "i");
if (reg.test(style) && reg.exec(style)[1]!="flex") res += (';' + reg.exec(style)[0]);
else res += (';display:' + display);
reg = getRegExp("[^;\s]*width\s*:\s*[^;]*", "ig");
var width = reg.exec(style);
while (width) {
res += (';' + width[0]);
width = reg.exec(style);
}
return res;
},
setImgStyle: function(item, imgMode) {
if (getRegExp("[^-]width\s*:\s*[^;]*", "i").test(';' + item.attrs.style))
item.attrs.style += ';width:100%';
if (imgMode == "widthFix")
item.attrs.style += ";height:auto !important";
return [item];
},
setStyle: function(item) {
if (getRegExp("[^-]width\s*:\s*[^;]*", "i").test(';' + item.attrs.style))
item.attrs.style += ';width:100%';
return [item];
}
}