]> git.imager.perl.org - bse.git/blob - t/010-modules/050-format.t
fix indent[] handling and don't abuse ul anymore
[bse.git] / t / 010-modules / 050-format.t
1 #!perl -w
2 use strict;
3 use Test::More tests => 142;
4
5 sub format_test($$$;$);
6 sub noformat_test($$$;$);
7
8 my $gotmodule = require_ok('DevHelp::Formatter');
9
10 ++$|;
11
12 SKIP: {
13   skip "couldn't load module", 63 unless $gotmodule;
14   format_test 'acronym[hello]', '<p><acronym>hello</acronym></p>', 'acronym';
15   format_test 'acronym[|hello]', '<p><acronym>hello</acronym></p>', 'acronym with empty title';
16   format_test 'acronym[foo|hello]', '<p><acronym title="foo">hello</acronym></p>', 'acronym with title';
17   format_test 'acronym[foo|bar|hello]', '<p><acronym class="bar" title="foo">hello</acronym></p>', 'acronym with class and title';
18   format_test 'bdo[ltr|hello]', '<p><bdo dir="ltr">hello</bdo></p>', 'bdo with dir';
19   format_test 'code[hello]', '<p><code>hello</code></p>', 'code';
20   format_test 'code[|hello]', '<p><code>hello</code></p>', 'code empty class';
21   format_test 'code[foo|hello]', '<p><code class="foo">hello</code></p>', 'code with class';
22   format_test 'code[var[x]="1"]', '<p><code><var>x</var>=&quot;1&quot;</code></p>', 'code with var';
23   format_test 'cite[hello]', '<p><cite>hello</cite></p>', 'cite';
24   format_test 'cite[|hello]', '<p><cite>hello</cite></p>', 'cite with empty title';
25   format_test 'cite[foo|hello]', '<p><cite title="foo">hello</cite></p>', 'cite with title';
26   format_test 'cite[foo|bar|hello]', '<p><cite class="bar" title="foo">hello</cite></p>', 'cite with class and title';
27   format_test 'small[hello]', '<p><small>hello</small></p>', 'small';
28   format_test 'small[|hello]', '<p><small>hello</small></p>', 'small empty class';
29   format_test 'small[foo|hello]', '<p><small class="foo">hello</small></p>', 'small with class';
30   format_test 'large[hello]', '<p><large>hello</large></p>', 'large';
31   format_test 'large[|hello]', '<p><large>hello</large></p>', 'large empty class';
32   format_test 'large[foo|hello]', '<p><large class="foo">hello</large></p>', 'large with class';
33   format_test 'mark[hello]', '<p><mark>hello</mark></p>', 'mark';
34   format_test 'mark[|hello]', '<p><mark>hello</mark></p>', 'mark empty class';
35   format_test 'mark[foo|hello]', '<p><mark class="foo">hello</mark></p>', 'mark with class';
36   format_test 'link[foo|hello]', '<p><a href="foo">hello</a></p>', 'anchor';
37   format_test 'poplink[foo|hello]', '<p><a href="foo" target="_blank">hello</a></p>', 'anchor with popup';
38   format_test <<IN, <<OUT, 'blockquote', 'both';
39 blockquote[hello]
40
41 blockquote[
42
43 hello]
44 IN
45 <blockquote>hello</blockquote>
46 <blockquote>
47 <p>hello</p>
48 </blockquote>
49 OUT
50   format_test <<IN, <<OUT, 'blockquote with empty class', 'both';
51 blockquote[|hello]
52
53 blockquote[|
54
55 hello
56
57 ]
58 IN
59 <blockquote>hello</blockquote>
60 <blockquote>
61 <p>hello</p>
62 </blockquote>
63 OUT
64   format_test <<IN, <<OUT, 'blockquote with class', 'both';
65 blockquote[foo|hello]
66
67 blockquote[foo|hello
68 world]
69
70 blockquote[foo|
71 hello
72 world]
73 IN
74 <blockquote class="foo">hello</blockquote>
75 <blockquote class="foo">hello<br />
76 world</blockquote>
77 <blockquote class="foo">
78 <p>hello<br />
79 world</p>
80 </blockquote>
81 OUT
82   format_test <<IN, <<OUT, 'article', 'both';
83 article[hello]
84
85 article[
86
87 hello]
88 IN
89 <article>hello</article>
90 <article>
91 <p>hello</p>
92 </article>
93 OUT
94   format_test <<IN, <<OUT, 'article with empty class', 'both';
95 article[|hello]
96
97 article[|
98
99 hello
100
101 ]
102 IN
103 <article>hello</article>
104 <article>
105 <p>hello</p>
106 </article>
107 OUT
108   format_test <<IN, <<OUT, 'article with id and class', 'both';
109 article[#id foo|hello]
110
111 article[#id foo|
112
113 hello]
114 IN
115 <article id="id" class="foo">hello</article>
116 <article id="id" class="foo">
117 <p>hello</p>
118 </article>
119 OUT
120   format_test <<IN, <<OUT, 'section', 'both';
121 section[
122 hello
123 ]
124 IN
125 <section>
126 <p>hello</p>
127 </section>
128 OUT
129   format_test <<IN, <<OUT, 'section with empty class', 'both';
130 section[|
131 hello]
132 IN
133 <section>
134 <p>hello</p>
135 </section>
136 OUT
137   format_test <<IN, <<OUT, 'section with id and class', 'both';
138 section[#id foo|hello
139
140 ]
141 IN
142 <section id="id" class="foo">
143 <p>hello</p>
144 </section>
145 OUT
146   format_test <<IN, <<OUT, 'header', 'both';
147 header[
148
149 hello]
150 IN
151 <header>
152 <p>hello</p>
153 </header>
154 OUT
155   format_test <<IN, <<OUT, 'header with empty class', 'both';
156 header[|hello
157
158 ]
159 IN
160 <header>
161 <p>hello</p>
162 </header>
163 OUT
164   format_test <<IN, <<OUT, 'header with id and class', 'both';
165 header[#id foo|
166 hello
167 ]
168 IN
169 <header id="id" class="foo">
170 <p>hello</p>
171 </header>
172 OUT
173   format_test <<IN, <<OUT, 'footer', 'both';
174 footer[hello
175 world]
176 IN
177 <footer>hello<br />
178 world</footer>
179 OUT
180   format_test <<IN, <<OUT, 'footer with empty class', 'both';
181 footer[|
182
183 hello
184
185 ]
186 IN
187 <footer>
188 <p>hello</p>
189 </footer>
190 OUT
191   format_test <<IN, <<OUT, 'footer with id and class', 'both';
192 footer[#id foo|hello
193
194 ]
195 IN
196 <footer id="id" class="foo">
197 <p>hello</p>
198 </footer>
199 OUT
200   format_test <<IN, <<OUT, 'aside', 'both';
201 aside[hello]
202 IN
203 <aside>hello</aside>
204 OUT
205   format_test <<IN, <<OUT, 'aside with empty class', 'both';
206 aside[|hello]
207 IN
208 <aside>hello</aside>
209 OUT
210   format_test <<IN, <<OUT, 'aside with id and class', 'both';
211 aside[#id foo|hello]
212 IN
213 <aside id="id" class="foo">hello</aside>
214 OUT
215   format_test <<IN, <<OUT, 'nav', 'both';
216 nav[hello]
217 IN
218 <nav>hello</nav>
219 OUT
220   format_test <<IN, <<OUT, 'nav with empty class', 'both';
221 nav[|
222
223 hello
224
225 ]
226 IN
227 <nav>
228 <p>hello</p>
229 </nav>
230 OUT
231   format_test <<IN, <<OUT, 'nav with id and class', 'both';
232 nav[#id foo|hello]
233 IN
234 <nav id="id" class="foo">hello</nav>
235 OUT
236   format_test <<IN, <<OUT, 'figure', 'both';
237 figure[hello]
238 IN
239 <figure>hello</figure>
240 OUT
241   format_test <<IN, <<OUT, 'figure with empty class', 'both';
242 figure[|hello]
243 IN
244 <figure>hello</figure>
245 OUT
246   format_test <<IN, <<OUT, 'figure with id and class', 'both';
247 figure[#id foo|hello]
248 IN
249 <figure id="id" class="foo">hello</figure>
250 OUT
251   format_test <<IN, <<OUT, 'figcaption', 'both';
252 figcaption[hello]
253 IN
254 <figcaption>hello</figcaption>
255 OUT
256   format_test <<IN, <<OUT, 'figcaption with empty class', 'both';
257 figcaption[|hello]
258 IN
259 <figcaption>hello</figcaption>
260 OUT
261   format_test <<IN, <<OUT, 'figcaption with id and class', 'both';
262 figcaption[#id foo|hello]
263 IN
264 <figcaption id="id" class="foo">hello</figcaption>
265 OUT
266   format_test <<IN, <<OUT, 'strong over paras', 'both';
267 strong[foo|hello
268
269 foo]
270 IN
271 <p><strong class="foo">hello</strong></p>
272 <p><strong class="foo">foo</strong></p>
273 OUT
274   format_test <<IN, <<OUT, 'blockquote list h1 var', 'both';
275 blockquote[
276 ** one
277 ** two
278 h1[quux]var[hello
279 there]
280
281 foo]
282 IN
283 <blockquote>
284 <ul>
285 <li>one</li>
286 <li>two</li>
287 </ul>
288 <h1>quux</h1>
289 <p><var>hello<br />
290 there</var></p>
291 <p>foo</p>
292 </blockquote>
293 OUT
294   format_test <<IN, <<OUT, 'address class h1 abbr over paras', 'both';
295 address[foo|h1[bar
296
297 quux]abbr[my abbr|hello]
298
299 class[foo|b[bold|E=MCsup[2]]]
300
301 foo]
302 IN
303 <address class="foo">
304 <h1>bar</h1>
305 <h1>quux</h1>
306 <p><abbr title="my abbr">hello</abbr></p>
307 <p class="foo"><b class="bold">E=MC<sup>2</sup></b></p>
308 <p>foo</p>
309 </address>
310 OUT
311   format_test <<IN, <<OUT, 'div blockquote h1 class over paras', 'both';
312 div[quux|blockquote[foo|h1[bar]
313 b[hello]
314 class[foo|b[bold|E=MCsup[2
315
316 kbd[xxx|super]]]]
317
318 foo]]
319 IN
320 <div class="quux">
321 <blockquote class="foo">
322 <h1>bar</h1>
323 <p><b>hello</b><br />
324 <span class="foo"><b class="bold">E=MC<sup>2</sup></b></span></p>
325 <p class="foo"><b class="bold"><sup><kbd class="xxx">super</kbd></sup></b></p>
326 <p>foo</p>
327 </blockquote>
328 </div>
329 OUT
330   format_test <<IN, <<OUT, 'bold', 'both';
331 b[hello]
332 IN
333 <p><b>hello</b></p>
334 OUT
335   format_test 'i[hello]', '<p><i>hello</i></p>', 'italic';
336   format_test 'b[i[hello]]', '<p><b><i>hello</i></b></p>', 'bold/italic';
337   format_test <<IN, <<OUT, 'bold over lines', 'both';
338 b[hello
339 foo]
340 IN
341 <p><b>hello<br />
342 foo</b></p>
343 OUT
344   format_test <<IN, <<OUT, 'bold over paras', 'both';
345 b[hello
346
347 foo]
348 IN
349 <p><b>hello</b></p>
350 <p><b>foo</b></p>
351 OUT
352   format_test <<IN, <<OUT, 'combo over paras', 'both';
353 i[b[hello
354
355 foo
356
357 bar]]
358 IN
359 <p><i><b>hello</b></i></p>
360 <p><i><b>foo</b></i></p>
361 <p><i><b>bar</b></i></p>
362 OUT
363   format_test <<IN, <<OUT, 'link', 'both';
364 link[http://foo/|bar
365
366 quux]
367 IN
368 <a href="http://foo/">
369 <p>bar</p>
370 <p>quux</p>
371 </a>
372 OUT
373   format_test 'tt[hello]', '<p><tt>hello</tt></p>', 'tt';
374   format_test 'font[-1|text]', '<p><font size="-1">text</font></p>', 'fontsize';
375   format_test 'fontcolor[-1|black|text]', '<p><font size="-1" color="black">text</font></p>', 'fontsizecolor';
376   format_test 'anchor[somename]', '<p><a name="somename"></a></p>', 'anchor';
377   format_test <<IN, <<OUT, 'pre', 'both';
378
379
380 pre[hello there
381 Joe]
382 IN
383 <pre>hello there
384 Joe</pre>
385 OUT
386   format_test <<IN, <<OUT, 'pre with bold', 'both';
387 pre[b[hello there
388
389 Joe]]
390 IN
391 <pre><b>hello there</b>
392
393 <b>Joe</b></pre>
394 OUT
395   format_test <<IN, <<OUT, 'html', 'both';
396 html[<object foo="bar" />]
397 IN
398 <object foo="bar" />
399 OUT
400
401   format_test 'embed[foo]', '', 'embed1';
402   format_test 'embed[foo,bar]', '', 'embed2';
403   format_test 'embed[foo,bar,quux]', '', 'embed3';
404   format_test 'h1[|text]', '<h1>text</h1>', 'h1';
405   format_test 'h1[someclass|text]', '<h1 class="someclass">text</h1>', 'h1class';
406   format_test 'h6[|te>xt]', '<h6>te&gt;xt</h6>', 'h6';
407   format_test 'h1[|foo]h2[|bar]', "<h1>foo</h1>\n<h2>bar</h2>", 'h1h2';
408   format_test 'h1[|foo]texth2[|bar]', 
409     "<h1>foo</h1>\n<p>text</p>\n<h2>bar</h2>", 'h1texth2';
410   format_test <<IN, <<OUT, 'align', 'both';
411 align[left|some text]
412 IN
413 <div align="left">
414 <p>some text</p>
415 </div>
416 OUT
417   format_test 'hr[]', '<hr />', 'hr0';
418   format_test 'hr[80%]', '<hr width="80%" />', 'hr1';
419   format_test 'hr[80%|10]', '<hr width="80%" size="10" />', 'hr2';
420   format_test <<'IN', <<'OUT', 'hr with other text', 'both';
421 testhr[]test
422 hr[80%]
423 test
424 IN
425 <p>test</p>
426 <hr />
427 <p>test</p>
428 <hr width="80%" />
429 <p>test</p>
430 OUT
431   format_test <<IN, <<OUT, 'table1', 'both';
432 table[80%
433 bgcolor="black"|quux|blarg
434 |hello|there
435 ]
436 IN
437 <table width="80%"><tr bgcolor="black"><td>quux</td><td>blarg</td></tr><tr><td>hello</td><td>there</td></tr></table>
438 OUT
439   format_test <<IN, <<OUT, 'table2', 'both';
440 table[80%|#808080|2|2|Arial
441 bgcolor="black"|quux|blarg
442 |hello|there
443 ]
444 IN
445 <table width="80%" bgcolor="#808080" cellpadding="2"><tr bgcolor="black"><td><font size="2" face="Arial">quux</font></td><td><font size="2" face="Arial">blarg</font></td></tr><tr><td><font size="2" face="Arial">hello</font></td><td><font size="2" face="Arial">there</font></td></tr></table>
446 OUT
447   format_test <<IN, <<OUT, 'table3', 'both';
448 table[80%|foo]
449 IN
450 <table width="80%"><tr><td>foo</td></tr></table>
451 OUT
452   format_test <<IN, <<OUT, 'ol1', 'both';
453 ## one
454 ## two
455 IN
456 <ol>
457 <li>one</li>
458 <li>two</li>
459 </ol>
460 OUT
461   format_test <<IN, <<OUT, 'ol2', 'both';
462 ## one
463
464 ## two
465 IN
466 <ol>
467 <li>
468 <p>one</p>
469 </li>
470 <li>two</li>
471 </ol>
472 OUT
473   format_test <<IN, <<OUT, 'ol1 alpha', 'both';
474 %% one
475 %% two
476 IN
477 <ol type="a">
478 <li>one</li>
479 <li>two</li>
480 </ol>
481 OUT
482   format_test <<IN, <<OUT, 'ol2 alpha', 'both';
483 %% one
484
485 %% two
486 IN
487 <ol type="a">
488 <li>
489 <p>one</p>
490 </li>
491 <li>two</li>
492 </ol>
493 OUT
494   format_test <<IN, <<OUT, 'ul1', 'both';
495 ** one
496 ** two
497 IN
498 <ul>
499 <li>one</li>
500 <li>two</li>
501 </ul>
502 OUT
503   format_test <<IN, <<OUT, 'ul2', 'both';
504 ** one
505
506 ** two
507 IN
508 <ul>
509 <li>
510 <p>one</p>
511 </li>
512 <li>two</li>
513 </ul>
514 OUT
515
516   format_test <<IN, <<OUT, 'ul indented', 'both';
517   ** one
518 **two
519 IN
520 <ul>
521 <li>one</li>
522 <li>two</li>
523 </ul>
524 OUT
525
526   format_test <<IN, <<OUT, "don't ul at end of line", 'both';
527 this shouldn't be a bullet ** some text
528
529 ** this should be a bullet
530 ** so should this
531 IN
532 <p>this shouldn't be a bullet ** some text</p>
533 <ul>
534 <li>this should be a bullet</li>
535 <li>so should this</li>
536 </ul>
537 OUT
538
539   format_test <<IN, <<OUT, 'mixed', 'both';
540 ** joe
541 ** bob
542 ## one
543 ## two
544 IN
545 <ul>
546 <li>joe</li>
547 <li>bob</li>
548 </ul>
549 <ol>
550 <li>one</li>
551 <li>two</li>
552 </ol>
553 OUT
554
555   format_test <<IN, <<OUT, 'spaces between', 'both';
556 ** joe
557  
558 ** bob
559
560 ** jane
561 IN
562 <ul>
563 <li>
564 <p>joe</p>
565 </li>
566 <li>
567 <p>bob</p>
568 </li>
569 <li>jane</li>
570 </ul>
571 OUT
572
573   format_test 'indent[text]', '<div class="indent">text</div>', 'indent';
574   format_test 'center[text]', '<center>text</center>', 'center';
575   format_test 'hrcolor[80|10|#FF0000]', <<OUT, 'hrcolor', 'out';
576 <table width="80" height="10" border="0" bgcolor="#FF0000" cellpadding="0" cellspacing="0"><tr><td><img src="/images/trans_pixel.gif" width="1" height="1" alt="" /></td></tr></table>
577 OUT
578   format_test 'image[foo]', '<p></p>', 'image';
579
580   format_test 'class[xxx|yyy]', '<p class="xxx">yyy</p>', 'class';
581   format_test "class[xxx|yy\n\nzz]", <<EOS, 'class2', 'out';
582 <p class="xxx">yy</p>
583 <p class="xxx">zz</p>
584 EOS
585   format_test 'div[someclass|h1[|foo]barh2[|quux]]', <<EOS, 'divblock', 'out';
586 <div class="someclass">
587 <h1>foo</h1>
588 <p>bar</p>
589 <h2>quux</h2>
590 </div>
591 EOS
592
593   format_test "h1[#foo|test]", q!<h1 id="foo">test</h1>!, 'h1#id';
594   format_test "h1[#foo bar|test]", q!<h1 id="foo" class="bar">test</h1>!, 'h1#id class';
595   format_test "h1[#foo bar quux|test]", q!<h1 id="foo" class="bar quux">test</h1>!, 'h1#id class class';
596   format_test "h1[text-align: center;|test]", q!<h1 style="text-align: center;">test</h1>!, 'h1 styled';
597   format_test "h1[#foo text-align: center;|test]", q!<h1 id="foo" style="text-align: center;">test</h1>!, 'h1 styled, id';
598
599   format_test "div[text-align: center;|test\n\ntest2]", <<EOS, 'div styled', 'out';
600 <div style="text-align: center;">
601 <p>test</p>
602 <p>test2</p>
603 </div>
604 EOS
605
606   format_test "div[#foo|test\n\ntest2]", <<EOS, 'div #id', 'out';
607 <div id="foo">
608 <p>test</p>
609 <p>test2</p>
610 </div>
611 EOS
612
613   format_test "abc comment[foo] def", "<p>abc  def</p>", "comment";
614   format_test <<IN, <<OUT, 'link over paras following an hr', 'both';
615 hr[100%]
616
617 link[#foo|hello
618
619 world]
620
621 link[#foo|
622 hello
623
624 world]
625 IN
626 <hr width="100%" />
627 <a href="#foo">
628 <p>hello</p>
629 <p>world</p>
630 </a>
631 <a href="#foo">
632 <p>hello</p>
633 <p>world</p>
634 </a>
635 OUT
636
637 format_test <<IN, <<OUT, 'link over div block containing paras', 'both';
638 link[#foo|
639
640 div[#id class background-color: red;|
641
642 hello
643
644 world
645
646 ]
647 ]
648 IN
649 <a href="#foo">
650 <div id="id" style="background-color: red;" class="class">
651 <p>hello</p>
652 <p>world</p>
653 </div>
654 </a>
655 OUT
656
657 format_test <<IN, <<OUT, 'poplink over div block containing paras', 'both';
658
659 poplink[http://www.example.com/|
660
661 div[#id class background-color: red;|
662
663 hello
664
665 world
666
667 ]
668 ]
669 IN
670 <a href="http://www.example.com/" target="_blank">
671 <div id="id" style="background-color: red;" class="class">
672 <p>hello</p>
673 <p>world</p>
674 </div>
675 </a>
676 OUT
677
678 format_test <<IN, <<OUT, 'link over complex nested block structure', 'both';
679
680 link[http://www.example.com/|
681
682 section[#id class background-color: red;|
683
684 header[h1[headline
685
686 more]
687
688 ]
689
690 article[foo|
691
692 b[bar|hello
693
694 i[world
695
696 today]]
697
698 div[i[tomorrow]
699
700 class[quux|yesterday]]
701
702 ]
703
704 footer[#id|footer]
705
706 ]
707 ]
708 IN
709 <a href="http://www.example.com/">
710 <section id="id" style="background-color: red;" class="class">
711 <header>
712 <h1>headline</h1>
713 <h1>more</h1>
714 </header>
715 <article class="foo">
716 <p><b class="bar">hello</b></p>
717 <p><b class="bar"><i>world</i></b></p>
718 <p><b class="bar"><i>today</i></b></p>
719 <div>
720 <p><i>tomorrow</i></p>
721 <p class="quux">yesterday</p>
722 </div>
723 </article>
724 <footer id="id">footer</footer>
725 </section>
726 </a>
727 OUT
728
729 format_test <<IN, <<OUT, 'list inside a block', 'both';
730 div[#id|
731 ** item
732 ** item
733 ]
734 IN
735 <div id="id">
736 <ul>
737 <li>item</li>
738 <li>item</li>
739 </ul>
740 </div>
741 OUT
742
743   # remove_format() tests
744   noformat_test 'image[foo]', '', 'image';
745   noformat_test 'code[something [bar]]', 'something [bar]', 'nested []';
746
747   noformat_test "abc comment[foo] def", "abc  def", "comment";
748
749   noformat_test 'class[foo|image[bar]]', '', 'class with image content';
750   noformat_test 'abbr[image[bar]]', '', 'abbr[] with image content';
751   noformat_test 'abbr[foo|image[bar]]', '', 'abbr[x|x] with image content';
752   noformat_test 'abbr[|image[bar]]', '', 'abbr[|x] with image content';
753   noformat_test 'strong[image[bar]]', '', 'strong[x] with image content';
754   noformat_test 'strong[|image[bar]]', '', 'strong[|x] with image content';
755   noformat_test 'strong[foo|image[bar]]', '', 'strong[x|x] with image content';
756
757   noformat_test 'div[foo|image[bar]]', '', 'div[x|x] with image content';
758   noformat_test 'comment[image[bar]]', '', 'comment[image[xx]] with image content';
759   noformat_test 'h1[foo|image[bar]]', '', 'h1[x|x] with image content';
760   noformat_test 'h1[|image[bar]]', '', 'h1[|x] with image content';
761   noformat_test 'h1[image[bar]]', '', 'h1[x] with image content';
762   
763   noformat_test 'poplink[xxx|image[bar]]', '', 'poplink[x|x] with image content';
764   noformat_test 'poplink[image[bar]]', '', 'poplink[x] with image content';
765   noformat_test 'link[xxx|image[bar]]', '', 'link[x|x] with image content';
766   noformat_test 'link[image[bar]]', '', 'link[x] with image content';
767   noformat_test 'align[xxx|image[bar]]', '', 'align[x|x] with image content';
768   noformat_test 'font[xxx|image[bar]]', '', 'font[x|x] with image content';
769   noformat_test 'hr[xxx|image[bar]]', '', 'hr[x|x] with image content';
770   noformat_test 'anchor[image[bar]]', '', 'anchor[x] with image content';
771   noformat_test '**image[bar]', '', '** list with image content';
772   noformat_test '%%image[bar]', '', '%% list with image content';
773   noformat_test '##image[bar]', '', '## list with image content';
774 }
775
776 sub format_test ($$$;$) {
777   my ($in, $out, $desc, $stripnl) = @_;
778
779   $stripnl ||= 'none';
780   $in =~ s/\n$// if $stripnl eq 'in' || $stripnl eq 'both';
781   $out =~ s/\n$// if $stripnl eq 'out' || $stripnl eq 'both';
782
783   my $formatter = DevHelp::Formatter->new;
784
785   my $result = $formatter->format($in);
786
787   is($result, $out, $desc);
788 }
789
790 sub noformat_test($$$;$) {
791   my ($in, $out, $desc, $stripnl) = @_;
792
793   $stripnl ||= 'none';
794   $in =~ s/\n$// if $stripnl eq 'in' || $stripnl eq 'both';
795   $out =~ s/\n$// if $stripnl eq 'out' || $stripnl eq 'both';
796
797   my $formatter = DevHelp::Formatter->new;
798
799   my $result = $formatter->remove_format($in);
800
801   is($result, $out, $desc);
802 }