@shopify/theme-language-server-common
Version:
<h1 align="center" style="position: relative;" > <br> <img src="https://github.com/Shopify/theme-check-vscode/blob/main/images/shopify_glyph.png?raw=true" alt="logo" width="141" height="160"> <br> Theme Language Server </h1>
52 lines • 2.26 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLiquidVariableOutput = exports.isNamedLiquidTag = exports.isHtmlAttribute = exports.getCompoundName = exports.isNamedHtmlElementNode = exports.isAttrEmpty = exports.isTextNode = exports.HtmlAttributeTypes = exports.HtmlElementTypes = void 0;
const liquid_html_parser_1 = require("@shopify/liquid-html-parser");
exports.HtmlElementTypes = [
liquid_html_parser_1.NodeTypes.HtmlElement,
liquid_html_parser_1.NodeTypes.HtmlDanglingMarkerClose,
liquid_html_parser_1.NodeTypes.HtmlSelfClosingElement,
liquid_html_parser_1.NodeTypes.HtmlVoidElement,
liquid_html_parser_1.NodeTypes.HtmlRawNode,
];
exports.HtmlAttributeTypes = [
liquid_html_parser_1.NodeTypes.AttrUnquoted,
liquid_html_parser_1.NodeTypes.AttrDoubleQuoted,
liquid_html_parser_1.NodeTypes.AttrSingleQuoted,
liquid_html_parser_1.NodeTypes.AttrEmpty,
];
function isTextNode(node) {
return node.type === liquid_html_parser_1.NodeTypes.TextNode;
}
exports.isTextNode = isTextNode;
function isAttrEmpty(node) {
return node.type === liquid_html_parser_1.NodeTypes.AttrEmpty;
}
exports.isAttrEmpty = isAttrEmpty;
function isNamedHtmlElementNode(node) {
return exports.HtmlElementTypes.includes(node.type);
}
exports.isNamedHtmlElementNode = isNamedHtmlElementNode;
function getCompoundName(node) {
if (typeof node.name === 'string')
return node.name;
const names = node.name;
if (names.length === 0 || names.length > 1 || !isTextNode(names[0])) {
return 'unknown';
}
return names[0].value;
}
exports.getCompoundName = getCompoundName;
function isHtmlAttribute(node) {
return exports.HtmlAttributeTypes.some((type) => node.type === type);
}
exports.isHtmlAttribute = isHtmlAttribute;
function isNamedLiquidTag(node, name) {
return node.type === liquid_html_parser_1.NodeTypes.LiquidTag && node.name === name && typeof node.markup !== 'string';
}
exports.isNamedLiquidTag = isNamedLiquidTag;
function isLiquidVariableOutput(node) {
return node.type === liquid_html_parser_1.NodeTypes.LiquidVariableOutput && typeof node.markup !== 'string';
}
exports.isLiquidVariableOutput = isLiquidVariableOutput;
//# sourceMappingURL=node.js.map
;