Permalink
Browse files

Adding newline when using tag code when preceding text

  • Loading branch information...
1 parent 8ab8ce8 commit 4e6f77c31726f73780d62dcd84fe559e8d24b16c @tj tj committed Oct 12, 2010
Showing with 6 additions and 2 deletions.
  1. +4 −1 lib/parser.js
  2. +2 −1 test/jade.test.js
View
@@ -336,7 +336,10 @@ Parser.prototype = {
while (this.peek.type === 'newline') this.advance;
// Assume newline when tag followed by text
- if (tag.text && this.peek.type === 'text') tag.text.push('\\n');
+ if (this.peek.type === 'text') {
+ if (tag.text) tag.text.push('\\n');
+ else tag.text = new nodes.Text('\\n');
+ }
// block?
if (this.peek.type === 'indent') {
View
@@ -272,7 +272,7 @@ module.exports = {
assert.equal(html, render(str));
assert.equal('<foo></foo>something<bar></bar>', render('foo\n= "something"\nbar'));
- assert.equal('<foo></foo>"something"\n<bar></bar>', render('foo\n"something"\nbar'));
+ assert.equal('<foo>\n</foo>"something"\n<bar></bar>', render('foo\n"something"\nbar'));
assert.equal('<foo></foo>something<bar></bar>else', render('foo\n= "something"\nbar\n= "else"'));
},
@@ -575,6 +575,7 @@ module.exports = {
assert.equal('test', render('!= "test"'));
assert.equal('test', render('= "test"'));
assert.equal('test', render('- var foo = "test"\n=foo'));
+ assert.equal('foo\n<em>test\n</em>bar\n', render('- var foo = "test"\n| foo\nem= foo\n| bar'));
assert.equal('test<h2>something</h2>', render('!= "test"\nh2 something'));
var str = [

0 comments on commit 4e6f77c

Please sign in to comment.