Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

Rename to pug-parser #25

Merged
merged 1 commit 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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# jade-parser
# pug-parser

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

[![Build Status](https://img.shields.io/travis/jadejs/jade-parser/master.svg)](https://travis-ci.org/jadejs/jade-parser)
[![Dependency Status](https://img.shields.io/gemnasium/jadejs/jade-parser.svg)](https://gemnasium.com/jadejs/jade-parser)
[![NPM version](https://img.shields.io/npm/v/jade-parser.svg)](https://www.npmjs.org/package/jade-parser)
[![Build Status](https://img.shields.io/travis/pugjs/pug-parser/master.svg)](https://travis-ci.org/pugjs/pug-parser)
[![Dependency Status](https://img.shields.io/gemnasium/pugjs/pug-parser.svg)](https://gemnasium.com/pugjs/pug-parser)
[![NPM version](https://img.shields.io/npm/v/pug-parser.svg)](https://www.npmjs.org/package/pug-parser)

## Installation

npm install jade-parser
npm install pug-parser

## License

Expand Down
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var assert = require('assert');
var TokenStream = require('token-stream');
var error = require('jade-error');
var error = require('pug-error');
var inlineTags = require('./lib/inline-tags');

module.exports = parse;
Expand Down Expand Up @@ -211,7 +211,7 @@ Parser.prototype = {
return this.parseComment();
case 'text':
case 'interpolated-code':
case 'start-jade-interpolation':
case 'start-pug-interpolation':
return this.parseText({block: true});
case 'text-html':
return this.initBlock(this.peek().line, this.parseTextHtml());
Expand Down Expand Up @@ -298,10 +298,10 @@ Parser.prototype = {
});
}
break;
case 'start-jade-interpolation':
case 'start-pug-interpolation':
this.advance();
tags.push(this.parseExpr());
this.expect('end-jade-interpolation');
this.expect('end-pug-interpolation');
break;
default:
var pluginResult = this.runPlugin('textTokens', nextTok, tags);
Expand Down Expand Up @@ -463,7 +463,7 @@ loop:

parseCode: function(noBlock){
var tok = this.expect('code');
assert(typeof tok.mustEscape === 'boolean', 'Please update to the newest version of jade-lexer.');
assert(typeof tok.mustEscape === 'boolean', 'Please update to the newest version of pug-lexer.');
var node = {
type: 'Code',
val: tok.val,
Expand Down Expand Up @@ -789,7 +789,7 @@ loop:

node.file.path = path.val.trim();

if (/\.jade$/.test(node.file.path) && !filters.length) {
if (/\.pug$/.test(node.file.path) && !filters.length) {
node.block = 'indent' == this.peek().type ? this.block() : this.emptyBlock(tok.line);
} else {
node.type = 'RawInclude';
Expand Down Expand Up @@ -874,9 +874,9 @@ loop:
case 'newline':
block.nodes.push({type: 'Text', val: '\n', line: tok.line});
break;
case 'start-jade-interpolation':
case 'start-pug-interpolation':
block.nodes.push(this.parseExpr());
this.expect('end-jade-interpolation');
this.expect('end-pug-interpolation');
break;
case 'interpolated-code':
block.nodes.push({
Expand Down Expand Up @@ -991,7 +991,7 @@ loop:
continue;
case 'start-attributes':
if (seenAttrs) {
console.warn(this.filename + ', line ' + this.peek().line + ':\nYou should not have jade tags with multiple attributes.');
console.warn(this.filename + ', line ' + this.peek().line + ':\nYou should not have pug tags with multiple attributes.');
}
seenAttrs = true;
tag.attrs = tag.attrs.concat(this.attrs(attributeNames));
Expand Down Expand Up @@ -1036,7 +1036,7 @@ loop:
case 'outdent':
case 'eos':
case 'start-pipeless-text':
case 'end-jade-interpolation':
case 'end-pug-interpolation':
break;
case 'slash':
if (selfClosingAllowed) {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "jade-parser",
"name": "pug-parser",
"version": "0.0.9",
"description": "The jade parser (takes an array of tokens and converts it to an abstract syntax tree)",
"description": "The pug parser (takes an array of tokens and converts it to an abstract syntax tree)",
"keywords": [
"jade"
"pug"
],
"dependencies": {
"jade-error": "^1.0.0",
"pug-error": "^1.3.0",
"token-stream": "0.0.1"
},
"devDependencies": {
Expand All @@ -20,7 +20,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jadejs/jade-parser.git"
"url": "https://github.com/pugjs/pug-parser.git"
},
"author": "ForbesLindesay",
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion test/cases/blocks-in-blocks.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "./auxiliary/blocks-in-blocks-layout.jade",
"path": "./auxiliary/blocks-in-blocks-layout.pug",
"line": 1,
"filename": "blocks-in-blocks.tokens.json"
},
Expand Down
2 changes: 1 addition & 1 deletion test/cases/blocks-in-blocks.tokens.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
2 changes: 1 addition & 1 deletion test/cases/blocks-in-if.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"nodes": [
{
"type": "Comment",
"val": " see https://github.com/jadejs/jade/issues/1589",
"val": " see https://github.com/pugjs/pug/issues/1589",
"buffer": false,
"line": 1,
"filename": "blocks-in-if.tokens.json"
Expand Down
2 changes: 1 addition & 1 deletion test/cases/blocks-in-if.tokens.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
4 changes: 2 additions & 2 deletions test/cases/comments.source.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"type": "Comment",
"val": " test/cases/comments.source.jade",
"val": " test/cases/comments.source.pug",
"buffer": false,
"line": 4,
"filename": "comments.source.tokens.json"
Expand All @@ -45,7 +45,7 @@
"nodes": [
{
"type": "Text",
"val": "test/cases/comments.source.jade",
"val": "test/cases/comments.source.pug",
"line": 7
},
{
Expand Down
4 changes: 2 additions & 2 deletions test/cases/comments.source.tokens.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
4 changes: 2 additions & 2 deletions test/cases/filters.inline.tokens.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}
2 changes: 1 addition & 1 deletion test/cases/include-extends-from-root.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "FileReference",
"line": 1,
"filename": "include-extends-from-root.tokens.json",
"path": "/auxiliary/extends-from-root.jade"
"path": "/auxiliary/extends-from-root.pug"
},
"line": 1,
"filename": "include-extends-from-root.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/include-extends-from-root.tokens.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}
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
Expand Up @@ -7,7 +7,7 @@
"type": "FileReference",
"line": 1,
"filename": "include-extends-of-common-template.tokens.json",
"path": "auxiliary/extends-empty-block-1.jade"
"path": "auxiliary/extends-empty-block-1.pug"
},
"line": 1,
"filename": "include-extends-of-common-template.tokens.json",
Expand All @@ -24,7 +24,7 @@
"type": "FileReference",
"line": 2,
"filename": "include-extends-of-common-template.tokens.json",
"path": "auxiliary/extends-empty-block-2.jade"
"path": "auxiliary/extends-empty-block-2.pug"
},
"line": 2,
"filename": "include-extends-of-common-template.tokens.json",
Expand Down
4 changes: 2 additions & 2 deletions test/cases/include-extends-of-common-template.tokens.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: 1 addition & 1 deletion test/cases/include-only-text.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type": "FileReference",
"line": 4,
"filename": "include-only-text.tokens.json",
"path": "include-only-text-body.jade"
"path": "include-only-text-body.pug"
},
"line": 4,
"filename": "include-only-text.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/include-only-text.tokens.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
2 changes: 1 addition & 1 deletion test/cases/include-with-text.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "FileReference",
"line": 2,
"filename": "include-with-text.tokens.json",
"path": "include-with-text-head.jade"
"path": "include-with-text-head.pug"
},
"line": 2,
"filename": "include-with-text.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/include-with-text.tokens.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
2 changes: 1 addition & 1 deletion test/cases/include.script.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "FileReference",
"line": 2,
"filename": "include.script.tokens.json",
"path": "auxiliary/pet.jade"
"path": "auxiliary/pet.pug"
},
"line": 2,
"filename": "include.script.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/include.script.tokens.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}
2 changes: 1 addition & 1 deletion test/cases/include.yield.nested.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "FileReference",
"line": 2,
"filename": "include.yield.nested.tokens.json",
"path": "auxiliary/yield-nested.jade"
"path": "auxiliary/yield-nested.pug"
},
"line": 2,
"filename": "include.yield.nested.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/include.yield.nested.tokens.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
2 changes: 1 addition & 1 deletion test/cases/includes.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "FileReference",
"line": 2,
"filename": "includes.tokens.json",
"path": "auxiliary/mixins.jade"
"path": "auxiliary/mixins.pug"
},
"line": 2,
"filename": "includes.tokens.json",
Expand Down
2 changes: 1 addition & 1 deletion test/cases/includes.tokens.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/inheritance.alert-dialog.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "auxiliary/dialog.jade",
"path": "auxiliary/dialog.pug",
"line": 2,
"filename": "inheritance.alert-dialog.tokens.json"
},
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.alert-dialog.tokens.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
2 changes: 1 addition & 1 deletion test/cases/inheritance.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "auxiliary/layout.jade",
"path": "auxiliary/layout.pug",
"line": 2,
"filename": "inheritance.tokens.json"
},
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "auxiliary/layout.jade",
"path": "auxiliary/layout.pug",
"line": 2,
"filename": "inheritance.extend.tokens.json"
},
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
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "auxiliary/layout.include.jade",
"path": "auxiliary/layout.include.pug",
"line": 2,
"filename": "inheritance.extend.include.tokens.json"
},
Expand Down
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.include.tokens.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
2 changes: 1 addition & 1 deletion test/cases/inheritance.extend.mixins.block.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "Extends",
"file": {
"type": "FileReference",
"path": "auxiliary/inheritance.extend.mixin.block.jade",
"path": "auxiliary/inheritance.extend.mixin.block.pug",
"line": 1,
"filename": "inheritance.extend.mixins.block.tokens.json"
},
Expand Down
Loading