GithubHelp home page GithubHelp logo

isabella232 / pug-lexer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pugjs/pug-lexer

0.0 0.0 0.0 423 KB

The pug lexer (converts a string into an array of tokens)

License: MIT License

JavaScript 70.37% HTML 29.63%

pug-lexer's Introduction

pug-lexer

The pug lexer. This module is responsible for taking a string and converting it into an array of tokens.

Build Status Dependency Status NPM version Coverage Status

Installation

npm install pug-lexer

Usage

var lex = require('pug-lexer');

lex(str, options)

Convert Pug string to an array of tokens.

options can contain the following properties:

  • filename (string): The name of the Pug file; it is used in error handling if provided.
  • plugins (array): An array of plugins, in the order they should be applied.
console.log(JSON.stringify(lex('div(data-foo="bar")', {filename: 'my-file.pug'}), null, '  '))
[
  {
    "type": "tag",
    "line": 1,
    "val": "div",
    "selfClosing": false
  },
  {
    "type": "attrs",
    "line": 1,
    "attrs": [
      {
        "name": "data-foo",
        "val": "\"bar\"",
        "escaped": true
      }
    ]
  },
  {
    "type": "eos",
    "line": 1
  }
]

new lex.Lexer(str, options)

Constructor for a Lexer 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 used in error handling if provided.
  • interpolated (boolean): if the Lexer is created as a child lexer for inline tag interpolation (e.g. #[p Hello]). Defaults to false.
  • startingLine (integer): the real line number of the first line in the input. It is also used for inline tag interpolation. Defaults to 1.
  • plugins (array): An array of plugins, in the order they should be applied.

License

MIT

pug-lexer's People

Contributors

alubbe avatar evanw avatar forbeslindesay avatar hemanth avatar rzara avatar timothygu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.