Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename to pug-lexer #51

Merged
merged 4 commits into from
Dec 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# jade-lexer
# pug-lexer

The jade lexer. This module is responsible for taking a string and converting it into an array of tokens.
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/jadejs/jade-lexer/master.svg)](https://travis-ci.org/jadejs/jade-lexer)
[![Dependency Status](https://img.shields.io/gemnasium/jadejs/jade-lexer.svg)](https://gemnasium.com/jadejs/jade-lexer)
[![NPM version](https://img.shields.io/npm/v/jade-lexer.svg)](https://www.npmjs.org/package/jade-lexer)
[![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/gemnasium/pugjs/pug-lexer.svg)](https://gemnasium.com/pugjs/pug-lexer)
[![NPM version](https://img.shields.io/npm/v/pug-lexer.svg)](https://www.npmjs.org/package/pug-lexer)

## Installation

npm install jade-lexer
npm install pug-lexer

## Usage

```js
var lex = require('jade-lexer');
var lex = require('pug-lexer');
```

### `lex(str, filename, options)`

Convert Jade string to an array of tokens.
Convert Pug string to an array of tokens.

`filename`, if provided, is used in error handling.

Expand All @@ -27,7 +27,7 @@ Convert Jade string to an array of tokens.
- `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.jade'), null, ' '))
console.log(JSON.stringify(lex('div(data-foo="bar")', 'my-file.pug'), null, ' '))
```

```json
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var assert = require('assert');
var isExpression = require('is-expression');
var characterParser = require('character-parser');
var error = require('jade-error');
var error = require('pug-error');

module.exports = lex;
module.exports.Lexer = Lexer;
Expand Down Expand Up @@ -436,7 +436,7 @@ Lexer.prototype = {
this.tokens.push(this.tok(type, prefix + value.substring(0, indexOfStart)));
this.incrementColumn(prefix.length + indexOfStart);
if (escaped) this.incrementColumn(1);
this.tokens.push(this.tok('start-jade-interpolation'));
this.tokens.push(this.tok('start-pug-interpolation'));
this.incrementColumn(2);
var child = new this.constructor(value.substr(indexOfStart + 2), this.filename, {
interpolated: true,
Expand All @@ -447,15 +447,15 @@ Lexer.prototype = {
try {
interpolated = child.getTokens();
} catch (ex) {
if (ex.code && /^JADE:/.test(ex.code)) {
if (ex.code && /^PUG:/.test(ex.code)) {
this.colno = ex.column;
this.error(ex.code.substr(5), ex.msg);
this.error(ex.code.substr(4), ex.msg);
}
throw ex;
}
this.colno = child.colno;
this.tokens = this.tokens.concat(interpolated);
this.tokens.push(this.tok('end-jade-interpolation'));
this.tokens.push(this.tok('end-pug-interpolation'));
this.incrementColumn(1);
this.addText(type, child.input);
return;
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "jade-lexer",
"name": "pug-lexer",
"version": "0.0.9",
"description": "The jade lexer (takes a string and converts it to an array of tokens)",
"description": "The pug lexer (takes a string and converts it to an array of tokens)",
"keywords": [
"jade"
"pug"
],
"dependencies": {
"character-parser": "^2.1.1",
"is-expression": "^1.0.0",
"jade-error": "^1.0.0"
"pug-error": "^1.3.0"
},
"devDependencies": {
"istanbul": "^0.3.2"
Expand All @@ -20,7 +20,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jadejs/jade-lexer.git"
"url": "https://github.com/pugjs/pug-lexer.git"
},
"author": "ForbesLindesay",
"license": "MIT"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cases/blocks-in-blocks.expected.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"type":"extends","line":1,"col":1}
{"type":"path","line":1,"col":9,"val":"./auxiliary/blocks-in-blocks-layout.jade"}
{"type":"path","line":1,"col":9,"val":"./auxiliary/blocks-in-blocks-layout.pug"}
{"type":"newline","line":3,"col":1}
{"type":"block","line":3,"col":1,"val":"body","mode":"replace"}
{"type":"indent","line":4,"col":1,"val":2}
Expand Down
4 changes: 0 additions & 4 deletions test/cases/blocks-in-blocks.jade

This file was deleted.

4 changes: 4 additions & 0 deletions test/cases/blocks-in-blocks.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends ./auxiliary/blocks-in-blocks-layout.pug

block body
h1 Page 2
2 changes: 1 addition & 1 deletion test/cases/blocks-in-if.expected.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"type":"comment","line":1,"col":1,"val":" see https://github.com/jadejs/jade/issues/1589","buffer":false}
{"type":"comment","line":1,"col":1,"val":" see https://github.com/pugjs/pug/issues/1589","buffer":false}
{"type":"newline","line":3,"col":1}
{"type":"code","line":3,"col":1,"val":"var ajax = true","mustEscape":false,"buffer":false}
{"type":"newline","line":5,"col":1}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//- see https://github.com/jadejs/jade/issues/1589
//- see https://github.com/pugjs/pug/issues/1589

-var ajax = true

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/cases/comments.source.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{"type":"text","line":3,"col":3,"val":""}
{"type":"end-pipeless-text","line":3,"col":3}
{"type":"newline","line":4,"col":1}
{"type":"comment","line":4,"col":1,"val":" test/cases/comments.source.jade","buffer":false}
{"type":"comment","line":4,"col":1,"val":" test/cases/comments.source.pug","buffer":false}
{"type":"newline","line":6,"col":1}
{"type":"comment","line":6,"col":1,"val":"","buffer":false}
{"type":"start-pipeless-text","line":6,"col":4}
{"type":"text","line":7,"col":3,"val":"test/cases/comments.source.jade"}
{"type":"text","line":7,"col":3,"val":"test/cases/comments.source.pug"}
{"type":"newline","line":8,"col":1}
{"type":"text","line":8,"col":3,"val":"when"}
{"type":"newline","line":9,"col":1}
Expand Down
9 changes: 0 additions & 9 deletions test/cases/comments.source.jade

This file was deleted.

9 changes: 9 additions & 0 deletions test/cases/comments.source.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//-
s/s.

//- test/cases/comments.source.pug

//-
test/cases/comments.source.pug
when
()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/cases/filters.inline.expected.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{"type":"tag","line":1,"col":1,"val":"p"}
{"type":"text","line":1,"col":3,"val":"before "}
{"type":"start-jade-interpolation","line":1,"col":10}
{"type":"start-pug-interpolation","line":1,"col":10}
{"type":"filter","line":1,"col":12,"val":"cdata"}
{"type":"text","line":1,"col":19,"val":"inside"}
{"type":"end-jade-interpolation","line":1,"col":25}
{"type":"end-pug-interpolation","line":1,"col":25}
{"type":"text","line":1,"col":26,"val":" after"}
{"type":"eos","line":1,"col":32}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cases/include-extends-from-root.expected.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"type":"include","line":1,"col":1}
{"type":"path","line":1,"col":9,"val":"/auxiliary/extends-from-root.jade"}
{"type":"path","line":1,"col":9,"val":"/auxiliary/extends-from-root.pug"}
{"type":"newline","line":2,"col":1}
{"type":"eos","line":2,"col":1}
1 change: 0 additions & 1 deletion test/cases/include-extends-from-root.jade

This file was deleted.

1 change: 1 addition & 0 deletions test/cases/include-extends-from-root.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include /auxiliary/extends-from-root.pug
4 changes: 2 additions & 2 deletions test/cases/include-extends-of-common-template.expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{"type":"include","line":1,"col":1}
{"type":"path","line":1,"col":9,"val":"auxiliary/extends-empty-block-1.jade"}
{"type":"path","line":1,"col":9,"val":"auxiliary/extends-empty-block-1.pug"}
{"type":"newline","line":2,"col":1}
{"type":"include","line":2,"col":1}
{"type":"path","line":2,"col":9,"val":"auxiliary/extends-empty-block-2.jade"}
{"type":"path","line":2,"col":9,"val":"auxiliary/extends-empty-block-2.pug"}
{"type":"newline","line":3,"col":1}
{"type":"eos","line":3,"col":1}
2 changes: 0 additions & 2 deletions test/cases/include-extends-of-common-template.jade

This file was deleted.

2 changes: 2 additions & 0 deletions test/cases/include-extends-of-common-template.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include auxiliary/extends-empty-block-1.pug
include auxiliary/extends-empty-block-2.pug
File renamed without changes.
2 changes: 1 addition & 1 deletion test/cases/include-only-text.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{"type":"tag","line":3,"col":5,"val":"p"}
{"type":"indent","line":4,"col":1,"val":6}
{"type":"include","line":4,"col":7}
{"type":"path","line":4,"col":15,"val":"include-only-text-body.jade"}
{"type":"path","line":4,"col":15,"val":"include-only-text-body.pug"}
{"type":"indent","line":5,"col":1,"val":8}
{"type":"tag","line":5,"col":9,"val":"em"}
{"type":"text","line":5,"col":12,"val":"hello world"}
Expand Down
5 changes: 0 additions & 5 deletions test/cases/include-only-text.jade

This file was deleted.

5 changes: 5 additions & 0 deletions test/cases/include-only-text.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
html
body
p
include include-only-text-body.pug
em hello world
2 changes: 1 addition & 1 deletion test/cases/include-with-text.expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{"type":"tag","line":1,"col":1,"val":"html"}
{"type":"indent","line":2,"col":1,"val":2}
{"type":"include","line":2,"col":3}
{"type":"path","line":2,"col":11,"val":"include-with-text-head.jade"}
{"type":"path","line":2,"col":11,"val":"include-with-text-head.pug"}
{"type":"indent","line":3,"col":1,"val":4}
{"type":"tag","line":3,"col":5,"val":"script"}
{"type":"start-attributes","line":3,"col":11}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
html
include include-with-text-head.jade
include include-with-text-head.pug
script(src='/caustic.js')
script(src='/app.js')
2 changes: 1 addition & 1 deletion test/cases/include.script.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
{"type":"end-attributes","line":1,"col":43}
{"type":"indent","line":2,"col":1,"val":2}
{"type":"include","line":2,"col":3}
{"type":"path","line":2,"col":11,"val":"auxiliary/pet.jade"}
{"type":"path","line":2,"col":11,"val":"auxiliary/pet.pug"}
{"type":"outdent","line":3,"col":1}
{"type":"eos","line":3,"col":1}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
script#pet-template(type='text/x-template')
include auxiliary/pet.jade
include auxiliary/pet.pug
2 changes: 1 addition & 1 deletion test/cases/include.yield.nested.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"include","line":2,"col":1}
{"type":"path","line":2,"col":9,"val":"auxiliary/yield-nested.jade"}
{"type":"path","line":2,"col":9,"val":"auxiliary/yield-nested.pug"}
{"type":"indent","line":3,"col":1,"val":2}
{"type":"tag","line":3,"col":3,"val":"p"}
{"type":"text","line":3,"col":5,"val":"some content"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

include auxiliary/yield-nested.jade
include auxiliary/yield-nested.pug
p some content
p and some more
2 changes: 1 addition & 1 deletion test/cases/includes.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"include","line":2,"col":1}
{"type":"path","line":2,"col":9,"val":"auxiliary/mixins.jade"}
{"type":"path","line":2,"col":9,"val":"auxiliary/mixins.pug"}
{"type":"newline","line":4,"col":1}
{"type":"call","line":4,"col":1,"val":"foo","args":null}
{"type":"newline","line":6,"col":1}
Expand Down
2 changes: 1 addition & 1 deletion test/cases/includes.jade → test/cases/includes.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

include auxiliary/mixins.jade
include auxiliary/mixins.pug

+foo

Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.alert-dialog.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":9,"val":"auxiliary/dialog.jade"}
{"type":"path","line":2,"col":9,"val":"auxiliary/dialog.pug"}
{"type":"newline","line":4,"col":1}
{"type":"block","line":4,"col":1,"val":"content","mode":"replace"}
{"type":"indent","line":5,"col":1,"val":2}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

extends auxiliary/dialog.jade
extends auxiliary/dialog.pug

block content
h1 Alert!
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":9,"val":"auxiliary/layout.jade"}
{"type":"path","line":2,"col":9,"val":"auxiliary/layout.pug"}
{"type":"newline","line":4,"col":1}
{"type":"block","line":4,"col":1,"val":"head","mode":"replace"}
{"type":"indent","line":5,"col":1,"val":2}
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.jade"}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.pug"}
{"type":"newline","line":4,"col":1}
{"type":"block","line":4,"col":1,"val":"head","mode":"replace"}
{"type":"indent","line":5,"col":1,"val":2}
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.include.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.include.jade"}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.include.pug"}
{"type":"newline","line":4,"col":1}
{"type":"block","line":4,"col":1,"val":"head","mode":"replace"}
{"type":"indent","line":5,"col":1,"val":2}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

extend auxiliary/layout.include.jade
extend auxiliary/layout.include.pug

block head
script(src='jquery.js')
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.mixins.block.expected.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"type":"extends","line":1,"col":1}
{"type":"path","line":1,"col":8,"val":"auxiliary/inheritance.extend.mixin.block.jade"}
{"type":"path","line":1,"col":8,"val":"auxiliary/inheritance.extend.mixin.block.pug"}
{"type":"newline","line":3,"col":1}
{"type":"block","line":3,"col":1,"val":"content","mode":"replace"}
{"type":"indent","line":4,"col":1,"val":2}
Expand Down
4 changes: 0 additions & 4 deletions test/cases/inheritance.extend.mixins.block.jade

This file was deleted.

4 changes: 4 additions & 0 deletions test/cases/inheritance.extend.mixins.block.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extend auxiliary/inheritance.extend.mixin.block.pug

block content
p Hello World!
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.mixins.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.jade"}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.pug"}
{"type":"newline","line":4,"col":1}
{"type":"mixin","line":4,"col":1,"val":"article","args":"title"}
{"type":"indent","line":5,"col":1,"val":2}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

extend auxiliary/layout.jade
extend auxiliary/layout.pug

mixin article(title)
if title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

extend auxiliary/layout.jade
extend auxiliary/layout.pug

block head
script(src='jquery.js')
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.recursive.expected.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"type":"extends","line":1,"col":1}
{"type":"path","line":1,"col":9,"val":"/auxiliary/inheritance.extend.recursive-parent.jade"}
{"type":"path","line":1,"col":9,"val":"/auxiliary/inheritance.extend.recursive-parent.pug"}
{"type":"newline","line":3,"col":1}
{"type":"block","line":3,"col":1,"val":"parent","mode":"replace"}
{"type":"indent","line":4,"col":1,"val":4}
Expand Down
4 changes: 0 additions & 4 deletions test/cases/inheritance.extend.recursive.jade

This file was deleted.

4 changes: 4 additions & 0 deletions test/cases/inheritance.extend.recursive.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends /auxiliary/inheritance.extend.recursive-parent.pug

block parent
h4 child
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.whitespace.expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{"type":"newline","line":2,"col":1}
{"type":"extends","line":2,"col":1}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.jade"}
{"type":"path","line":2,"col":8,"val":"auxiliary/layout.pug"}
{"type":"newline","line":4,"col":1}
{"type":"block","line":4,"col":1,"val":"head","mode":"replace"}
{"type":"indent","line":6,"col":1,"val":2}
Expand Down
Loading