corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 /*
2 The MIT License (MIT)
3  
4 Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors.
5  
6 Permission is hereby granted, free of charge, to any person
7 obtaining a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13  
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16  
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 */
26  
27 exports.test_data = {
28 default_options: [
29 { name: "indent_size", value: "4" },
30 { name: "indent_char", value: "' '" },
31 { name: "indent_with_tabs", value: "false" },
32 { name: "preserve_newlines", value: "true" },
33 { name: "jslint_happy", value: "false" },
34 { name: "keep_array_indentation", value: "false" },
35 { name: "brace_style", value: "'collapse'" },
36 { name: "extra_liners", value: "['html', 'head', '/html']" }
37 ],
38 groups: [{
39 name: "Handle inline and block elements differently",
40 description: "",
41 matrix: [{}],
42 tests: [{
43 fragment: true,
44 input: '<body><h1>Block</h1></body>',
45 output: [
46 '<body>',
47 ' <h1>Block</h1>',
48 '</body>'
49 ]
50 }, {
51 fragment: true,
52 unchanged: '<body><i>Inline</i></body>'
53 }]
54 }, {
55 name: "End With Newline",
56 description: "",
57 matrix: [{
58 options: [
59 { name: "end_with_newline", value: "true" }
60 ],
61 eof: '\n'
62 }, {
63 options: [
64 { name: "end_with_newline", value: "false" }
65 ],
66 eof: ''
67 }
68  
69 ],
70 tests: [
71 { fragment: true, input: '', output: '{{eof}}' },
72 { fragment: true, input: '<div></div>', output: '<div></div>{{eof}}' },
73 // { fragment: true, input: ' \n\n<div></div>\n\n\n\n', output: ' <div></div>{{eof}}' },
74 { fragment: true, input: '\n', output: '{{eof}}' }
75 ],
76 }, {
77 name: "Custom Extra Liners (empty)",
78 description: "",
79 matrix: [{
80 options: [
81 { name: "extra_liners", value: "[]" }
82 ]
83 },
84  
85 ],
86 tests: [{
87 fragment: true,
88 input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
89 output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n <p>x</p>\n </div>\n</body>\n</html>'
90 }],
91 }, {
92 name: "Custom Extra Liners (default)",
93 description: "",
94 matrix: [{
95 options: [
96 { name: "extra_liners", value: "null" }
97 ]
98 },
99  
100 ],
101 tests: [{
102 fragment: true,
103 input: '<html><head></head><body></body></html>',
104 output: '<html>\n\n<head></head>\n\n<body></body>\n\n</html>'
105 }],
106 }, {
107 name: "Custom Extra Liners (p, string)",
108 description: "",
109 matrix: [{
110 options: [
111 { name: "extra_liners", value: "'p,/p'" }
112 ]
113 },
114  
115 ],
116 tests: [{
117 fragment: true,
118 input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
119 output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n\n <p>x\n\n </p>\n </div>\n</body>\n</html>'
120 }],
121 }, {
122 name: "Custom Extra Liners (p)",
123 description: "",
124 matrix: [{
125 options: [
126 { name: "extra_liners", value: "['p', '/p']" }
127 ]
128 },
129  
130 ],
131 tests: [{
132 fragment: true,
133 input: '<html><head><meta></head><body><div><p>x</p></div></body></html>',
134 output: '<html>\n<head>\n <meta>\n</head>\n<body>\n <div>\n\n <p>x\n\n </p>\n </div>\n</body>\n</html>'
135 }],
136 }, {
137 name: "Tests for script and style types (issue 453, 821)",
138 description: "Only format recognized script types",
139 tests: [{
140 input: '<script type="text/unknown"><div></div></script>',
141 output: [
142 '<script type="text/unknown">',
143 ' <div></div>',
144 '</script>'
145 ]
146 }, {
147 input: '<script type="text/javascript"><div></div></script>',
148 output: [
149 '<script type="text/javascript">',
150 ' < div > < /div>',
151 '</script>'
152 ]
153 }, {
154 input: '<script><div></div></script>',
155 output: [
156 '<script>',
157 ' < div > < /div>',
158 '</script>'
159 ]
160 }, {
161 input: '<script>var foo = "bar";</script>',
162 output: [
163 '<script>',
164 ' var foo = "bar";',
165 '</script>'
166 ]
167 }, {
168 input: '<script type="text/javascript">var foo = "bar";</script>',
169 output: [
170 '<script type="text/javascript">',
171 ' var foo = "bar";',
172 '</script>'
173 ]
174 }, {
175 input: '<script type="application/javascript">var foo = "bar";</script>',
176 output: [
177 '<script type="application/javascript">',
178 ' var foo = "bar";',
179 '</script>'
180 ]
181 }, {
182 input: '<script type="application/javascript;version=1.8">var foo = "bar";</script>',
183 output: [
184 '<script type="application/javascript;version=1.8">',
185 ' var foo = "bar";',
186 '</script>'
187 ]
188 }, {
189 input: '<script type="application/x-javascript">var foo = "bar";</script>',
190 output: [
191 '<script type="application/x-javascript">',
192 ' var foo = "bar";',
193 '</script>'
194 ]
195 }, {
196 input: '<script type="application/ecmascript">var foo = "bar";</script>',
197 output: [
198 '<script type="application/ecmascript">',
199 ' var foo = "bar";',
200 '</script>'
201 ]
202 }, {
203 input: '<script type="dojo/aspect">this.domNode.style.display="none";</script>',
204 output: [
205 '<script type="dojo/aspect">',
206 ' this.domNode.style.display = "none";',
207 '</script>'
208 ]
209 }, {
210 input: '<script type="dojo/method">this.domNode.style.display="none";</script>',
211 output: [
212 '<script type="dojo/method">',
213 ' this.domNode.style.display = "none";',
214 '</script>'
215 ]
216 }, {
217 input: '<script type="text/javascript1.5">var foo = "bar";</script>',
218 output: [
219 '<script type="text/javascript1.5">',
220 ' var foo = "bar";',
221 '</script>'
222 ]
223 }, {
224 input: '<script type="application/json">{"foo":"bar"}</script>',
225 output: [
226 '<script type="application/json">',
227 ' {',
228 ' "foo": "bar"',
229 ' }',
230 '</script>'
231 ]
232 }, {
233 input: '<script type="application/ld+json">{"foo":"bar"}</script>',
234 output: [
235 '<script type="application/ld+json">',
236 ' {',
237 ' "foo": "bar"',
238 ' }',
239 '</script>'
240 ]
241 }, {
242 input: '<style type="text/unknown"><tag></tag></style>',
243 output: [
244 '<style type="text/unknown">',
245 ' <tag></tag>',
246 '</style>'
247 ]
248 }, {
249 input: '<style type="text/css"><tag></tag></style>',
250 output: [
251 '<style type="text/css">',
252 ' <tag></tag>',
253 '</style>'
254 ]
255 }, {
256 input: '<style><tag></tag></style>',
257 output: [
258 '<style>',
259 ' <tag></tag>',
260 '</style>'
261 ]
262 }, {
263 input: '<style>.selector {font-size:12px;}</style>',
264 output: [
265 '<style>',
266 ' .selector {',
267 ' font-size: 12px;',
268 ' }',
269 '</style>'
270 ]
271 }, {
272 input: '<style type="text/css">.selector {font-size:12px;}</style>',
273 output: [
274 '<style type="text/css">',
275 ' .selector {',
276 ' font-size: 12px;',
277 ' }',
278 '</style>'
279 ]
280 },
281  
282 ],
283 }, {
284 name: "Attribute Wrap alignment with spaces",
285 description: "Ensure attributes are internally aligned with spaces when the indent_character is set to tab",
286 matrix: [{
287 options: [
288 { name: "wrap_attributes", value: "'force-aligned'" },
289 { name: "indent_with_tabs", value: "true" }
290 ]
291 }],
292 tests: [{
293 fragment: true,
294 input: '<div><div a="1" b="2"><div>test</div></div></div>',
295 output: '<div>\n\t<div a="1"\n\t b="2">\n\t\t<div>test</div>\n\t</div>\n</div>'
296 }]
297 }, {
298 name: "Attribute Wrap de-indent",
299 description: "Tags de-indent when attributes are wrapped",
300 matrix: [{
301 options: [
302 { name: "wrap_attributes", value: "'force-aligned'" },
303 { name: "indent_with_tabs", value: "false" }
304 ]
305 }],
306 tests: [{
307 fragment: true,
308 input: '<div a="1" b="2"><div>test</div></div>',
309 output: '<div a="1"\n b="2">\n <div>test</div>\n</div>'
310 },
311 {
312 fragment: true,
313 input: '<p>\n <a href="/test/" target="_blank"><img src="test.jpg" /></a><a href="/test/" target="_blank"><img src="test.jpg" /></a>\n</p>',
314 output: '<p>\n <a href="/test/"\n target="_blank"><img src="test.jpg" /></a><a href="/test/"\n target="_blank"><img src="test.jpg" /></a>\n</p>'
315 },
316 {
317 fragment: true,
318 input: '<p>\n <span data-not-a-href="/test/" data-totally-not-a-target="_blank"><img src="test.jpg" /></span><span data-not-a-href="/test/" data-totally-not-a-target="_blank"><img src="test.jpg" /></span>\n</p>',
319 output: '<p>\n <span data-not-a-href="/test/"\n data-totally-not-a-target="_blank"><img src="test.jpg" /></span><span data-not-a-href="/test/"\n data-totally-not-a-target="_blank"><img src="test.jpg" /></span>\n</p>'
320 }
321 ]
322 }, {
323 name: "Attribute Wrap",
324 description: "Wraps attributes inside of html tags",
325 matrix: [{
326 options: [
327 { name: "wrap_attributes", value: "'force'" }
328 ],
329 indent_attr: '\n ',
330 indent_attr_first: ' ',
331 indent_end: '',
332 indent_end_selfclosing: ' ',
333 indent_over80: '\n '
334 }, {
335 options: [
336 { name: "wrap_attributes", value: "'force'" },
337 { name: "wrap_line_length", value: "80" }
338 ],
339 indent_attr: '\n ',
340 indent_attr_first: ' ',
341 indent_end: '',
342 indent_end_selfclosing: ' ',
343 indent_over80: '\n '
344 }, {
345 options: [
346 { name: "wrap_attributes", value: "'force'" },
347 { name: "wrap_attributes_indent_size", value: "8" }
348 ],
349 indent_attr: '\n ',
350 indent_attr_first: ' ',
351 indent_end: '',
352 indent_end_selfclosing: ' ',
353 indent_over80: '\n '
354 }, {
355 options: [
356 { name: "wrap_attributes", value: "'auto'" },
357 { name: "wrap_line_length", value: "80" },
358 { name: "wrap_attributes_indent_size", value: "0" }
359 ],
360 indent_attr: ' ',
361 indent_attr_first: ' ',
362 indent_end: '',
363 indent_end_selfclosing: ' ',
364 indent_over80: '\n'
365 }, {
366 options: [
367 { name: "wrap_attributes", value: "'auto'" },
368 { name: "wrap_line_length", value: "80" },
369 { name: "wrap_attributes_indent_size", value: "4" }
370 ],
371 indent_attr: ' ',
372 indent_attr_first: ' ',
373 indent_end: '',
374 indent_end_selfclosing: ' ',
375 indent_over80: '\n '
376 }, {
377 options: [
378 { name: "wrap_attributes", value: "'auto'" },
379 { name: "wrap_line_length", value: "0" }
380 ],
381 indent_attr: ' ',
382 indent_attr_first: ' ',
383 indent_end: '',
384 indent_end_selfclosing: ' ',
385 indent_over80: ' '
386 }, {
387 options: [
388 { name: "wrap_attributes", value: "'force-aligned'" }
389 ],
390 indent_attr: '\n ',
391 indent_attr_faligned: ' ',
392 indent_attr_first: ' ',
393 indent_end: '',
394 indent_end_selfclosing: ' ',
395 indent_over80: '\n '
396 }, {
397 options: [
398 { name: "wrap_attributes", value: "'force-aligned'" },
399 { name: "wrap_line_length", value: "80" }
400 ],
401 indent_attr: '\n ',
402 indent_attr_faligned: ' ',
403 indent_attr_first: ' ',
404 indent_end: '',
405 indent_end_selfclosing: ' ',
406 indent_over80: '\n '
407 }, {
408 options: [
409 { name: "wrap_attributes", value: "'force-aligned'" },
410 { name: "wrap_attributes_indent_size", value: "8" }
411 ],
412 indent_attr: '\n ',
413 indent_attr_faligned: ' ',
414 indent_attr_first: ' ',
415 indent_end: '',
416 indent_end_selfclosing: ' ',
417 indent_over80: '\n '
418 }, {
419 options: [
420 { name: "wrap_attributes", value: "'force-expand-multiline'" },
421 { name: "wrap_attributes_indent_size", value: "4" }
422 ],
423 indent_attr: '\n ',
424 indent_attr_first: '\n ',
425 indent_end: '\n',
426 indent_end_selfclosing: '\n',
427 indent_over80: '\n '
428 }, {
429 options: [
430 { name: "wrap_attributes", value: "'force-expand-multiline'" },
431 { name: "wrap_attributes_indent_size", value: "4" },
432 { name: "wrap_line_length", value: "80" }
433 ],
434 indent_attr: '\n ',
435 indent_attr_first: '\n ',
436 indent_end: '\n',
437 indent_end_selfclosing: '\n',
438 indent_over80: '\n '
439 }, {
440 options: [
441 { name: "wrap_attributes", value: "'force-expand-multiline'" },
442 { name: "wrap_attributes_indent_size", value: "8" }
443 ],
444 indent_attr: '\n ',
445 indent_attr_first: '\n ',
446 indent_end: '\n',
447 indent_end_selfclosing: '\n',
448 indent_over80: '\n '
449 }],
450 tests: [{
451 fragment: true,
452 input: '<div >This is some text</div>',
453 output: '<div>This is some text</div>'
454 }, {
455 fragment: true,
456 input: '<div attr="123" >This is some text</div>',
457 output: '<div attr="123">This is some text</div>'
458 }, {
459 fragment: true,
460 input: '<div attr0 attr1="123" data-attr2="hello t here">This is some text</div>',
461 output: '<div{{indent_attr_first}}attr0{{indent_attr}}attr1="123"{{indent_attr}}data-attr2="hello t here"{{indent_end}}>This is some text</div>'
462 }, {
463 fragment: true,
464 input: '<div lookatthissuperduperlongattributenamewhoahcrazy0="true" attr0 attr1="123" data-attr2="hello t here" heymanimreallylongtoowhocomesupwiththesenames="false">This is some text</div>',
465 output: '<div{{indent_attr_first}}lookatthissuperduperlongattributenamewhoahcrazy0="true"{{indent_attr}}attr0{{indent_attr}}attr1="123"{{indent_attr}}data-attr2="hello t here"{{indent_over80}}heymanimreallylongtoowhocomesupwiththesenames="false"{{indent_end}}>This is some text</div>'
466 }, {
467 fragment: true,
468 input: '<img attr0 attr1="123" data-attr2="hello t here"/>',
469 output: '<img{{indent_attr_first}}attr0{{indent_attr}}attr1="123"{{indent_attr}}data-attr2="hello t here"{{indent_end_selfclosing}}/>'
470 }, {
471 fragment: true,
472 input: '<?xml version="1.0" encoding="UTF-8" ?><root attr1="foo" attr2="bar"/>',
473 output: '<?xml version="1.0" encoding="UTF-8" ?>\n<root{{indent_attr_first}}attr1="foo"{{indent_attr}}{{indent_attr_faligned}}attr2="bar"{{indent_end_selfclosing}}/>'
474 }, {
475 fragment: true,
476 input: '<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin" rel="stylesheet" type="text/css">',
477 output: '<link{{indent_attr_first}}href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&amp;subset=latin"{{indent_over80}}{{indent_attr_faligned}}rel="stylesheet"{{indent_attr}}{{indent_attr_faligned}}type="text/css"{{indent_end}}>'
478 }]
479 }, {
480 name: "Handlebars Indenting Off",
481 description: "Test handlebar behavior when indenting is off",
482 template: "^^^ $$$",
483 options: [
484 { name: "indent_handlebars", value: "false" }
485 ],
486 tests: [{
487 fragment: true,
488 input_: '{{#if 0}}\n' +
489 ' <div>\n' +
490 ' </div>\n' +
491 '{{/if}}',
492 output: '{{#if 0}}\n' +
493 '<div>\n' +
494 '</div>\n' +
495 '{{/if}}'
496 }, {
497 fragment: true,
498 input_: '<div>\n' +
499 '{{#each thing}}\n' +
500 ' {{name}}\n' +
501 '{{/each}}\n' +
502 '</div>',
503 output: '<div>\n' +
504 ' {{#each thing}} {{name}} {{/each}}\n' +
505 '</div>'
506 }
507  
508 ]
509 }, {
510 name: "Handlebars Indenting On",
511 description: "Test handlebar formatting",
512 template: "^^^ $$$",
513 matrix: [{
514 options: [
515 { name: "indent_handlebars", value: "true" }
516 ],
517 content: '{{field}}'
518 }, {
519 options: [
520 { name: "indent_handlebars", value: "true" }
521 ],
522 content: '{{! comment}}'
523 }, {
524 options: [
525 { name: "indent_handlebars", value: "true" }
526 ],
527 content: '{{!-- comment--}}'
528 }, {
529 options: [
530 { name: "indent_handlebars", value: "true" }
531 ],
532 content: '{pre{{field1}} {{field2}} {{field3}}post'
533 }, {
534 options: [
535 { name: "indent_handlebars", value: "true" }
536 ],
537 content: '{{! \n mult-line\ncomment \n with spacing\n}}'
538 }, {
539 options: [
540 { name: "indent_handlebars", value: "true" }
541 ],
542 content: '{{!-- \n mult-line\ncomment \n with spacing\n--}}'
543 }, {
544 options: [
545 { name: "indent_handlebars", value: "true" }
546 ],
547 content: '{{!-- \n mult-line\ncomment \n{{#> component}}\n mult-line\ncomment \n with spacing\n {{/ component}}--}}'
548 }, {
549 options: [
550 { name: "indent_handlebars", value: "true" },
551 { name: "wrap_line_length", value: "80" }
552 ],
553 content: 'content'
554 }],
555 tests: [
556 { fragment: true, unchanged: '{{page-title}}' },
557 { fragment: true, unchanged: '{{#if 0}}{{/if}}' },
558 { fragment: true, unchanged: '{{#if 0}}^^^&content$$${{/if}}' },
559 { fragment: true, unchanged: '{{#if 0}}\n{{/if}}' }, {
560 fragment: true,
561 input_: '{{#if words}}{{/if}}',
562 output: '{{#if words}}{{/if}}'
563 }, {
564 fragment: true,
565 input_: '{{#if words}}^^^&content$$${{/if}}',
566 output: '{{#if words}}^^^&content$$${{/if}}'
567 }, {
568 fragment: true,
569 input_: '{{#if words}}^^^&content$$${{/if}}',
570 output: '{{#if words}}^^^&content$$${{/if}}'
571 }, {
572 fragment: true,
573 unchanged: '{{#if 1}}\n' +
574 ' <div>\n' +
575 ' </div>\n' +
576 '{{/if}}'
577 }, {
578 fragment: true,
579 input_: '{{#if 1}}\n' +
580 '<div>\n' +
581 '</div>\n' +
582 '{{/if}}',
583 output: '{{#if 1}}\n' +
584 ' <div>\n' +
585 ' </div>\n' +
586 '{{/if}}'
587 }, {
588 fragment: true,
589 unchanged: '<div>\n' +
590 ' {{#if 1}}\n' +
591 ' {{/if}}\n' +
592 '</div>'
593 }, {
594 fragment: true,
595 input_: '<div>\n' +
596 '{{#if 1}}\n' +
597 '{{/if}}\n' +
598 '</div>',
599 output: '<div>\n' +
600 ' {{#if 1}}\n' +
601 ' {{/if}}\n' +
602 '</div>'
603 }, {
604 fragment: true,
605 input_: '{{#if}}\n' +
606 '{{#each}}\n' +
607 '{{#if}}\n' +
608 '^^^&content$$$\n' +
609 '{{/if}}\n' +
610 '{{#if}}\n' +
611 '^^^&content$$$\n' +
612 '{{/if}}\n' +
613 '{{/each}}\n' +
614 '{{/if}}',
615 output: '{{#if}}\n' +
616 ' {{#each}}\n' +
617 ' {{#if}}\n' +
618 ' ^^^&content$$$\n' +
619 ' {{/if}}\n' +
620 ' {{#if}}\n' +
621 ' ^^^&content$$$\n' +
622 ' {{/if}}\n' +
623 ' {{/each}}\n' +
624 '{{/if}}'
625 }, {
626 fragment: true,
627 unchanged: '{{#if 1}}\n' +
628 ' <div>\n' +
629 ' </div>\n' +
630 '{{/if}}'
631 },
632  
633 // Test {{else}} aligned with {{#if}} and {{/if}}
634 {
635 fragment: true,
636 input_: '{{#if 1}}\n' +
637 ' ^^^&content$$$\n' +
638 ' {{else}}\n' +
639 ' ^^^&content$$$\n' +
640 '{{/if}}',
641 output: '{{#if 1}}\n' +
642 ' ^^^&content$$$\n' +
643 '{{else}}\n' +
644 ' ^^^&content$$$\n' +
645 '{{/if}}'
646 }, {
647 fragment: true,
648 input_: '{{#if 1}}\n' +
649 ' {{else}}\n' +
650 ' {{/if}}',
651 output: '{{#if 1}}\n' +
652 '{{else}}\n' +
653 '{{/if}}'
654 }, {
655 fragment: true,
656 input_: '{{#if thing}}\n' +
657 '{{#if otherthing}}\n' +
658 ' ^^^&content$$$\n' +
659 ' {{else}}\n' +
660 '^^^&content$$$\n' +
661 ' {{/if}}\n' +
662 ' {{else}}\n' +
663 '^^^&content$$$\n' +
664 '{{/if}}',
665 output: '{{#if thing}}\n' +
666 ' {{#if otherthing}}\n' +
667 ' ^^^&content$$$\n' +
668 ' {{else}}\n' +
669 ' ^^^&content$$$\n' +
670 ' {{/if}}\n' +
671 '{{else}}\n' +
672 ' ^^^&content$$$\n' +
673 '{{/if}}'
674 },
675 // Test {{}} inside of <> tags, which should be separated by spaces
676 // for readability, unless they are inside a string.
677 {
678 fragment: true,
679 input_: '<div{{somestyle}}></div>',
680 output: '<div {{somestyle}}></div>'
681 }, {
682 fragment: true,
683 input_: '<div{{#if test}}class="foo"{{/if}}>^^^&content$$$</div>',
684 output: '<div {{#if test}} class="foo" {{/if}}>^^^&content$$$</div>'
685 }, {
686 fragment: true,
687 input_: '<div{{#if thing}}{{somestyle}}class="{{class}}"{{else}}class="{{class2}}"{{/if}}>^^^&content$$$</div>',
688 output: '<div {{#if thing}} {{somestyle}} class="{{class}}" {{else}} class="{{class2}}" {{/if}}>^^^&content$$$</div>'
689 }, {
690 fragment: true,
691 input_: '<span{{#if condition}}class="foo"{{/if}}>^^^&content$$$</span>',
692 output: '<span {{#if condition}} class="foo" {{/if}}>^^^&content$$$</span>'
693 }, {
694 fragment: true,
695 unchanged: '<div unformatted="{{#if}}^^^&content$$${{/if}}">^^^&content$$$</div>'
696 }, {
697 fragment: true,
698 unchanged: '<div unformatted="{{#if }} ^^^&content$$${{/if}}">^^^&content$$$</div>'
699 },
700  
701 // Quotes found inside of Handlebars expressions inside of quoted
702 // strings themselves should not be considered string delimiters.
703 {
704 fragment: true,
705 unchanged: '<div class="{{#if thingIs "value"}}^^^&content$$${{/if}}"></div>'
706 }, {
707 fragment: true,
708 unchanged: '<div class="{{#if thingIs \\\'value\\\'}}^^^&content$$${{/if}}"></div>'
709 }, {
710 fragment: true,
711 unchanged: '<div class=\\\'{{#if thingIs "value"}}^^^&content$$${{/if}}\\\'></div>'
712 }, {
713 fragment: true,
714 unchanged: '<div class=\\\'{{#if thingIs \\\'value\\\'}}^^^&content$$${{/if}}\\\'></div>'
715 }, {
716 fragment: true,
717 unchanged: '<span>{{condition < 0 ? "result1" : "result2"}}</span>'
718 }, {
719 fragment: true,
720 unchanged: '<span>{{condition1 && condition2 && condition3 && condition4 < 0 ? "resForTrue" : "resForFalse"}}</span>'
721 }
722 ],
723 }, {
724 name: "Handlebars Else tag indenting",
725 description: "Handlebar Else tags should be newlined after formatted tags",
726 template: "^^^ $$$",
727 options: [
728 { name: "indent_handlebars", value: "true" }
729 ],
730 tests: [{
731 fragment: true,
732 input_: '{{#if test}}<div></div>{{else}}<div></div>{{/if}}',
733 output: '{{#if test}}\n' +
734 ' <div></div>\n' +
735 '{{else}}\n' +
736 ' <div></div>\n' +
737 '{{/if}}'
738 }, {
739 fragment: true,
740 unchanged: '{{#if test}}<span></span>{{else}}<span></span>{{/if}}'
741 }]
742 }, {
743 name: "Unclosed html elements",
744 description: "Unclosed elements should not indent",
745 options: [],
746 tests: [
747 { fragment: true, unchanged: '<source>\n<source>' },
748 { fragment: true, unchanged: '<br>\n<br>' },
749 { fragment: true, unchanged: '<input>\n<input>' },
750 { fragment: true, unchanged: '<meta>\n<meta>' },
751 { fragment: true, unchanged: '<link>\n<link>' },
752 { fragment: true, unchanged: '<colgroup>\n <col>\n <col>\n</colgroup>' }
753 ]
754 }, {
755 name: "Unformatted tags",
756 description: "Unformatted tag behavior",
757 options: [],
758 tests: [{
759 fragment: true,
760 input: '<ol>\n <li>b<pre>c</pre></li>\n</ol>',
761 output: [
762 '<ol>',
763 ' <li>b',
764 ' <pre>c</pre>',
765 ' </li>',
766 '</ol>'
767 ]
768 },
769 { fragment: true, unchanged: '<ol>\n <li>b<code>c</code></li>\n</ol>' },
770 { fragment: true, unchanged: '<ul>\n <li>\n <span class="octicon octicon-person"></span>\n <a href="/contact/">Kontakt</a>\n </li>\n</ul>' },
771 { fragment: true, unchanged: '<div class="searchform"><input type="text" value="" name="s" id="s" /><input type="submit" id="searchsubmit" value="Search" /></div>' },
772 { fragment: true, unchanged: '<div class="searchform"><input type="text" value="" name="s" id="s"><input type="submit" id="searchsubmit" value="Search"></div>' },
773 { fragment: true, unchanged: '<p>\n <a href="/test/"><img src="test.jpg" /></a>\n</p>' },
774 { fragment: true, unchanged: '<p>\n <a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a>\n</p>' },
775 { fragment: true, unchanged: '<p>\n <a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a><a href="/test/"><img src="test.jpg" /></a>\n</p>' },
776 { fragment: true, unchanged: '<p>\n <span>image: <img src="test.jpg" /></span><span>image: <img src="test.jpg" /></span>\n</p>' },
777 { fragment: true, unchanged: '<p>\n <strong>image: <img src="test.jpg" /></strong><strong>image: <img src="test.jpg" /></strong>\n</p>' },
778 ]
779 }, {
780 name: "File starting with comment",
781 description: "Unformatted tag behavior",
782 options: [],
783 tests: [{
784 fragment: true,
785 unchanged: [
786 '<!--sample comment -->',
787 '',
788 '<html>',
789 '<body>',
790 ' <span>a span</span>',
791 '</body>',
792 '',
793 '</html>'
794 ]
795 }, ]
796 }, {
797 name: "Php formatting",
798 description: "Php (<?php ... ?>) treated as comments.",
799 options: [],
800 tests: [{
801 fragment: true,
802 input: '<h1 class="content-page-header"><?=$view["name"]; ?></h1>',
803 output: '<h1 class="content-page-header">\n <?=$view["name"]; ?>\n</h1>',
804 }, {
805 fragment: true,
806 unchanged: [
807 '<?php',
808 'for($i = 1; $i <= 100; $i++;) {',
809 ' #count to 100!',
810 ' echo($i . "</br>");',
811 '}',
812 '?>'
813 ]
814 }, {
815 fragment: true,
816 unchanged: [
817 '<?php ?>',
818 '<!DOCTYPE html>',
819 '',
820 '<html>',
821 '',
822 '<head></head>',
823 '',
824 '<body></body>',
825 '',
826 '</html>'
827 ]
828 }]
829 }, {
830 name: "Support simple language specific option inheritance/overriding",
831 description: "Support simple language specific option inheritance/overriding",
832 matrix: [{
833 options: [
834 { name: "js", value: "{ 'indent_size': 3 }" },
835 { name: "css", value: "{ 'indent_size': 5 }" }
836 ],
837 h: ' ',
838 c: ' ',
839 j: ' '
840 },
841 {
842 options: [
843 { name: "html", value: "{ 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 } }" }
844 ],
845 h: ' ',
846 c: ' ',
847 j: ' '
848 },
849 {
850 options: [
851 { name: "indent_size", value: "9" },
852 { name: "html", value: "{ 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 }, 'indent_size': 2}" },
853 { name: "js", value: "{ 'indent_size': 5 }" },
854 { name: "css", value: "{ 'indent_size': 3 }" }
855 ],
856 h: ' ',
857 c: ' ',
858 j: ' '
859 }
860 ],
861 tests: [{
862 fragment: true,
863 unchanged: [
864 '<head>',
865 '{{h}}<script>',
866 '{{h}}{{h}}if (a == b) {',
867 '{{h}}{{h}}{{j}}test();',
868 '{{h}}{{h}}}',
869 '{{h}}</script>',
870 '{{h}}<style>',
871 '{{h}}{{h}}.selector {',
872 '{{h}}{{h}}{{c}}font-size: 12px;',
873 '{{h}}{{h}}}',
874 '{{h}}</style>',
875 '</head>',
876 ]
877 }, ]
878 }, {
879 name: "underscore.js formatting",
880 description: "underscore.js templates (<% ... %>) treated as comments.",
881 options: [],
882 tests: [{
883 fragment: true,
884 unchanged: [
885 '<div class="col-sm-9">',
886 ' <textarea id="notes" class="form-control" rows="3">',
887 ' <%= notes %>',
888 ' </textarea>',
889 '</div>'
890 ]
891 }, ]
892 }, {
893 name: "Indent with tabs",
894 description: "Use one tab instead of several spaces for indentation",
895 template: "^^^ $$$",
896 options: [
897 { name: "indent_with_tabs", value: "true" }
898 ],
899 tests: [{
900 fragment: true,
901 input_: '<div>\n' +
902 '<div>\n' +
903 '</div>\n' +
904 '</div>',
905 output: '<div>\n' +
906 '\t<div>\n' +
907 '\t</div>\n' +
908 '</div>'
909 }]
910 }, {
911 name: "Indent without tabs",
912 description: "Use several spaces for indentation",
913 template: "^^^ $$$",
914 options: [
915 { name: "indent_with_tabs", value: "false" }
916 ],
917 tests: [{
918 fragment: true,
919 input_: '<div>\n' +
920 '<div>\n' +
921 '</div>\n' +
922 '</div>',
923 output: '<div>\n' +
924 ' <div>\n' +
925 ' </div>\n' +
926 '</div>'
927 }]
928 }, {
929 name: "Indent body inner html by default",
930 description: "",
931 tests: [{
932 fragment: true,
933 input: '<html>\n<body>\n<div></div>\n</body>\n\n</html>',
934 output: '<html>\n<body>\n <div></div>\n</body>\n\n</html>'
935 }]
936 }, {
937 name: "indent_body_inner_html set to false prevents indent of body inner html",
938 description: "",
939 options: [
940 { name: 'indent_body_inner_html', value: "false" }
941 ],
942 tests: [{
943 fragment: true,
944 unchanged: '<html>\n<body>\n<div></div>\n</body>\n\n</html>'
945 }]
946 }, {
947 name: "Indent head inner html by default",
948 description: "",
949 tests: [{
950 fragment: true,
951 input: '<html>\n\n<head>\n<meta>\n</head>\n\n</html>',
952 output: '<html>\n\n<head>\n <meta>\n</head>\n\n</html>'
953 }]
954 }, {
955 name: "indent_head_inner_html set to false prevents indent of head inner html",
956 description: "",
957 options: [
958 { name: 'indent_head_inner_html', value: "false" }
959 ],
960 tests: [{
961 fragment: true,
962 unchanged: '<html>\n\n<head>\n<meta>\n</head>\n\n</html>'
963 }]
964 }, {
965 name: "content_unformatted to prevent formatting content",
966 description: "",
967 options: [
968 { name: 'content_unformatted', value: "['script', 'style', 'p', 'span', 'br']" }
969 ],
970 tests: [{
971 fragment: true,
972 input: '<html><body><h1>A</h1><script>if(1){f();}</script><style>.a{display:none;}</style></body></html>',
973 output: [
974 '<html>',
975 '<body>',
976 ' <h1>A</h1>',
977 ' <script>if(1){f();}</script>',
978 ' <style>.a{display:none;}</style>',
979 '</body>',
980 '',
981 '</html>'
982 ]
983 }, {
984 fragment: true,
985 input: '<div><p>Beautify me</p></div><p><p>But not me</p></p>',
986 output: [
987 '<div>',
988 ' <p>Beautify me</p>',
989 '</div>',
990 '<p><p>But not me</p></p>'
991 ]
992 }, {
993 fragment: true,
994 input: '<div><p\n class="beauty-me"\n>Beautify me</p></div><p><p\n class="iamalreadybeauty"\n>But not me</p></p>',
995 output: [
996 '<div>',
997 ' <p class="beauty-me">Beautify me</p>',
998 '</div>',
999 '<p><p',
1000 ' class="iamalreadybeauty"',
1001 '>But not me</p></p>'
1002 ]
1003 }, {
1004 fragment: true,
1005 unchanged: '<div><span>blabla<div>something here</div></span></div>'
1006 }, {
1007 fragment: true,
1008 unchanged: '<div><br /></div>'
1009 }, {
1010 fragment: true,
1011 input: '<div><pre>var a=1;\nvar b=a;</pre></div>',
1012 output: [
1013 '<div>',
1014 ' <pre>var a=1; var b=a;</pre>',
1015 '</div>'
1016 ]
1017 }, {
1018 fragment: true,
1019 input: '<div><pre>\nvar a=1;\nvar b=a;\n</pre></div>',
1020 output: [
1021 '<div>',
1022 ' <pre>',
1023 ' var a=1; var b=a;',
1024 ' </pre>',
1025 '</div>'
1026 ]
1027 }]
1028 }, {
1029 name: "default content_unformatted",
1030 description: "",
1031 options: [],
1032 tests: [{
1033 fragment: true,
1034 input: '<html><body><h1>A</h1><script>if(1){f();}</script><style>.a{display:none;}</style></body></html>',
1035 output: [
1036 '<html>',
1037 '<body>',
1038 ' <h1>A</h1>',
1039 ' <script>',
1040 ' if (1) {',
1041 ' f();',
1042 ' }',
1043 ' </script>',
1044 ' <style>',
1045 ' .a {',
1046 ' display: none;',
1047 ' }',
1048 ' </style>',
1049 '</body>',
1050 '',
1051 '</html>'
1052 ]
1053 }, {
1054 fragment: true,
1055 input: '<div><p>Beautify me</p></div><p><p>But not me</p></p>',
1056 output: [
1057 '<div>',
1058 ' <p>Beautify me</p>',
1059 '</div>',
1060 '<p>',
1061 ' <p>But not me</p>',
1062 '</p>',
1063 ]
1064 }, {
1065 fragment: true,
1066 input: '<div><p\n class="beauty-me"\n>Beautify me</p></div><p><p\n class="iamalreadybeauty"\n>But not me</p></p>',
1067 output: [
1068 '<div>',
1069 ' <p class="beauty-me">Beautify me</p>',
1070 '</div>',
1071 '<p>',
1072 ' <p class="iamalreadybeauty">But not me</p>',
1073 '</p>'
1074 ]
1075 }, {
1076 fragment: true,
1077 unchanged: '<div><span>blabla<div>something here</div></span></div>'
1078 }, {
1079 fragment: true,
1080 unchanged: '<div><br /></div>'
1081 }, {
1082 fragment: true,
1083 input: '<div><pre>var a=1;\nvar b=a;</pre></div>',
1084 output: [
1085 '<div>',
1086 ' <pre>var a=1;',
1087 'var b=a;</pre>',
1088 '</div>'
1089 ]
1090 }, {
1091 fragment: true,
1092 input: '<div><pre>\nvar a=1;\nvar b=a;\n</pre></div>',
1093 output: [
1094 '<div>',
1095 ' <pre>',
1096 'var a=1;',
1097 'var b=a;',
1098 '</pre>',
1099 '</div>'
1100 ]
1101 }]
1102 }, {
1103 name: "New Test Suite"
1104 }],
1105 };