# yy-pug-lexer

> The pug lexer (takes a string and converts it to an array of tokens)

Latest version **1.0.3** (published 2016-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install yy-pug-lexer
pnpm add yy-pug-lexer
yarn add yy-pug-lexer
bun add yy-pug-lexer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-06-05 |
| First published | 2016-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ForbesLindesay |
| Maintainers | yuemenglong |
| Keywords | pug |

## Links

- npm: https://www.npmjs.com/package/yy-pug-lexer
- Repository: https://github.com/yuemenglong/pug-lexer
- Homepage: https://github.com/yuemenglong/pug-lexer#readme
- Issues: https://github.com/yuemenglong/pug-lexer/issues
- npm.io page: https://npm.io/package/yy-pug-lexer

## Dependencies (3)

- [pug-error](https://npm.io/package/pug-error.md) ^1.3.0
- [is-expression](https://npm.io/package/is-expression.md) ^2.0.0
- [character-parser](https://npm.io/package/character-parser.md) ^2.1.1

## Recent versions

- 1.0.3 (latest) — 2016-06-05
- 1.0.2 — 2016-05-13
- 1.0.1 — 2016-05-06

## README

# pug-lexer

The pug lexer.  This module is responsible for taking a string and converting it into an array of tokens.

[![Build Status](https://img.shields.io/travis/pugjs/pug-lexer/master.svg)](https://travis-ci.org/pugjs/pug-lexer)
[![Dependency Status](https://img.shields.io/david/pugjs/pug-lexer.svg)](https://david-dm.org/pugjs/pug-lexer)
[![NPM version](https://img.shields.io/npm/v/pug-lexer.svg)](https://www.npmjs.org/package/pug-lexer)

## Installation

    npm install pug-lexer

## Usage

```js
var lex = require('pug-lexer');
```

### `lex(str, filename, options)`

Convert Pug string to an array of tokens.

`filename`, if provided, is used in error handling.

`options` can contain the following property:

- `plugins` (array): An array of plugins, in the order they should be applied.

```js
console.log(JSON.stringify(lex('div(data-foo="bar")', 'my-file.pug'), null, '  '))
```

```json
[
  {
    "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, filename, 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:

- `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

---
_Source: https://npm.io/package/yy-pug-lexer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
