The simplest abstract syntax tree walker.
npm i --save ast-plugin
- Traverse Ast plugins
import { Ast, Plugin } from 'ast-plugin';
new Ast(ast).traverse([
new TestPlugin(cfg),
// ...
]);
- Write an ast plugin
import { Ast, Plugin } from 'ast-plugin';
class TestPlugin extends Plugin {
pre = () => {
};
visitor = () => {
return {
// process node with type = 'text'
text: ast => {
console.log(ast.node);
ast.segment();
},
};
};
post = () => {
};
}
- lint-md Cli tool to lint your markdown file for Chinese.
MIT@hustcc.