var parser = new less.Parser(); var source = "@color: #fff; body { color: @color; }"; parser.parse(source, function (err, tree) { if (err) { console.error(err); } else { console.log(tree.toCSS()); } });
var parser = new less.Parser(); var sourceUrl = "http://example.com/styles.less"; parser.parseURL(sourceUrl, function (err, tree) { if (err) { console.error(err); } else { console.log(tree.toCSS()); } });This code example shows how to use the less.Parser to parse a Less CSS file from a remote URL and output the corresponding CSS code. The input is a variable that defines the URL of the Less file, and the output is the same code, but with the Less variables resolved. Overall, the JavaScript Less Parser is a useful library for working with Less CSS in JavaScript projects. It is a part of the Less.js project, which provides a comprehensive set of features for working with CSS preprocessor languages.