6.0.0 • Published 4 years ago

pug-parser v6.0.0

Weekly downloads
1,160,468
License
MIT
Repository
github
Last release
4 years ago

pug-parser

The pug parser (takes an array of tokens and converts it to an abstract syntax tree)

Build Status Dependencies Status DevDependencies Status NPM version

Installation

npm install pug-parser

Usage

var parse = require('pug-parser');

parse(tokens, options)

Convert Pug tokens to an abstract syntax tree (AST).

options can contain the following properties:

  • filename (string): The name of the Pug file; it is included in the produced AST nodes and error handling, if provided.
  • plugins (array): An array of plugins, in the order they should be applied.
  • src (string): The source of the Pug file; it is used in error handling if provided.
var lex = require('pug-lexer');

var filename = 'my-file.pug';
var src = 'div(data-foo="bar")';
var tokens = lex(src, {filename});

var ast = parse(tokens, {filename, src});

console.log(JSON.stringify(ast, null, '  '))
{
  "type": "Block",
  "nodes": [
    {
      "type": "Tag",
      "name": "div",
      "selfClosing": false,
      "block": {
        "type": "Block",
        "nodes": [],
        "line": 1,
        "filename": "my-file.pug"
      },
      "attrs": [
        {
          "name": "data-foo",
          "val": "\"bar\"",
          "line": 1,
          "column": 5,
          "filename": "my-file.pug",
          "mustEscape": true
        }
      ],
      "attributeBlocks": [],
      "isInline": false,
      "line": 1,
      "column": 1,
      "filename": "my-file.pug"
    }
  ],
  "line": 0,
  "filename": "my-file.pug"
}

new parse.Parser(tokens, options)

Constructor for a Parser class. This is not meant to be used directly unless you know what you are doing.

options may contain the following properties:

  • filename (string): The name of the Pug file; it is included in the produced AST nodes and error handling, if provided.
  • plugins (array): An array of plugins, in the order they should be applied.
  • src (string): The source of the Pug file; it is used in error handling if provided.

License

MIT

pug@olivervorasai/sliderfalling42-butterfly-envelopefalling42-butterfly-wowjsasterjs@everything-registry/sub-chunk-2492scegteapackage-tatespoorman297rpugthen-pugvolar-service-pugvscode-pug-languageservicemi18n-corelocal-scoped-scss-with-pug-loaderjade-jsxjade2scriptjaideicons-vue-testio-ng2-aot-fixer-pugmitroofann-pugmolosserhtml-typingsimport-bem-webpack-pluginjsxgettextparcel-plugin-pugpug-asyncpug-dependenciespug-dependencypug-element-loaderpug-cachepug-customer-parserpug-html-vuepug-pack-loaderpug-package-loaderpug-layoutpug-inheritancepug-react-compilerpug-react-loaderpug2tsxpug3-ast-loaderpug-tailwindpug-vdompug-stylekit-webpack-pluginpugjs-angular-language-serverpugjs-angular-templatepugjs-language-servicenessarcs-coresi18n-core@amory/transform-react-pug@amory/react-pug@astql/pug.pug@bitfirer/vue-qriously@brydget/restifyyi18n-corezliq-pug@hazyflame/vue-jitsi-meet@grantstrachan/npm-packaging-test@infinitebrahmanuniverse/nolb-pug@ladjs/pug@linthtml/linthtml-pug@mydiem/aot-fixer-pug@markuplint/pug-parser@kocan-plugins/pug@kocan/pug-language-service@i18never/parse@i18never/preprocess@ptb/transform-react-pug@scoutgg/fn-pug@startupjs/babel-plugin-transform-react-pug@object-studio/react-native-web@cloudrac3r/pug@dinert/componentalisselisss-lab3@zalastax/nolb-pug@unisharp/pug-inheritance@virtualpatterns/mablung-check-dependency@virtualpatterns/nessa@uiengine/adapter-pug@volar/pug-language-service@volar-plugins/pugangular-aot-fixer-pugcomponent-scannerderby-pugdi18n-coredi18n-core-vue3docs-intlsbabel-plugin-transform-react-pugbabel-plugin-transform-react-pug-coffeebabel-plugin-transform-react-pug-coffee7babel-plugin-react-pugbroccoli-pugeslint-plugin-pugemjayflutter-viewgettext-pug
6.0.0

4 years ago

6.0.0-canary-2

4 years ago

6.0.0-canary-1

5 years ago

5.0.1

5 years ago

4.0.2

7 years ago

5.0.0

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.0.0

9 years ago

0.0.0

9 years ago