@lint-md/ast-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@lint-md/ast-plugin

The simplest abstract syntax tree walker.

Build Status

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.

Readme

Keywords

Package Sidebar

Install

npm i @lint-md/ast-plugin

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

24.2 kB

Total Files

44

Last publish

Collaborators

  • yzl520
  • atool