How to use the nodes function from stylus

Find comprehensive JavaScript stylus.nodes code examples handpicked from public code repositorys.

stylus.nodes is a module in the Stylus library that defines the abstract syntax tree (AST) nodes for Stylus stylesheets.

472
473
474
475
476
477
478
479
480
481
compiler.isURL = true;
const visitedUrl = url.nodes.map(node => compiler.visit(node)).join("");
const splitted = visitedUrl.split("!");
const parsedUrl = (0, _url.parse)(splitted.pop()); // Parse literal

const literal = new _stylus.nodes.Literal(`url("${parsedUrl.href}")`);
let {
  pathname
} = parsedUrl;
let {
fork icon1
star icon0
watch icon1

+ 2 other calls in file

How does stylus.nodes work?

stylus.nodes is a module in the Stylus library that provides a set of classes and utilities to represent and manipulate various nodes in the abstract syntax tree (AST) of a Stylus stylesheet, including literals, variables, operators, selectors, and more.

Ai Example

1
2
3
4
const stylus = require("stylus");
const nodes = stylus.nodes;

const block = new nodes.Block();

This creates a new instance of the Block class and assigns it to the block variable. The Block class has various methods for manipulating the block of code it represents, such as push, which adds a new node to the block.