0.0.7 • Published 5 years ago

ast-plugin v0.0.7

Weekly downloads
297
License
MIT
Repository
github
Last release
5 years ago

ast-plugin

The simplest abstract syntax tree walker.

Install

npm i --save ast-plugin

Usage

  • 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 = () => {};
}

Used by

  • lint-md: Cli tool to lint your markdown file for Chinese.

License

MIT@hustcc.

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.1-beta.1

5 years ago