有没有办法访问手写笔AST

is there there way to access stylus AST

我需要访问由 stylus 生成的 CSS 样式的抽象语法树 (AST) 而无需再次解析(通过 css-parse)。 我想知道生成样式的 AST 是否公开可用。

部分支持访问 AST。它不完整,但在某些情况下仍然可以使用。

这是一个如何执行此操作的基本示例 — https://gist.github.com/kizu/41f40714ea533ee1f876

关键部分是:

var Parser = require('stylus').Parser;
var parser = new Parser(stylContent);
var ast = parser.parse();

您将从 stylContent 中获得包含 Stylus 代码的 AST。

在未来(Stylus 1.0.0),我们计划让访问 AST 变得更容易,它会更完整。