3 # t/xhtml01.t - check basic output from Pod::Simple::XHTML
11 use Test::More tests => 25;
13 use_ok('Pod::Simple::XHTML') or exit;
15 my $parser = Pod::Simple::XHTML->new ();
16 isa_ok ($parser, 'Pod::Simple::XHTML');
20 my $PERLDOC = "http://search.cpan.org/perldoc?";
22 initialize($parser, $results);
23 $parser->parse_string_document( "=head1 Poit!" );
24 is($results, "<h1>Poit!</h1>\n\n", "head1 level output");
26 initialize($parser, $results);
27 $parser->parse_string_document( "=head2 I think so Brain." );
28 is($results, "<h2>I think so Brain.</h2>\n\n", "head2 level output");
30 initialize($parser, $results);
31 $parser->parse_string_document( "=head3 I say, Brain..." );
32 is($results, "<h3>I say, Brain...</h3>\n\n", "head3 level output");
34 initialize($parser, $results);
35 $parser->parse_string_document( "=head4 Zort!" );
36 is($results, "<h4>Zort!</h4>\n\n", "head4 level output");
39 initialize($parser, $results);
40 $parser->parse_string_document(<<'EOPOD');
43 Gee, Brain, what do you want to do tonight?
46 is($results, <<'EOHTML', "simple paragraph");
47 <p>Gee, Brain, what do you want to do tonight?</p>
52 initialize($parser, $results);
53 $parser->parse_string_document(<<'EOPOD');
56 B: Now, Pinky, if by any chance you are captured during this mission,
57 remember you are Gunther Heindriksen from Appenzell. You moved to
58 Grindelwald to drive the cog train to Murren. Can you repeat that?
60 P: Mmmm, no, Brain, don't think I can.
63 is($results, <<'EOHTML', "multiple paragraphs");
64 <p>B: Now, Pinky, if by any chance you are captured during this mission, remember you are Gunther Heindriksen from Appenzell. You moved to Grindelwald to drive the cog train to Murren. Can you repeat that?</p>
66 <p>P: Mmmm, no, Brain, don't think I can.</p>
70 initialize($parser, $results);
71 $parser->parse_string_document(<<'EOPOD');
76 P: Gee, Brain, what do you want to do tonight?
80 B: The same thing we do every night, Pinky. Try to take over the world!
86 is($results, <<'EOHTML', "simple bulleted list");
89 <li>P: Gee, Brain, what do you want to do tonight?</li>
91 <li>B: The same thing we do every night, Pinky. Try to take over the world!</li>
98 initialize($parser, $results);
99 $parser->parse_string_document(<<'EOPOD');
104 P: Gee, Brain, what do you want to do tonight?
108 B: The same thing we do every night, Pinky. Try to take over the world!
114 is($results, <<'EOHTML', "numbered list");
117 <li>1. P: Gee, Brain, what do you want to do tonight?</li>
119 <li>2. B: The same thing we do every night, Pinky. Try to take over the world!</li>
126 initialize($parser, $results);
127 $parser->parse_string_document(<<'EOPOD');
132 Gee, Brain, what do you want to do tonight?
136 The same thing we do every night, Pinky. Try to take over the world!
142 is($results, <<'EOHTML', "list with text headings");
147 <p>Gee, Brain, what do you want to do tonight?</p>
151 <p>The same thing we do every night, Pinky. Try to take over the world!</p>
158 initialize($parser, $results);
159 $parser->parse_string_document(<<'EOPOD');
167 is($results, <<'EOHTML', "code block");
168 <pre><code> 1 + 1 = 2;
169 2 + 2 = 4;</code></pre>
174 initialize($parser, $results);
175 $parser->parse_string_document(<<'EOPOD');
178 A plain paragraph with a C<functionname>.
180 is($results, <<"EOHTML", "code entity in a paragraph");
181 <p>A plain paragraph with a <code>functionname</code>.</p>
186 initialize($parser, $results);
187 $parser->html_header("<html>\n<body>");
188 $parser->html_footer("</body>\n</html>");
189 $parser->parse_string_document(<<'EOPOD');
192 A plain paragraph with body tags turned on.
194 is($results, <<"EOHTML", "adding html body tags");
198 <p>A plain paragraph with body tags turned on.</p>
206 initialize($parser, $results);
207 $parser->html_css('style.css');
208 $parser->html_header(undef);
209 $parser->html_footer(undef);
210 $parser->parse_string_document(<<'EOPOD');
213 A plain paragraph with body tags and css tags turned on.
215 like($results, qr/<link rel='stylesheet' href='style.css' type='text\/css'>/,
216 "adding html body tags and css tags");
219 initialize($parser, $results);
220 $parser->parse_string_document(<<'EOPOD');
223 A plain paragraph with S<non breaking text>.
225 is($results, <<"EOHTML", "Non breaking text in a paragraph");
226 <p>A plain paragraph with <nobr>non breaking text</nobr>.</p>
230 initialize($parser, $results);
231 $parser->parse_string_document(<<'EOPOD');
234 A plain paragraph with a L<Newlines>.
236 is($results, <<"EOHTML", "Link entity in a paragraph");
237 <p>A plain paragraph with a <a href="${PERLDOC}Newlines">Newlines</a>.</p>
241 initialize($parser, $results);
242 $parser->parse_string_document(<<'EOPOD');
245 A plain paragraph with a L<perlport/Newlines>.
247 is($results, <<"EOHTML", "Link entity in a paragraph");
248 <p>A plain paragraph with a <a href="${PERLDOC}perlport/Newlines">"Newlines" in perlport</a>.</p>
252 initialize($parser, $results);
253 $parser->parse_string_document(<<'EOPOD');
256 A plain paragraph with a L<Boo|http://link.included.here>.
258 is($results, <<"EOHTML", "A link in a paragraph");
259 <p>A plain paragraph with a <a href="http://link.included.here">Boo</a>.</p>
263 initialize($parser, $results);
264 $parser->parse_string_document(<<'EOPOD');
267 A plain paragraph with a L<http://link.included.here>.
269 is($results, <<"EOHTML", "A link in a paragraph");
270 <p>A plain paragraph with a <a href="http://link.included.here">http://link.included.here</a>.</p>
274 initialize($parser, $results);
275 $parser->parse_string_document(<<'EOPOD');
278 A plain paragraph with B<bold text>.
280 is($results, <<"EOHTML", "Bold text in a paragraph");
281 <p>A plain paragraph with <b>bold text</b>.</p>
285 initialize($parser, $results);
286 $parser->parse_string_document(<<'EOPOD');
289 A plain paragraph with I<italic text>.
291 is($results, <<"EOHTML", "Italic text in a paragraph");
292 <p>A plain paragraph with <i>italic text</i>.</p>
296 initialize($parser, $results);
297 $parser->parse_string_document(<<'EOPOD');
300 A plain paragraph with a F<filename>.
302 is($results, <<"EOHTML", "File name in a paragraph");
303 <p>A plain paragraph with a <i>filename</i>.</p>
308 initialize($parser, $results);
309 $parser->parse_string_document(<<'EOPOD');
312 # this header is very important & don't you forget it
313 my $text = "File is: " . <FILE>;
315 is($results, <<"EOHTML", "Verbatim text with encodable entities");
316 <pre><code> # this header is very important & don't you forget it
317 my \$text = "File is: " . <FILE>;</code></pre>
321 initialize($parser, $results);
322 $parser->parse_string_document(<<'EOPOD');
325 # this header is very important & don't you forget it
326 B<my $file = <FILEE<gt> || 'Blank!';>
327 my $text = "File is: " . <FILE>;
329 is($results, <<"EOHTML", "Verbatim text with markup and embedded formatting");
330 <pre><code> # this header is very important & don't you forget it
331 <b>my \$file = <FILE> || 'Blank!';</b>
332 my \$text = "File is: " . <FILE>;</code></pre>
336 ######################################
339 $_[0] = Pod::Simple::XHTML->new ();
340 $_[0]->html_header("");
341 $_[0]->html_footer("");
342 $_[0]->output_string( \$results ); # Send the resulting output to a string