🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

prettier-plugin-marko

Package Overview
Dependencies
Maintainers
7
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-marko - npm Package Compare versions

Comparing version
4.0.9
to
4.0.10
+109
-114
dist/index.js

@@ -39,8 +39,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });

}({});
let CommentType = /* @__PURE__ */ function(CommentType) {
CommentType[CommentType["line"] = 0] = "line";
CommentType[CommentType["block"] = 1] = "block";
CommentType[CommentType["html"] = 2] = "html";
return CommentType;
}({});
function parse(code, filename = "index.marko") {

@@ -70,3 +64,3 @@ const builder = new Builder(code);

this.program = this.#parentNode = {
type: NodeType.Program,
type: 0,
parent: void 0,

@@ -80,3 +74,3 @@ body: [],

pushBody(this.#parentNode, {
type: NodeType.Text,
type: 17,
parent: this.#parentNode,

@@ -89,3 +83,3 @@ start: range.start,

pushBody(this.#parentNode, {
type: NodeType.CDATA,
type: 18,
parent: this.#parentNode,

@@ -99,3 +93,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Doctype,
type: 19,
parent: this.#parentNode,

@@ -109,3 +103,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Declaration,
type: 20,
parent: this.#parentNode,

@@ -118,13 +112,13 @@ value: range.value,

onComment(range) {
let commentType = CommentType.html;
let commentType = 2;
switch (this.#code.charCodeAt(range.start + 1)) {
case 47:
commentType = CommentType.line;
commentType = 0;
break;
case 42:
commentType = CommentType.block;
commentType = 1;
break;
}
pushBody(this.#parentNode, {
type: NodeType.Comment,
type: 21,
parent: this.#parentNode,

@@ -139,3 +133,3 @@ commentType,

pushBody(this.#parentNode, {
type: NodeType.Placeholder,
type: 22,
parent: this.#parentNode,

@@ -150,3 +144,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Scriptlet,
type: 23,
parent: this.#parentNode,

@@ -165,3 +159,3 @@ value: range.value,

let start = range.start;
let type = NodeType.Tag;
let type = 1;
let bodyType = htmljs_parser.TagType.html;

@@ -181,3 +175,3 @@ let nameText = void 0;

this.program.body.push(this.#staticNode = {
type: NodeType.Style,
type: 27,
parent: this.program,

@@ -200,3 +194,3 @@ ext: ext || void 0,

this.program.body.push(this.#staticNode = {
type: NodeType.Class,
type: 26,
parent: this.program,

@@ -209,3 +203,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Export,
type: 25,
parent: this.program,

@@ -218,3 +212,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Import,
type: 24,
parent: this.program,

@@ -229,3 +223,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Static,
type: 28,
parent: this.program,

@@ -268,3 +262,3 @@ target: nameText,

default:
if (nameText[0] === "@") type = NodeType.AttrTag;
if (nameText[0] === "@") type = 16;
break;

@@ -275,3 +269,3 @@ }

const name = {
type: NodeType.OpenTagName,
type: 2,
parent: void 0,

@@ -310,6 +304,6 @@ quasis: range.quasis,

};
if (tag.type === NodeType.AttrTag) {
if (tag.type === 16) {
let parentTag = parent;
let nameText = tag.nameText.slice(1);
while (parentTag.type === NodeType.Tag && isControlFlowTag(parentTag)) {
while (parentTag.type === 1 && isControlFlowTag(parentTag)) {
parentTag.hasAttrTags = true;

@@ -319,3 +313,3 @@ parentTag = parentTag.parent;

switch (parentTag.type) {
case NodeType.AttrTag:
case 16:
tag.owner = parentTag.owner;

@@ -325,3 +319,3 @@ parentTag.hasAttrTags = true;

break;
case NodeType.Tag:
case 1:
tag.owner = parentTag;

@@ -341,3 +335,3 @@ parentTag.hasAttrTags = true;

parent.shorthandId = {
type: NodeType.ShorthandId,
type: 3,
parent,

@@ -353,3 +347,3 @@ quasis: range.quasis,

const shorthandClassName = {
type: NodeType.ShorthandClassName,
type: 4,
parent,

@@ -367,3 +361,3 @@ quasis: range.quasis,

parent.typeArgs = {
type: NodeType.TagTypeArgs,
type: 5,
parent,

@@ -378,3 +372,3 @@ value: range.value,

parent.typeParams = {
type: NodeType.TagTypeParams,
type: 6,
parent,

@@ -389,3 +383,3 @@ value: range.value,

parent.var = {
type: NodeType.TagVar,
type: 7,
parent,

@@ -400,3 +394,3 @@ value: range.value,

parent.params = {
type: NodeType.TagParams,
type: 9,
parent,

@@ -411,3 +405,3 @@ value: range.value,

parent.args = {
type: NodeType.TagArgs,
type: 8,
parent,

@@ -422,3 +416,3 @@ value: range.value,

const name = {
type: NodeType.AttrName,
type: 11,
parent: void 0,

@@ -429,3 +423,3 @@ start: range.start,

pushAttr(parent, this.#attrNode = name.parent = {
type: NodeType.AttrNamed,
type: 10,
parent,

@@ -442,3 +436,3 @@ name,

parent.args = {
type: NodeType.AttrArgs,
type: 12,
parent,

@@ -454,3 +448,3 @@ value: range.value,

parent.value = {
type: NodeType.AttrValue,
type: 13,
parent,

@@ -467,3 +461,3 @@ value: range.value,

parent.value = {
type: NodeType.AttrMethod,
type: 14,
parent,

@@ -481,3 +475,3 @@ typeParams: range.typeParams,

pushAttr(parent, {
type: NodeType.AttrSpread,
type: 15,
parent,

@@ -491,3 +485,3 @@ value: range.value,

if (this.#staticNode) {
if (this.#staticNode.type === NodeType.Style) this.#staticNode.value.end = range.end - 1;
if (this.#staticNode.type === 27) this.#staticNode.value.end = range.end - 1;
this.#staticNode.end = range.end;

@@ -559,3 +553,3 @@ this.#staticNode = void 0;

tag.each((child) => {
if (child.node.type === NodeType.Placeholder) {
if (child.node.type === 22) {
code += `MARKO_${pid++}_`;

@@ -621,3 +615,3 @@ (placeholders ||= []).push(print(child));

if (tag.attrs?.length) {
for (const attr of tag.attrs) if (attr.type === NodeType.AttrNamed && attr.value?.type === NodeType.AttrValue && read(attr.name, opts) === "type") {
for (const attr of tag.attrs) if (attr.type === 10 && attr.value?.type === 13 && read(attr.name, opts) === "type") {
const { code } = opts._markoParsed;

@@ -781,6 +775,6 @@ const value = attr.value.value;

const visitorKeys = {
[NodeType.Tag]: tagVisitorKeys,
[NodeType.AttrTag]: tagVisitorKeys,
[NodeType.Program]: ["body"],
[NodeType.AttrNamed]: ["args", "value"]
[1]: tagVisitorKeys,
[16]: tagVisitorKeys,
[0]: ["body"],
[10]: ["args", "value"]
};

@@ -825,3 +819,3 @@ const languages = [{

opts.markoSyntax = "html";
for (const child of program.body) if (child.type === NodeType.Tag) {
for (const child of program.body) if (child.type === 1) {
if (child.concise) opts.markoSyntax = "concise";

@@ -833,2 +827,3 @@ break;

},
/* c8 ignore start */
locStart(node) {

@@ -857,28 +852,28 @@ return node.start;

const printHandlers = {
[NodeType.AttrArgs]: printExact,
[NodeType.AttrMethod]: printExact,
[NodeType.AttrNamed]: printExact,
[NodeType.AttrSpread]: printExact,
[NodeType.Class]: printExact,
[NodeType.Export]: printExact,
[NodeType.Import]: printExact,
[NodeType.OpenTagName]: printExact,
[NodeType.Placeholder]: printExact,
[NodeType.Scriptlet]: printExact,
[NodeType.ShorthandClassName]: printExact,
[NodeType.ShorthandId]: printExact,
[NodeType.Static]: printExact,
[NodeType.Style]: printExact,
[NodeType.TagArgs]: printExact,
[NodeType.TagParams]: printExact,
[NodeType.TagTypeArgs]: printExact,
[NodeType.TagTypeParams]: printExact,
[NodeType.TagVar]: printExact,
[NodeType.Tag]: printTag,
[NodeType.AttrTag]: printTag,
[NodeType.CDATA]: (path, opts) => `<![CDATA[${read(path.node.value, opts)}]]>`,
[NodeType.Comment]: (path, opts) => {
[12]: printExact,
[14]: printExact,
[10]: printExact,
[15]: printExact,
[26]: printExact,
[25]: printExact,
[24]: printExact,
[2]: printExact,
[22]: printExact,
[23]: printExact,
[4]: printExact,
[3]: printExact,
[28]: printExact,
[27]: printExact,
[8]: printExact,
[9]: printExact,
[5]: printExact,
[6]: printExact,
[7]: printExact,
[1]: printTag,
[16]: printTag,
[18]: (path, opts) => `<![CDATA[${read(path.node.value, opts)}]]>`,
[21]: (path, opts) => {
const { node } = path;
const code = read(node, opts);
if (node.commentType !== CommentType.line) {
if (node.commentType !== 0) {
if (code.includes("\n")) {

@@ -904,5 +899,5 @@ const lines = code.split("\n");

},
[NodeType.Doctype]: (path, opts) => `<!${read(path.node.value, opts).replace(/\s+/g, " ").trim()}>`,
[NodeType.Declaration]: (path, opts) => `<?${read(path.node.value, opts).trim()}?>`,
[NodeType.Program]: (path, opts, print) => {
[19]: (path, opts) => `<!${read(path.node.value, opts).replace(/\s+/g, " ").trim()}>`,
[20]: (path, opts) => `<?${read(path.node.value, opts).trim()}?>`,
[0]: (path, opts, print) => {
const body = printBody(path, opts, print);

@@ -912,3 +907,3 @@ if (!body) return [b.hardline];

},
[NodeType.Text]: (path, opts) => {
[17]: (path, opts) => {
const text = read(path.node, opts).replace(/\\/g, "\\\\");

@@ -919,6 +914,6 @@ return /^\$!?{/.test(text) ? "\\" + text : text;

const embedHandlers = {
[NodeType.Class]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), exprParse),
[NodeType.Import]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[NodeType.Export]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[NodeType.Style]: async (toDoc, _print, path, opts) => {
[26]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), exprParse),
[24]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[25]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[27]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -934,3 +929,3 @@ const code = read(node.value, opts).trim();

},
[NodeType.Static]: async (toDoc, _print, path, opts) => {
[28]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -940,3 +935,3 @@ const code = opts._markoParsed.code.slice(node.start + node.target.length + 1, node.end).replace(/^\s*\{([\s\S]*)\}\s*$/, "$1").trim();

},
[NodeType.Scriptlet]: async (toDoc, _print, path, opts) => {
[23]: async (toDoc, _print, path, opts) => {
const code = read(path.node.value, opts).replace(/^\s*\{([\s\S]*)\}\s*$/, "$1").trim();

@@ -949,4 +944,4 @@ return code ? [

},
[NodeType.OpenTagName]: (toDoc, _print, path, opts) => templateToDoc(toDoc, path, opts),
[NodeType.Placeholder]: async (toDoc, _print, path, opts) => {
[2]: (toDoc, _print, path, opts) => templateToDoc(toDoc, path, opts),
[22]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -962,4 +957,4 @@ const code = read(node.value, opts);

},
[NodeType.TagArgs]: (toDoc, _print, path, opts) => argsToDoc(path.node, opts, toDoc),
[NodeType.AttrNamed]: async (toDoc, _print, path, opts) => {
[8]: (toDoc, _print, path, opts) => argsToDoc(path.node, opts, toDoc),
[10]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -974,3 +969,3 @@ const name = read(node.name, opts);

}
if (node.value) if (node.value.type === NodeType.AttrMethod) {
if (node.value) if (node.value.type === 14) {
const attrMethodDoc = await toDoc(`function${read(node.value, opts)}`, exprParse);

@@ -984,8 +979,8 @@ if (Array.isArray(attrMethodDoc) && attrMethodDoc.length && typeof attrMethodDoc[0] === "string") {

},
[NodeType.AttrSpread]: async (toDoc, _print, path, opts) => {
[15]: async (toDoc, _print, path, opts) => {
return b.group(["...", toValidAttrValue(await toDoc(read(path.node.value, opts), exprParse), isConcise(opts))]);
},
[NodeType.ShorthandId]: async (toDoc, _print, path, opts) => ["#", await templateToDoc(toDoc, path, opts)],
[NodeType.ShorthandClassName]: async (toDoc, _print, path, opts) => [".", await templateToDoc(toDoc, path, opts)],
[NodeType.Tag]: async (toDoc, print, path, opts) => {
[3]: async (toDoc, _print, path, opts) => ["#", await templateToDoc(toDoc, path, opts)],
[4]: async (toDoc, _print, path, opts) => [".", await templateToDoc(toDoc, path, opts)],
[1]: async (toDoc, print, path, opts) => {
const parser = getTagParser(path.node, opts);

@@ -999,3 +994,3 @@ if (parser === void 0) return void 0;

},
[NodeType.TagVar]: async (toDoc, _print, path, opts) => {
[7]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1025,3 +1020,3 @@ let doc = await toDoc(`var ${read(node.value, opts).trim()}=_`, stmtParse);

},
[NodeType.TagTypeArgs]: async (toDoc, _print, path, opts) => {
[5]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1038,3 +1033,3 @@ if (isEmpty(node.value, opts)) return "";

},
[NodeType.TagParams]: async (toDoc, _print, path, opts) => {
[9]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1060,3 +1055,3 @@ if (isEmpty(node.value, opts)) return "";

},
[NodeType.TagTypeParams]: async (toDoc, _print, path, opts) => {
[6]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1155,3 +1150,3 @@ if (isEmpty(node.parent.params?.value, opts) || isEmpty(node.value, opts)) return "";

const childDoc = child.call(print);
inlineChild = isInline(child.node) || inlineChild && child.node.type === NodeType.Comment && child.node.commentType !== CommentType.line;
inlineChild = isInline(child.node) || inlineChild && child.node.type === 21 && child.node.commentType !== 0;
content ||= [];

@@ -1163,3 +1158,3 @@ if (inlineChild) {

}
if (child.node.type === NodeType.Text && typeof childDoc === "string") {
if (child.node.type === 17 && typeof childDoc === "string") {
const nl = isConcise(opts) ? b.hardline : b.literalline;

@@ -1194,7 +1189,7 @@ let lineStart = 0;

let childDoc = child.call(print);
if (child.node.type === NodeType.Text && typeof childDoc === "string") childDoc = trimText(childDoc, child);
if (child.node.type === 17 && typeof childDoc === "string") childDoc = trimText(childDoc, child);
if (!childDoc) return;
content ||= [];
isInlineTag = false;
inlineChild = isInline(child.node) || inlineChild && child.node.type === NodeType.Comment && child.node.commentType !== CommentType.line;
inlineChild = isInline(child.node) || inlineChild && child.node.type === 21 && child.node.commentType !== 0;
if (isExplicitLine) {

@@ -1211,3 +1206,3 @@ const last = content.length - 1;

switch (child.node.type) {
case NodeType.Text:
case 17:
if (typeof childDoc === "string") {

@@ -1225,3 +1220,3 @@ const len = childDoc.length;

break;
case NodeType.Placeholder:
case 22:
if (typeof childDoc === "string" && isVisibleSpace(childDoc)) {

@@ -1232,3 +1227,3 @@ if (endsWithLine(inline)) return;

break;
case NodeType.Tag:
case 1:
isInlineTag = true;

@@ -1327,3 +1322,3 @@ ensureVisibleSpaceBetweenTags(inline, opts);

const sibling = siblings[i];
if (sibling.type !== NodeType.Scriptlet && sibling.type !== NodeType.Comment) {
if (sibling.type !== 23 && sibling.type !== 21) {
prev = sibling;

@@ -1335,3 +1330,3 @@ break;

const sibling = siblings[i];
if (sibling.type !== NodeType.Scriptlet && sibling.type !== NodeType.Comment) {
if (sibling.type !== 23 && sibling.type !== 21) {
next = sibling;

@@ -1351,4 +1346,4 @@ break;

switch (node.type) {
case NodeType.Text:
case NodeType.Placeholder: return true;
case 17:
case 22: return true;
default: return false;

@@ -1359,5 +1354,5 @@ }

switch (node.type) {
case NodeType.Text:
case NodeType.Placeholder: return true;
case NodeType.Tag: return !!node.nameText && /^(?:a(?:bbr|cronym)?|b(?:do|ig|r)?|cite|code|dfn|em|i(?:mg)?|kbd|label|map|object|output|q|samp|small|span|strong|sub|sup|time|tt|var)$/.test(node.nameText);
case 17:
case 22: return true;
case 1: return !!node.nameText && /^(?:a(?:bbr|cronym)?|b(?:do|ig|r)?|cite|code|dfn|em|i(?:mg)?|kbd|label|map|object|output|q|samp|small|span|strong|sub|sup|time|tt|var)$/.test(node.nameText);
default: return false;

@@ -1367,5 +1362,5 @@ }

function hasPreservedText(node) {
if (node.type === NodeType.Tag && hasTagParser(node)) return true;
if (node.type === 1 && hasTagParser(node)) return true;
let cur = node;
while (cur.type === NodeType.Tag) {
while (cur.type === 1) {
if (cur.nameText && /^(?:textarea|pre)$/.test(cur.nameText)) return true;

@@ -1377,3 +1372,3 @@ cur = cur.parent;

function isDefaultAttr(node) {
if (node.type === NodeType.AttrNamed && node.value && node.name.start === node.name.end) return true;
if (node.type === 10 && node.value && node.name.start === node.name.end) return true;
return false;

@@ -1380,0 +1375,0 @@ }

@@ -38,8 +38,2 @@ import { doc } from "prettier";

}({});
let CommentType = /* @__PURE__ */ function(CommentType) {
CommentType[CommentType["line"] = 0] = "line";
CommentType[CommentType["block"] = 1] = "block";
CommentType[CommentType["html"] = 2] = "html";
return CommentType;
}({});
function parse(code, filename = "index.marko") {

@@ -69,3 +63,3 @@ const builder = new Builder(code);

this.program = this.#parentNode = {
type: NodeType.Program,
type: 0,
parent: void 0,

@@ -79,3 +73,3 @@ body: [],

pushBody(this.#parentNode, {
type: NodeType.Text,
type: 17,
parent: this.#parentNode,

@@ -88,3 +82,3 @@ start: range.start,

pushBody(this.#parentNode, {
type: NodeType.CDATA,
type: 18,
parent: this.#parentNode,

@@ -98,3 +92,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Doctype,
type: 19,
parent: this.#parentNode,

@@ -108,3 +102,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Declaration,
type: 20,
parent: this.#parentNode,

@@ -117,13 +111,13 @@ value: range.value,

onComment(range) {
let commentType = CommentType.html;
let commentType = 2;
switch (this.#code.charCodeAt(range.start + 1)) {
case 47:
commentType = CommentType.line;
commentType = 0;
break;
case 42:
commentType = CommentType.block;
commentType = 1;
break;
}
pushBody(this.#parentNode, {
type: NodeType.Comment,
type: 21,
parent: this.#parentNode,

@@ -138,3 +132,3 @@ commentType,

pushBody(this.#parentNode, {
type: NodeType.Placeholder,
type: 22,
parent: this.#parentNode,

@@ -149,3 +143,3 @@ value: range.value,

pushBody(this.#parentNode, {
type: NodeType.Scriptlet,
type: 23,
parent: this.#parentNode,

@@ -164,3 +158,3 @@ value: range.value,

let start = range.start;
let type = NodeType.Tag;
let type = 1;
let bodyType = TagType.html;

@@ -180,3 +174,3 @@ let nameText = void 0;

this.program.body.push(this.#staticNode = {
type: NodeType.Style,
type: 27,
parent: this.program,

@@ -199,3 +193,3 @@ ext: ext || void 0,

this.program.body.push(this.#staticNode = {
type: NodeType.Class,
type: 26,
parent: this.program,

@@ -208,3 +202,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Export,
type: 25,
parent: this.program,

@@ -217,3 +211,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Import,
type: 24,
parent: this.program,

@@ -228,3 +222,3 @@ start: range.start,

this.program.body.push(this.#staticNode = {
type: NodeType.Static,
type: 28,
parent: this.program,

@@ -267,3 +261,3 @@ target: nameText,

default:
if (nameText[0] === "@") type = NodeType.AttrTag;
if (nameText[0] === "@") type = 16;
break;

@@ -274,3 +268,3 @@ }

const name = {
type: NodeType.OpenTagName,
type: 2,
parent: void 0,

@@ -309,6 +303,6 @@ quasis: range.quasis,

};
if (tag.type === NodeType.AttrTag) {
if (tag.type === 16) {
let parentTag = parent;
let nameText = tag.nameText.slice(1);
while (parentTag.type === NodeType.Tag && isControlFlowTag(parentTag)) {
while (parentTag.type === 1 && isControlFlowTag(parentTag)) {
parentTag.hasAttrTags = true;

@@ -318,3 +312,3 @@ parentTag = parentTag.parent;

switch (parentTag.type) {
case NodeType.AttrTag:
case 16:
tag.owner = parentTag.owner;

@@ -324,3 +318,3 @@ parentTag.hasAttrTags = true;

break;
case NodeType.Tag:
case 1:
tag.owner = parentTag;

@@ -340,3 +334,3 @@ parentTag.hasAttrTags = true;

parent.shorthandId = {
type: NodeType.ShorthandId,
type: 3,
parent,

@@ -352,3 +346,3 @@ quasis: range.quasis,

const shorthandClassName = {
type: NodeType.ShorthandClassName,
type: 4,
parent,

@@ -366,3 +360,3 @@ quasis: range.quasis,

parent.typeArgs = {
type: NodeType.TagTypeArgs,
type: 5,
parent,

@@ -377,3 +371,3 @@ value: range.value,

parent.typeParams = {
type: NodeType.TagTypeParams,
type: 6,
parent,

@@ -388,3 +382,3 @@ value: range.value,

parent.var = {
type: NodeType.TagVar,
type: 7,
parent,

@@ -399,3 +393,3 @@ value: range.value,

parent.params = {
type: NodeType.TagParams,
type: 9,
parent,

@@ -410,3 +404,3 @@ value: range.value,

parent.args = {
type: NodeType.TagArgs,
type: 8,
parent,

@@ -421,3 +415,3 @@ value: range.value,

const name = {
type: NodeType.AttrName,
type: 11,
parent: void 0,

@@ -428,3 +422,3 @@ start: range.start,

pushAttr(parent, this.#attrNode = name.parent = {
type: NodeType.AttrNamed,
type: 10,
parent,

@@ -441,3 +435,3 @@ name,

parent.args = {
type: NodeType.AttrArgs,
type: 12,
parent,

@@ -453,3 +447,3 @@ value: range.value,

parent.value = {
type: NodeType.AttrValue,
type: 13,
parent,

@@ -466,3 +460,3 @@ value: range.value,

parent.value = {
type: NodeType.AttrMethod,
type: 14,
parent,

@@ -480,3 +474,3 @@ typeParams: range.typeParams,

pushAttr(parent, {
type: NodeType.AttrSpread,
type: 15,
parent,

@@ -490,3 +484,3 @@ value: range.value,

if (this.#staticNode) {
if (this.#staticNode.type === NodeType.Style) this.#staticNode.value.end = range.end - 1;
if (this.#staticNode.type === 27) this.#staticNode.value.end = range.end - 1;
this.#staticNode.end = range.end;

@@ -558,3 +552,3 @@ this.#staticNode = void 0;

tag.each((child) => {
if (child.node.type === NodeType.Placeholder) {
if (child.node.type === 22) {
code += `MARKO_${pid++}_`;

@@ -620,3 +614,3 @@ (placeholders ||= []).push(print(child));

if (tag.attrs?.length) {
for (const attr of tag.attrs) if (attr.type === NodeType.AttrNamed && attr.value?.type === NodeType.AttrValue && read(attr.name, opts) === "type") {
for (const attr of tag.attrs) if (attr.type === 10 && attr.value?.type === 13 && read(attr.name, opts) === "type") {
const { code } = opts._markoParsed;

@@ -780,6 +774,6 @@ const value = attr.value.value;

const visitorKeys = {
[NodeType.Tag]: tagVisitorKeys,
[NodeType.AttrTag]: tagVisitorKeys,
[NodeType.Program]: ["body"],
[NodeType.AttrNamed]: ["args", "value"]
[1]: tagVisitorKeys,
[16]: tagVisitorKeys,
[0]: ["body"],
[10]: ["args", "value"]
};

@@ -824,3 +818,3 @@ const languages = [{

opts.markoSyntax = "html";
for (const child of program.body) if (child.type === NodeType.Tag) {
for (const child of program.body) if (child.type === 1) {
if (child.concise) opts.markoSyntax = "concise";

@@ -832,2 +826,3 @@ break;

},
/* c8 ignore start */
locStart(node) {

@@ -856,28 +851,28 @@ return node.start;

const printHandlers = {
[NodeType.AttrArgs]: printExact,
[NodeType.AttrMethod]: printExact,
[NodeType.AttrNamed]: printExact,
[NodeType.AttrSpread]: printExact,
[NodeType.Class]: printExact,
[NodeType.Export]: printExact,
[NodeType.Import]: printExact,
[NodeType.OpenTagName]: printExact,
[NodeType.Placeholder]: printExact,
[NodeType.Scriptlet]: printExact,
[NodeType.ShorthandClassName]: printExact,
[NodeType.ShorthandId]: printExact,
[NodeType.Static]: printExact,
[NodeType.Style]: printExact,
[NodeType.TagArgs]: printExact,
[NodeType.TagParams]: printExact,
[NodeType.TagTypeArgs]: printExact,
[NodeType.TagTypeParams]: printExact,
[NodeType.TagVar]: printExact,
[NodeType.Tag]: printTag,
[NodeType.AttrTag]: printTag,
[NodeType.CDATA]: (path, opts) => `<![CDATA[${read(path.node.value, opts)}]]>`,
[NodeType.Comment]: (path, opts) => {
[12]: printExact,
[14]: printExact,
[10]: printExact,
[15]: printExact,
[26]: printExact,
[25]: printExact,
[24]: printExact,
[2]: printExact,
[22]: printExact,
[23]: printExact,
[4]: printExact,
[3]: printExact,
[28]: printExact,
[27]: printExact,
[8]: printExact,
[9]: printExact,
[5]: printExact,
[6]: printExact,
[7]: printExact,
[1]: printTag,
[16]: printTag,
[18]: (path, opts) => `<![CDATA[${read(path.node.value, opts)}]]>`,
[21]: (path, opts) => {
const { node } = path;
const code = read(node, opts);
if (node.commentType !== CommentType.line) {
if (node.commentType !== 0) {
if (code.includes("\n")) {

@@ -903,5 +898,5 @@ const lines = code.split("\n");

},
[NodeType.Doctype]: (path, opts) => `<!${read(path.node.value, opts).replace(/\s+/g, " ").trim()}>`,
[NodeType.Declaration]: (path, opts) => `<?${read(path.node.value, opts).trim()}?>`,
[NodeType.Program]: (path, opts, print) => {
[19]: (path, opts) => `<!${read(path.node.value, opts).replace(/\s+/g, " ").trim()}>`,
[20]: (path, opts) => `<?${read(path.node.value, opts).trim()}?>`,
[0]: (path, opts, print) => {
const body = printBody(path, opts, print);

@@ -911,3 +906,3 @@ if (!body) return [b.hardline];

},
[NodeType.Text]: (path, opts) => {
[17]: (path, opts) => {
const text = read(path.node, opts).replace(/\\/g, "\\\\");

@@ -918,6 +913,6 @@ return /^\$!?{/.test(text) ? "\\" + text : text;

const embedHandlers = {
[NodeType.Class]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), exprParse),
[NodeType.Import]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[NodeType.Export]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[NodeType.Style]: async (toDoc, _print, path, opts) => {
[26]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), exprParse),
[24]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[25]: (toDoc, _print, path, opts) => toDoc(read(path.node, opts), stmtParse),
[27]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -933,3 +928,3 @@ const code = read(node.value, opts).trim();

},
[NodeType.Static]: async (toDoc, _print, path, opts) => {
[28]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -939,3 +934,3 @@ const code = opts._markoParsed.code.slice(node.start + node.target.length + 1, node.end).replace(/^\s*\{([\s\S]*)\}\s*$/, "$1").trim();

},
[NodeType.Scriptlet]: async (toDoc, _print, path, opts) => {
[23]: async (toDoc, _print, path, opts) => {
const code = read(path.node.value, opts).replace(/^\s*\{([\s\S]*)\}\s*$/, "$1").trim();

@@ -948,4 +943,4 @@ return code ? [

},
[NodeType.OpenTagName]: (toDoc, _print, path, opts) => templateToDoc(toDoc, path, opts),
[NodeType.Placeholder]: async (toDoc, _print, path, opts) => {
[2]: (toDoc, _print, path, opts) => templateToDoc(toDoc, path, opts),
[22]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -961,4 +956,4 @@ const code = read(node.value, opts);

},
[NodeType.TagArgs]: (toDoc, _print, path, opts) => argsToDoc(path.node, opts, toDoc),
[NodeType.AttrNamed]: async (toDoc, _print, path, opts) => {
[8]: (toDoc, _print, path, opts) => argsToDoc(path.node, opts, toDoc),
[10]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -973,3 +968,3 @@ const name = read(node.name, opts);

}
if (node.value) if (node.value.type === NodeType.AttrMethod) {
if (node.value) if (node.value.type === 14) {
const attrMethodDoc = await toDoc(`function${read(node.value, opts)}`, exprParse);

@@ -983,8 +978,8 @@ if (Array.isArray(attrMethodDoc) && attrMethodDoc.length && typeof attrMethodDoc[0] === "string") {

},
[NodeType.AttrSpread]: async (toDoc, _print, path, opts) => {
[15]: async (toDoc, _print, path, opts) => {
return b.group(["...", toValidAttrValue(await toDoc(read(path.node.value, opts), exprParse), isConcise(opts))]);
},
[NodeType.ShorthandId]: async (toDoc, _print, path, opts) => ["#", await templateToDoc(toDoc, path, opts)],
[NodeType.ShorthandClassName]: async (toDoc, _print, path, opts) => [".", await templateToDoc(toDoc, path, opts)],
[NodeType.Tag]: async (toDoc, print, path, opts) => {
[3]: async (toDoc, _print, path, opts) => ["#", await templateToDoc(toDoc, path, opts)],
[4]: async (toDoc, _print, path, opts) => [".", await templateToDoc(toDoc, path, opts)],
[1]: async (toDoc, print, path, opts) => {
const parser = getTagParser(path.node, opts);

@@ -998,3 +993,3 @@ if (parser === void 0) return void 0;

},
[NodeType.TagVar]: async (toDoc, _print, path, opts) => {
[7]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1024,3 +1019,3 @@ let doc = await toDoc(`var ${read(node.value, opts).trim()}=_`, stmtParse);

},
[NodeType.TagTypeArgs]: async (toDoc, _print, path, opts) => {
[5]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1037,3 +1032,3 @@ if (isEmpty(node.value, opts)) return "";

},
[NodeType.TagParams]: async (toDoc, _print, path, opts) => {
[9]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1059,3 +1054,3 @@ if (isEmpty(node.value, opts)) return "";

},
[NodeType.TagTypeParams]: async (toDoc, _print, path, opts) => {
[6]: async (toDoc, _print, path, opts) => {
const { node } = path;

@@ -1154,3 +1149,3 @@ if (isEmpty(node.parent.params?.value, opts) || isEmpty(node.value, opts)) return "";

const childDoc = child.call(print);
inlineChild = isInline(child.node) || inlineChild && child.node.type === NodeType.Comment && child.node.commentType !== CommentType.line;
inlineChild = isInline(child.node) || inlineChild && child.node.type === 21 && child.node.commentType !== 0;
content ||= [];

@@ -1162,3 +1157,3 @@ if (inlineChild) {

}
if (child.node.type === NodeType.Text && typeof childDoc === "string") {
if (child.node.type === 17 && typeof childDoc === "string") {
const nl = isConcise(opts) ? b.hardline : b.literalline;

@@ -1193,7 +1188,7 @@ let lineStart = 0;

let childDoc = child.call(print);
if (child.node.type === NodeType.Text && typeof childDoc === "string") childDoc = trimText(childDoc, child);
if (child.node.type === 17 && typeof childDoc === "string") childDoc = trimText(childDoc, child);
if (!childDoc) return;
content ||= [];
isInlineTag = false;
inlineChild = isInline(child.node) || inlineChild && child.node.type === NodeType.Comment && child.node.commentType !== CommentType.line;
inlineChild = isInline(child.node) || inlineChild && child.node.type === 21 && child.node.commentType !== 0;
if (isExplicitLine) {

@@ -1210,3 +1205,3 @@ const last = content.length - 1;

switch (child.node.type) {
case NodeType.Text:
case 17:
if (typeof childDoc === "string") {

@@ -1224,3 +1219,3 @@ const len = childDoc.length;

break;
case NodeType.Placeholder:
case 22:
if (typeof childDoc === "string" && isVisibleSpace(childDoc)) {

@@ -1231,3 +1226,3 @@ if (endsWithLine(inline)) return;

break;
case NodeType.Tag:
case 1:
isInlineTag = true;

@@ -1326,3 +1321,3 @@ ensureVisibleSpaceBetweenTags(inline, opts);

const sibling = siblings[i];
if (sibling.type !== NodeType.Scriptlet && sibling.type !== NodeType.Comment) {
if (sibling.type !== 23 && sibling.type !== 21) {
prev = sibling;

@@ -1334,3 +1329,3 @@ break;

const sibling = siblings[i];
if (sibling.type !== NodeType.Scriptlet && sibling.type !== NodeType.Comment) {
if (sibling.type !== 23 && sibling.type !== 21) {
next = sibling;

@@ -1350,4 +1345,4 @@ break;

switch (node.type) {
case NodeType.Text:
case NodeType.Placeholder: return true;
case 17:
case 22: return true;
default: return false;

@@ -1358,5 +1353,5 @@ }

switch (node.type) {
case NodeType.Text:
case NodeType.Placeholder: return true;
case NodeType.Tag: return !!node.nameText && /^(?:a(?:bbr|cronym)?|b(?:do|ig|r)?|cite|code|dfn|em|i(?:mg)?|kbd|label|map|object|output|q|samp|small|span|strong|sub|sup|time|tt|var)$/.test(node.nameText);
case 17:
case 22: return true;
case 1: return !!node.nameText && /^(?:a(?:bbr|cronym)?|b(?:do|ig|r)?|cite|code|dfn|em|i(?:mg)?|kbd|label|map|object|output|q|samp|small|span|strong|sub|sup|time|tt|var)$/.test(node.nameText);
default: return false;

@@ -1366,5 +1361,5 @@ }

function hasPreservedText(node) {
if (node.type === NodeType.Tag && hasTagParser(node)) return true;
if (node.type === 1 && hasTagParser(node)) return true;
let cur = node;
while (cur.type === NodeType.Tag) {
while (cur.type === 1) {
if (cur.nameText && /^(?:textarea|pre)$/.test(cur.nameText)) return true;

@@ -1376,3 +1371,3 @@ cur = cur.parent;

function isDefaultAttr(node) {
if (node.type === NodeType.AttrNamed && node.value && node.name.start === node.name.end) return true;
if (node.type === 10 && node.value && node.name.start === node.name.end) return true;
return false;

@@ -1379,0 +1374,0 @@ }

@@ -51,3 +51,3 @@ import { type Range, type Ranges, TagType } from "htmljs-parser";

nameText: "if" | "else" | "else-if" | "for" | "while";
bodyType: TagType.html;
bodyType: typeof TagType.html;
};

@@ -70,3 +70,3 @@ type ChildNode = Tag | AttrTag | Text | Doctype | Declaration | CDATA | Placeholder | Scriptlet | Comment;

nameText: string | undefined;
bodyType: Exclude<TagType, "statement">;
bodyType: Exclude<TagType, typeof TagType.statement>;
name: OpenTagName;

@@ -93,3 +93,3 @@ var: TagVar | undefined;

nameText: string;
bodyType: TagType.html;
bodyType: typeof TagType.html;
name: OpenTagName;

@@ -96,0 +96,0 @@ var: TagVar | undefined;

{
"name": "prettier-plugin-marko",
"version": "4.0.9",
"version": "4.0.10",
"description": "A prettier plugin for parsing and printing Marko files",

@@ -46,24 +46,24 @@ "keywords": [

"dependencies": {
"htmljs-parser": "^5.10.2"
"htmljs-parser": "^5.12.1"
},
"devDependencies": {
"@changesets/changelog-github": "^0.6.0",
"@changesets/cli": "^2.30.0",
"@changesets/changelog-github": "^0.7.0",
"@changesets/cli": "^2.31.0",
"@eslint/js": "^10.0.1",
"@marko/compiler": "^5.39.62",
"@types/node": "^25.5.0",
"@vitest/coverage-v8": "^4.1.1",
"eslint": "^10.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"globals": "^17.4.0",
"@marko/compiler": "^5.40.0",
"@types/node": "^26.1.0",
"@vitest/coverage-v8": "^4.1.9",
"eslint": "^10.6.0",
"eslint-plugin-simple-import-sort": "^13.0.0",
"globals": "^17.7.0",
"husky": "^9.1.7",
"lint-staged": "^16.4.0",
"marko": "^6.0.160",
"prettier": "^3.8.1",
"lint-staged": "^17.0.8",
"marko": "^6.2.1",
"prettier": "^3.9.4",
"prettier-plugin-packagejson": "^3.0.2",
"rolldown": "^1.0.0-rc.11",
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.2",
"vitest": "^4.1.1"
"rolldown": "^1.1.4",
"typescript": "^6.0.3",
"typescript-eslint": "^8.62.1",
"vitest": "^4.1.9"
}
}