Skip to content

Commit 33fa57e

Browse files
committed
Add missing inline tags
1 parent 6cca8f7 commit 33fa57e

File tree

8 files changed

+68
-51
lines changed

8 files changed

+68
-51
lines changed

packages/pug-parser/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ var assert = require('assert');
44
var TokenStream = require('token-stream');
55
var error = require('pug-error');
66
var inlineTags = require('./lib/inline-tags');
7+
var inlineTagsObj = {};
8+
inlineTags.forEach(
9+
function (tag) {
10+
inlineTagsObj[tag] = true;
11+
}
12+
);
713

814
module.exports = parse;
915
module.exports.Parser = Parser;
@@ -1117,7 +1123,7 @@ Parser.prototype = {
11171123
block: this.emptyBlock(tok.loc.start.line),
11181124
attrs: [],
11191125
attributeBlocks: [],
1120-
isInline: inlineTags.indexOf(tok.val) !== -1,
1126+
isInline: inlineTagsObj.hasOwnProperty(tok.val),
11211127
line: tok.loc.start.line,
11221128
column: tok.loc.start.column,
11231129
filename: this.filename,

packages/pug-parser/lib/inline-tags.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,53 @@ module.exports = [
55
'abbr',
66
'acronym',
77
'b',
8+
'bdi',
9+
'bdo',
10+
'big',
811
'br',
12+
'button',
13+
'canvas',
14+
'cite',
915
'code',
16+
'data',
17+
'datalist',
18+
'del',
19+
'dfn',
1020
'em',
21+
'embed',
1122
'font',
1223
'i',
24+
'iframe',
1325
'img',
26+
'input',
1427
'ins',
1528
'kbd',
29+
'label',
1630
'map',
31+
'mark',
32+
'meter',
33+
'noscript',
34+
'object',
35+
'output',
36+
'picture',
37+
'progress',
38+
'ruby',
39+
's',
1740
'samp',
41+
'select',
42+
'slot',
1843
'small',
1944
'span',
2045
'strong',
46+
'svg',
2147
'sub',
2248
'sup',
49+
'template',
50+
'textarea',
51+
'time',
52+
'u',
53+
'tt',
54+
'var',
55+
'video',
56+
'wbr',
2357
];

packages/pug-parser/test/__snapshots__/index.test.js.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ Object {
784784
},
785785
"column": 1,
786786
"filename": "attrs.tokens.json",
787-
"isInline": false,
787+
"isInline": true,
788788
"line": 6,
789789
"name": "select",
790790
"selfClosing": false,
@@ -836,7 +836,7 @@ Object {
836836
},
837837
"column": 1,
838838
"filename": "attrs.tokens.json",
839-
"isInline": false,
839+
"isInline": true,
840840
"line": 10,
841841
"name": "input",
842842
"selfClosing": false,
@@ -1124,7 +1124,7 @@ Object {
11241124
},
11251125
"column": 1,
11261126
"filename": "attrs.tokens.json",
1127-
"isInline": false,
1127+
"isInline": true,
11281128
"line": 17,
11291129
"name": "select",
11301130
"selfClosing": false,
@@ -1176,7 +1176,7 @@ Object {
11761176
},
11771177
"column": 1,
11781178
"filename": "attrs.tokens.json",
1179-
"isInline": false,
1179+
"isInline": true,
11801180
"line": 21,
11811181
"name": "input",
11821182
"selfClosing": false,
@@ -6697,7 +6697,7 @@ Object {
66976697
},
66986698
"column": 9,
66996699
"filename": "escape-test.tokens.json",
6700-
"isInline": false,
6700+
"isInline": true,
67016701
"line": 6,
67026702
"name": "textarea",
67036703
"selfClosing": false,
@@ -8371,7 +8371,7 @@ Object {
83718371
},
83728372
"column": 1,
83738373
"filename": "html5.tokens.json",
8374-
"isInline": false,
8374+
"isInline": true,
83758375
"line": 2,
83768376
"name": "input",
83778377
"selfClosing": false,
@@ -8405,7 +8405,7 @@ Object {
84058405
},
84068406
"column": 1,
84078407
"filename": "html5.tokens.json",
8408-
"isInline": false,
8408+
"isInline": true,
84098409
"line": 3,
84108410
"name": "input",
84118411
"selfClosing": false,
@@ -8439,7 +8439,7 @@ Object {
84398439
},
84408440
"column": 1,
84418441
"filename": "html5.tokens.json",
8442-
"isInline": false,
8442+
"isInline": true,
84438443
"line": 4,
84448444
"name": "input",
84458445
"selfClosing": false,
@@ -13405,7 +13405,7 @@ Object {
1340513405
},
1340613406
"column": 5,
1340713407
"filename": "mixin.blocks.tokens.json",
13408-
"isInline": false,
13408+
"isInline": true,
1340913409
"line": 6,
1341013410
"name": "input",
1341113411
"selfClosing": false,
@@ -13496,7 +13496,7 @@ Object {
1349613496
},
1349713497
"column": 7,
1349813498
"filename": "mixin.blocks.tokens.json",
13499-
"isInline": false,
13499+
"isInline": true,
1350013500
"line": 12,
1350113501
"name": "input",
1350213502
"selfClosing": false,
@@ -13530,7 +13530,7 @@ Object {
1353013530
},
1353113531
"column": 7,
1353213532
"filename": "mixin.blocks.tokens.json",
13533-
"isInline": false,
13533+
"isInline": true,
1353413534
"line": 13,
1353513535
"name": "input",
1353613536
"selfClosing": false,
@@ -13626,7 +13626,7 @@ Object {
1362613626
},
1362713627
"column": 7,
1362813628
"filename": "mixin.blocks.tokens.json",
13629-
"isInline": false,
13629+
"isInline": true,
1363013630
"line": 18,
1363113631
"name": "input",
1363213632
"selfClosing": false,
@@ -13660,7 +13660,7 @@ Object {
1366013660
},
1366113661
"column": 7,
1366213662
"filename": "mixin.blocks.tokens.json",
13663-
"isInline": false,
13663+
"isInline": true,
1366413664
"line": 19,
1366513665
"name": "input",
1366613666
"selfClosing": false,
@@ -18913,7 +18913,7 @@ Object {
1891318913
},
1891418914
"column": 3,
1891518915
"filename": "text-block.tokens.json",
18916-
"isInline": false,
18916+
"isInline": true,
1891718917
"line": 3,
1891818918
"name": "input",
1891918919
"selfClosing": false,
@@ -18924,7 +18924,7 @@ Object {
1892418924
},
1892518925
"column": 1,
1892618926
"filename": "text-block.tokens.json",
18927-
"isInline": false,
18927+
"isInline": true,
1892818928
"line": 2,
1892918929
"name": "label",
1893018930
"selfClosing": false,
@@ -18972,7 +18972,7 @@ Object {
1897218972
},
1897318973
"column": 3,
1897418974
"filename": "text-block.tokens.json",
18975-
"isInline": false,
18975+
"isInline": true,
1897618976
"line": 6,
1897718977
"name": "input",
1897818978
"selfClosing": false,
@@ -18983,7 +18983,7 @@ Object {
1898318983
},
1898418984
"column": 1,
1898518985
"filename": "text-block.tokens.json",
18986-
"isInline": false,
18986+
"isInline": true,
1898718987
"line": 5,
1898818988
"name": "label",
1898918989
"selfClosing": false,

packages/pug/test/cases/attrs.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
<a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
2-
<select>
1+
<a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a><select>
32
<option value="foo" selected="selected">Foo</option>
4-
<option selected="selected" value="bar">Bar</option>
5-
</select><a foo="class:"></a>
6-
<input pattern="\S+"/><a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a>
7-
<select>
3+
<option selected="selected" value="bar">Bar</option></select><a foo="class:"></a><input pattern="\S+"/><a href="/contact">contact</a><a class="button" href="/save">save</a><a foo="foo" bar="bar" baz="baz"></a><a foo="foo, bar, baz" bar="1"></a><a foo="((foo))" bar="1"></a><select>
84
<option value="foo" selected="selected">Foo</option>
9-
<option selected="selected" value="bar">Bar</option>
10-
</select><a foo="class:"></a>
11-
<input pattern="\S+"/>
5+
<option selected="selected" value="bar">Bar</option></select><a foo="class:"></a><input pattern="\S+"/>
126
<foo terse="true"></foo>
137
<foo date="1970-01-01T00:00:00.000Z"></foo>
148
<foo abc="abc" def="def"></foo>

packages/pug/test/cases/escape-test.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
<head>
44
<title>escape-test</title>
55
</head>
6-
<body>
7-
<textarea>&lt;param name=&quot;flashvars&quot; value=&quot;a=&amp;quot;value_a&amp;quot;&amp;b=&amp;quot;value_b&amp;quot;&amp;c=3&quot;/&gt;</textarea>
8-
</body>
6+
<body><textarea>&lt;param name=&quot;flashvars&quot; value=&quot;a=&amp;quot;value_a&amp;quot;&amp;b=&amp;quot;value_b&amp;quot;&amp;c=3&quot;/&gt;</textarea></body>
97
</html>

packages/pug/test/cases/html5.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
<!DOCTYPE html>
2-
<input type="checkbox" checked>
3-
<input type="checkbox" checked>
4-
<input type="checkbox">
1+
<!DOCTYPE html><input type="checkbox" checked><input type="checkbox" checked><input type="checkbox">
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
<html>
22
<body>
3-
<form method="GET" action="/search">
4-
<input type="hidden" name="_csrf" value="hey"/>
5-
<input type="text" name="query" placeholder="Search"/>
6-
<input type="submit" value="Search"/>
3+
<form method="GET" action="/search"><input type="hidden" name="_csrf" value="hey"/><input type="text" name="query" placeholder="Search"/><input type="submit" value="Search"/>
74
</form>
85
</body>
96
</html>
107
<html>
118
<body>
12-
<form method="POST" action="/search">
13-
<input type="hidden" name="_csrf" value="hey"/>
14-
<input type="text" name="query" placeholder="Search"/>
15-
<input type="submit" value="Search"/>
9+
<form method="POST" action="/search"><input type="hidden" name="_csrf" value="hey"/><input type="text" name="query" placeholder="Search"/><input type="submit" value="Search"/>
1610
</form>
1711
</body>
1812
</html>
1913
<html>
2014
<body>
21-
<form method="POST" action="/search">
22-
<input type="hidden" name="_csrf" value="hey"/>
15+
<form method="POST" action="/search"><input type="hidden" name="_csrf" value="hey"/>
2316
</form>
2417
</body>
2518
</html>
@@ -31,4 +24,4 @@
3124
</div>
3225
</div>
3326
<div id="baz">123
34-
</div>
27+
</div>
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
<label>Username:
2-
<input type="text" name="user[name]"/>
3-
</label>
4-
<label>Password:
5-
<input type="text" name="user[pass]"/>
6-
</label>
1+
<label>Username:<input type="text" name="user[name]"/></label><label>Password:<input type="text" name="user[pass]"/></label>

0 commit comments

Comments
 (0)