• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#--- manual.t -----------------------------------------------------------------
2# function: Test HTML::ToC generating a manual.
3
4use strict;
5use Test;
6
7BEGIN { plan tests => 3; }
8
9use HTML::Toc;
10use HTML::TocGenerator;
11use HTML::TocInsertor;
12use HTML::TocUpdator;
13
14
15#--- AssembleTocLine() --------------------------------------------------------
16# function: Assemble ToC line.
17
18sub AssembleTocLine {
19		# Get arguments
20	my ($aLevel, $aGroupId, $aNode, $aSequenceNr, $aText) = @_;
21		# Local variables
22	my ($result);
23
24		# Assemble ToC line
25	SWITCH: {
26		if ($aGroupId eq "prelude") {
27			$result = "<li>$aText\n";
28			last SWITCH;
29		}
30		if ($aGroupId eq "part") {
31			$result = "<li>Part $aNode &nbsp;$aText\n";
32			last SWITCH;
33		}
34		if ($aGroupId eq "h") {
35			$result = "<li>$aSequenceNr. &nbsp;$aText\n";
36			last SWITCH;
37		}
38		else {
39			$result = "<li>$aNode &nbsp;$aText\n";
40			last SWITCH;
41		}
42	}
43
44		# Return value
45	return $result;
46}  # AssembleTocLine()
47
48
49#--- AssembleTokenNumber() ----------------------------------------------------
50# function: Assemble token number.
51
52sub AssembleTokenNumber {
53		# Get arguments
54	my ($aNode, $aGroupId, $aFile, $aGroupLevel, $aLevel, $aToc) = @_;
55		# Local variables
56	my ($result);
57		# Assemble token number
58	SWITCH: {
59		if ($aGroupId eq "part") {
60			$result = "Part $aNode &nbsp;";
61			last SWITCH;
62		}
63		else {
64			$result = "$aNode &nbsp;";
65			last SWITCH;
66		}
67	}
68		# Return value
69	return $result;
70}  # AssembleTokenNumber()
71
72
73#--- TestInsertManualToc ------------------------------------------------------
74# function: Test inserting ToC into manual.
75
76sub TestInsertManualToc {
77	my $output;
78		# Create objects
79	my $toc          = new HTML::Toc;
80	my $tocOfFigures = new HTML::Toc;
81	my $tocOfTables  = new HTML::Toc;
82	my $tocInsertor  = new HTML::TocInsertor;
83
84		# Set ToC options
85	$toc->setOptions({
86		'doNestGroup'          => 1,
87		'doNumberToken'        => 1,
88		'insertionPoint'       => "replace <!-- Table of Contents -->",
89		'templateLevel'        => \&AssembleTocLine,
90      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
91      'templateLevelEnd'     => '"</ul>\n"',
92		'templateTokenNumber'  => \&AssembleTokenNumber,
93      'tokenToToc'           => [{
94            'groupId'        => 'part',
95			   'doNumberToken'  => 1,
96            'level'          => 1,
97            'tokenBegin'     => '<h1 class=part>',
98         }, {
99            'tokenBegin'     => '<h1 class=-[appendix|prelude|hidden|part]>'
100         }, {
101            'tokenBegin'     => '<h2>',
102            'level'          => 2
103         }, {
104            'tokenBegin'     => '<h3>',
105            'level'          => 3
106         }, {
107            'groupId'        => 'appendix',
108            'tokenBegin'     => '<h1 class=appendix>',
109			   'numberingStyle' => 'upper-alpha',
110         }, {
111            'groupId'        => 'appendix',
112            'tokenBegin'     => '<h2 class=appendix>',
113            'level'          => 2
114         }, {
115            'groupId'        => 'prelude',
116            'tokenBegin'     => '<h1 class=prelude>',
117            'level'          => 1,
118			   'doNumberToken'  => 0,
119         }],
120	});
121	$tocOfFigures->setOptions({
122		'doNumberToken'        => 1,
123		'insertionPoint'       => "replace <!-- Table of Figures -->",
124		'templateLevelBegin'   => '"<ol>\n"',
125		'templateLevelEnd'     => '"</ol>\n"',
126		'templateTokenNumber'  => '"Figure $node: &nbsp;"',
127		'tokenToToc'           => [{
128				'groupId'        => 'Figure',
129				'tokenBegin'     => '<p class=captionFigure>'
130			}]
131	});
132	$tocOfTables->setOptions({
133		'doNumberToken'        => 1,
134		'insertionPoint'       => "replace <!-- Table of Tables -->",
135		'templateLevelBegin'   => '"<ol>\n"',
136		'templateLevelEnd'     => '"</ol>\n"',
137		'templateTokenNumber'  => '"Table $node: &nbsp;"',
138		'tokenToToc'           => [{
139				'groupId'        => 'Table',
140				'tokenBegin'     => '<p class=captionTable>'
141			}]
142	});
143		# Insert ToC
144	$tocInsertor->insertIntoFile(
145		[$toc, $tocOfFigures, $tocOfTables],
146		't/ManualTest/manualTest1.htm', {
147			 'doUseGroupsGlobal' => 1,
148			 'output'            => \$output,
149			 'outputFile'        => 't/ManualTest/manualTest2.htm'
150		}
151	);
152	ok($output, <<EOT);
153<html>
154<head>
155   <title>Manual</title>
156    <style type="text/css">
157       ul.toc_appendix1 {
158         list-style-type: none;
159         margin-left: 0;
160         margin-top: 1em;
161         margin-bottom: 1em;
162       }
163       ul.toc_h1 {
164         list-style-type: none;
165         margin-left: 1;
166         margin-top: 1em;
167         margin-bottom: 1em;
168       }
169       ul.toc_h2 {
170         list-style-type: none;
171       }
172       ul.toc_h3 {
173         list-style-type: none;
174       }
175       ul.toc_part1 {
176         list-style-type: none;
177         margin-left: 1;
178         margin-top: 1em;
179         margin-bottom: 1em;
180       }
181       ul.toc_prelude1 {
182         list-style: none;
183       }
184       p.captionFigure {
185         font-style: italic;
186         font-weight: bold;
187       }
188       p.captionTable {
189         font-style: italic;
190         font-weight: bold;
191       }
192    </style>
193</head>
194<body>
195
196<a name=prelude-1><h1 class=prelude>Preface</h1></a>
197Better C than never.
198
199<h1 class=hidden>Table of Contents</h1>
200
201<!-- Table of Contents generated by Perl - HTML::Toc -->
202<ul class=toc_prelude1>
203   <li><a href=#prelude-1>Preface</a>
204   <li><a href=#prelude-2>Table of Figures</a>
205   <li><a href=#prelude-3>Table of Tables</a>
206   <li><a href=#prelude-4>Introduction</a>
207   <ul class=toc_part1>
208      <li>Part 1 &nbsp;<a href=#part-1>Disks</a>
209      <ul class=toc_h1>
210         <li>1. &nbsp;<a href=#h-1>Compiler Disk v1</a>
211         <ul class=toc_h2>
212            <li>1. &nbsp;<a href=#h-1.1>System</a>
213            <li>2. &nbsp;<a href=#h-1.2>Standard Library</a>
214         </ul>
215         <li>2. &nbsp;<a href=#h-2>Compiler Disk v2</a>
216         <ul class=toc_h2>
217            <li>1. &nbsp;<a href=#h-2.1>System</a>
218            <ul class=toc_h3>
219               <li>1. &nbsp;<a href=#h-2.1.1>parser.com</a>
220               <li>2. &nbsp;<a href=#h-2.1.2>compiler.com</a>
221               <li>3. &nbsp;<a href=#h-2.1.3>linker.com</a>
222            </ul>
223            <li>2. &nbsp;<a href=#h-2.2>Standard Library</a>
224         </ul>
225         <li>3. &nbsp;<a href=#h-3>Library System Disk</a>
226      </ul>
227      <li>Part 2 &nbsp;<a href=#part-2>Personal</a>
228      <ul class=toc_h1>
229         <li>4. &nbsp;<a href=#h-4>Tips & Tricks</a>
230      </ul>
231      <li>Part 3 &nbsp;<a href=#part-3>Appendixes</a>
232      <ul class=toc_appendix1>
233         <li>A &nbsp;<a href=#appendix-A>Functions Standard Library v1</a>
234         <li>B &nbsp;<a href=#appendix-B>Functions Standard Library v2</a>
235         <li>C &nbsp;<a href=#appendix-C>Functions Graphic Library</a>
236      </ul>
237   </ul>
238   <li><a href=#prelude-5>Bibliography</a>
239</ul>
240<!-- End of generated Table of Contents -->
241
242
243<a name=prelude-2><h1 class=prelude>Table of Figures</h1></a>
244
245<!-- Table of Contents generated by Perl - HTML::Toc -->
246<ol>
247   <li><a href=#Figure-1>Contents Compiler Disk v1</a>
248   <li><a href=#Figure-2>Contents Compiler Disk v2</a>
249</ol>
250<!-- End of generated Table of Contents -->
251
252
253<a name=prelude-3><h1 class=prelude>Table of Tables</h1></a>
254
255<!-- Table of Contents generated by Perl - HTML::Toc -->
256<ol>
257   <li><a href=#Table-1>Compile Steps</a>
258</ol>
259<!-- End of generated Table of Contents -->
260
261
262<a name=prelude-4><h1 class=prelude>Introduction</h1></a>
263Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
264<a name=Table-1><p class=captionTable>Table 1: &nbsp;Compile Steps</p></a>
265<ul><pre>
266   Parser
267   Compiler
268   Linker
269</pre></ul>
270
271<a name=part-1><h1 class=part>Part 1 &nbsp;Disks</h1></a>
272<a name=h-1><h1>1 &nbsp;Compiler Disk v1</h1></a>
273<img src=img.gif alt="Contents Compiler Disk v1">
274<a name=Figure-1><p class=captionFigure>Figure 1: &nbsp;Contents Compiler Disk v1</p></a>
275
276<a name=h-1.1><h2>1.1 &nbsp;System</h2></a>
277<a name=h-1.2><h2>1.2 &nbsp;Standard Library</h2></a>
278
279<a name=h-2><h1>2 &nbsp;Compiler Disk v2</h1></a>
280<img src=img.gif alt="Contents Compiler Disk v2">
281<a name=Figure-2><p class=captionFigure>Figure 2: &nbsp;Contents Compiler Disk v2</p></a>
282
283<a name=h-2.1><h2>2.1 &nbsp;System</h2></a>
284<a name=h-2.1.1><h3>2.1.1 &nbsp;parser.com</h3></a>
285<a name=h-2.1.2><h3>2.1.2 &nbsp;compiler.com</h3></a>
286<a name=h-2.1.3><h3>2.1.3 &nbsp;linker.com</h3></a>
287<a name=h-2.2><h2>2.2 &nbsp;Standard Library</h2></a>
288
289<a name=h-3><h1>3 &nbsp;Library System Disk</h1></a>
290<a name=part-2><h1 class=part>Part 2 &nbsp;Personal</h1></a>
291<a name=h-4><h1>4 &nbsp;Tips & Tricks</h1></a>
292<a name=part-3><h1 class=part>Part 3 &nbsp;Appendixes</h1></a>
293<a name=appendix-A><h1 class=appendix>A &nbsp;Functions Standard Library v1</h1></a>
294<a name=appendix-B><h1 class=appendix>B &nbsp;Functions Standard Library v2</h1></a>
295<a name=appendix-C><h1 class=appendix>C &nbsp;Functions Graphic Library</h1></a>
296<a name=prelude-5><h1 class=prelude>Bibliography</h1></a>
297</body>
298</html>
299EOT
300}  # TestInsertManualToc()
301
302
303#--- TestInsertManualForUpdating() --------------------------------------------
304# function: Test inserting ToC into manual.
305
306sub TestInsertManualForUpdating {
307	my $output;
308		# Create objects
309	my $toc          = new HTML::Toc;
310	my $tocOfFigures = new HTML::Toc;
311	my $tocOfTables  = new HTML::Toc;
312	my $tocUpdator   = new HTML::TocUpdator;
313
314		# Set ToC options
315	$toc->setOptions({
316		'doNestGroup'          => 1,
317		'doNumberToken'        => 1,
318		'insertionPoint'       => "after <!-- Table of Contents -->",
319		'templateLevel'        => \&AssembleTocLine,
320      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
321      'templateLevelEnd'     => '"</ul>\n"',
322		'templateTokenNumber'  => \&AssembleTokenNumber,
323      'tokenToToc'           => [{
324            'groupId'        => 'part',
325			   'doNumberToken'  => 1,
326            'level'          => 1,
327            'tokenBegin'     => '<h1 class=part>',
328         }, {
329            'tokenBegin'     => '<h1 class=-[appendix|prelude|hidden|part]>'
330         }, {
331            'tokenBegin'     => '<h2>',
332            'level'          => 2
333         }, {
334            'tokenBegin'     => '<h3>',
335            'level'          => 3
336         }, {
337            'groupId'        => 'appendix',
338            'tokenBegin'     => '<h1 class=appendix>',
339			   'numberingStyle' => 'upper-alpha',
340         }, {
341            'groupId'        => 'appendix',
342            'tokenBegin'     => '<h2 class=appendix>',
343            'level'          => 2
344         }, {
345            'groupId'        => 'prelude',
346            'tokenBegin'     => '<h1 class=prelude>',
347            'level'          => 1,
348			   'doNumberToken'  => 0,
349         }],
350	});
351	$tocOfFigures->setOptions({
352		'doNumberToken'        => 1,
353		'insertionPoint'       => "after <!-- Table of Figures -->",
354		'templateLevelBegin'   => '"<ol>\n"',
355		'templateLevelEnd'     => '"</ol>\n"',
356		'templateTokenNumber'  => '"Figure $node: &nbsp;"',
357		'tokenToToc'           => [{
358				'groupId'        => 'Figure',
359				'tokenBegin'     => '<p class=captionFigure>'
360			}]
361	});
362	$tocOfTables->setOptions({
363		'doNumberToken'        => 1,
364		'insertionPoint'       => "after <!-- Table of Tables -->",
365		'templateLevelBegin'   => '"<ol>\n"',
366		'templateLevelEnd'     => '"</ol>\n"',
367		'templateTokenNumber'  => '"Table $node: &nbsp;"',
368		'tokenToToc'           => [{
369				'groupId'        => 'Table',
370				'tokenBegin'     => '<p class=captionTable>'
371			}]
372	});
373		# Insert ToC
374	$tocUpdator->updateFile(
375		[$toc, $tocOfFigures, $tocOfTables],
376		't/ManualTest/manualTest1.htm', {
377			 'doUseGroupsGlobal' => 1,
378			 'output'            => \$output,
379			 'outputFile'        => 't/ManualTest/manualTest3.htm'
380		}
381	);
382	ok($output, <<EOT);
383<html>
384<head>
385   <title>Manual</title>
386    <style type="text/css">
387       ul.toc_appendix1 {
388         list-style-type: none;
389         margin-left: 0;
390         margin-top: 1em;
391         margin-bottom: 1em;
392       }
393       ul.toc_h1 {
394         list-style-type: none;
395         margin-left: 1;
396         margin-top: 1em;
397         margin-bottom: 1em;
398       }
399       ul.toc_h2 {
400         list-style-type: none;
401       }
402       ul.toc_h3 {
403         list-style-type: none;
404       }
405       ul.toc_part1 {
406         list-style-type: none;
407         margin-left: 1;
408         margin-top: 1em;
409         margin-bottom: 1em;
410       }
411       ul.toc_prelude1 {
412         list-style: none;
413       }
414       p.captionFigure {
415         font-style: italic;
416         font-weight: bold;
417       }
418       p.captionTable {
419         font-style: italic;
420         font-weight: bold;
421       }
422    </style>
423</head>
424<body>
425
426<!-- #BeginTocAnchorNameBegin --><a name=prelude-1><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Preface</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
427Better C than never.
428
429<h1 class=hidden>Table of Contents</h1>
430<!-- Table of Contents --><!-- #BeginToc -->
431<!-- Table of Contents generated by Perl - HTML::Toc -->
432<ul class=toc_prelude1>
433   <li><a href=#prelude-1>Preface</a>
434   <li><a href=#prelude-2>Table of Figures</a>
435   <li><a href=#prelude-3>Table of Tables</a>
436   <li><a href=#prelude-4>Introduction</a>
437   <ul class=toc_part1>
438      <li>Part 1 &nbsp;<a href=#part-1>Disks</a>
439      <ul class=toc_h1>
440         <li>1. &nbsp;<a href=#h-1>Compiler Disk v1</a>
441         <ul class=toc_h2>
442            <li>1. &nbsp;<a href=#h-1.1>System</a>
443            <li>2. &nbsp;<a href=#h-1.2>Standard Library</a>
444         </ul>
445         <li>2. &nbsp;<a href=#h-2>Compiler Disk v2</a>
446         <ul class=toc_h2>
447            <li>1. &nbsp;<a href=#h-2.1>System</a>
448            <ul class=toc_h3>
449               <li>1. &nbsp;<a href=#h-2.1.1>parser.com</a>
450               <li>2. &nbsp;<a href=#h-2.1.2>compiler.com</a>
451               <li>3. &nbsp;<a href=#h-2.1.3>linker.com</a>
452            </ul>
453            <li>2. &nbsp;<a href=#h-2.2>Standard Library</a>
454         </ul>
455         <li>3. &nbsp;<a href=#h-3>Library System Disk</a>
456      </ul>
457      <li>Part 2 &nbsp;<a href=#part-2>Personal</a>
458      <ul class=toc_h1>
459         <li>4. &nbsp;<a href=#h-4>Tips & Tricks</a>
460      </ul>
461      <li>Part 3 &nbsp;<a href=#part-3>Appendixes</a>
462      <ul class=toc_appendix1>
463         <li>A &nbsp;<a href=#appendix-A>Functions Standard Library v1</a>
464         <li>B &nbsp;<a href=#appendix-B>Functions Standard Library v2</a>
465         <li>C &nbsp;<a href=#appendix-C>Functions Graphic Library</a>
466      </ul>
467   </ul>
468   <li><a href=#prelude-5>Bibliography</a>
469</ul>
470<!-- End of generated Table of Contents -->
471<!-- #EndToc -->
472
473<!-- #BeginTocAnchorNameBegin --><a name=prelude-2><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Figures</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
474<!-- Table of Figures --><!-- #BeginToc -->
475<!-- Table of Contents generated by Perl - HTML::Toc -->
476<ol>
477   <li><a href=#Figure-1>Contents Compiler Disk v1</a>
478   <li><a href=#Figure-2>Contents Compiler Disk v2</a>
479</ol>
480<!-- End of generated Table of Contents -->
481<!-- #EndToc -->
482
483<!-- #BeginTocAnchorNameBegin --><a name=prelude-3><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Tables</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
484<!-- Table of Tables --><!-- #BeginToc -->
485<!-- Table of Contents generated by Perl - HTML::Toc -->
486<ol>
487   <li><a href=#Table-1>Compile Steps</a>
488</ol>
489<!-- End of generated Table of Contents -->
490<!-- #EndToc -->
491
492<!-- #BeginTocAnchorNameBegin --><a name=prelude-4><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Introduction</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
493Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
494<!-- #BeginTocAnchorNameBegin --><a name=Table-1><!-- #EndTocAnchorNameBegin --><p class=captionTable><!-- #BeginTocNumber -->Table 1: &nbsp;<!-- #EndTocNumber -->Compile Steps</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
495<ul><pre>
496   Parser
497   Compiler
498   Linker
499</pre></ul>
500
501<!-- #BeginTocAnchorNameBegin --><a name=part-1><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 1 &nbsp;<!-- #EndTocNumber -->Disks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
502<!-- #BeginTocAnchorNameBegin --><a name=h-1><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->1 &nbsp;<!-- #EndTocNumber -->Compiler Disk v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
503<img src=img.gif alt="Contents Compiler Disk v1">
504<!-- #BeginTocAnchorNameBegin --><a name=Figure-1><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 1: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v1</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
505
506<!-- #BeginTocAnchorNameBegin --><a name=h-1.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
507<!-- #BeginTocAnchorNameBegin --><a name=h-1.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
508
509<!-- #BeginTocAnchorNameBegin --><a name=h-2><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->2 &nbsp;<!-- #EndTocNumber -->Compiler Disk v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
510<img src=img.gif alt="Contents Compiler Disk v2">
511<!-- #BeginTocAnchorNameBegin --><a name=Figure-2><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 2: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v2</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
512
513<!-- #BeginTocAnchorNameBegin --><a name=h-2.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
514<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.1><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.1 &nbsp;<!-- #EndTocNumber -->parser.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
515<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.2><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.2 &nbsp;<!-- #EndTocNumber -->compiler.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
516<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.3><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.3 &nbsp;<!-- #EndTocNumber -->linker.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
517<!-- #BeginTocAnchorNameBegin --><a name=h-2.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
518
519<!-- #BeginTocAnchorNameBegin --><a name=h-3><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->3 &nbsp;<!-- #EndTocNumber -->Library System Disk</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
520<!-- #BeginTocAnchorNameBegin --><a name=part-2><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 2 &nbsp;<!-- #EndTocNumber -->Personal</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
521<!-- #BeginTocAnchorNameBegin --><a name=h-4><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->4 &nbsp;<!-- #EndTocNumber -->Tips & Tricks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
522<!-- #BeginTocAnchorNameBegin --><a name=part-3><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 3 &nbsp;<!-- #EndTocNumber -->Appendixes</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
523<!-- #BeginTocAnchorNameBegin --><a name=appendix-A><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->A &nbsp;<!-- #EndTocNumber -->Functions Standard Library v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
524<!-- #BeginTocAnchorNameBegin --><a name=appendix-B><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->B &nbsp;<!-- #EndTocNumber -->Functions Standard Library v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
525<!-- #BeginTocAnchorNameBegin --><a name=appendix-C><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->C &nbsp;<!-- #EndTocNumber -->Functions Graphic Library</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
526<!-- #BeginTocAnchorNameBegin --><a name=prelude-5><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Bibliography</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
527</body>
528</html>
529EOT
530}  # TestInsertManualForUpdating()
531
532
533#--- TestUpdateManual() -------------------------------------------------------
534# function: Test inserting ToC into manual.
535
536sub TestUpdateManual {
537	my $output;
538		# Create objects
539	my $toc          = new HTML::Toc;
540	my $tocOfFigures = new HTML::Toc;
541	my $tocOfTables  = new HTML::Toc;
542	my $tocUpdator   = new HTML::TocUpdator;
543
544		# Set ToC options
545	$toc->setOptions({
546		'doNestGroup'          => 1,
547		'doNumberToken'        => 1,
548		'insertionPoint'       => "after <!-- Table of Contents -->",
549		'templateLevel'        => \&AssembleTocLine,
550      'templateLevelBegin'   => '"<ul class=toc_$groupId$level>\n"',
551      'templateLevelEnd'     => '"</ul>\n"',
552		'templateTokenNumber'  => \&AssembleTokenNumber,
553      'tokenToToc'           => [{
554            'groupId'        => 'part',
555			   'doNumberToken'  => 1,
556            'level'          => 1,
557            'tokenBegin'     => '<h1 class=part>',
558         }, {
559            'tokenBegin'     => '<h1 class=-[appendix|prelude|hidden|part]>'
560         }, {
561            'tokenBegin'     => '<h2>',
562            'level'          => 2
563         }, {
564            'tokenBegin'     => '<h3>',
565            'level'          => 3
566         }, {
567            'groupId'        => 'appendix',
568            'tokenBegin'     => '<h1 class=appendix>',
569			   'numberingStyle' => 'upper-alpha',
570         }, {
571            'groupId'        => 'appendix',
572            'tokenBegin'     => '<h2 class=appendix>',
573            'level'          => 2
574         }, {
575            'groupId'        => 'prelude',
576            'tokenBegin'     => '<h1 class=prelude>',
577            'level'          => 1,
578			   'doNumberToken'  => 0,
579         }],
580	});
581	$tocOfFigures->setOptions({
582		'doNumberToken'        => 1,
583		'insertionPoint'       => "after <!-- Table of Figures -->",
584		'templateLevelBegin'   => '"<ol>\n"',
585		'templateLevelEnd'     => '"</ol>\n"',
586		'templateTokenNumber'  => '"Figure $node: &nbsp;"',
587		'tokenToToc'           => [{
588				'groupId'        => 'Figure',
589				'tokenBegin'     => '<p class=captionFigure>'
590			}]
591	});
592	$tocOfTables->setOptions({
593		'doNumberToken'        => 1,
594		'insertionPoint'       => "after <!-- Table of Tables -->",
595		'templateLevelBegin'   => '"<ol>\n"',
596		'templateLevelEnd'     => '"</ol>\n"',
597		'templateTokenNumber'  => '"Table $node: &nbsp;"',
598		'tokenToToc'           => [{
599				'groupId'        => 'Table',
600				'tokenBegin'     => '<p class=captionTable>'
601			}]
602	});
603		# Insert ToC
604	$tocUpdator->updateFile(
605		[$toc, $tocOfFigures, $tocOfTables],
606		't/ManualTest/manualTest3.htm', {
607			 'doUseGroupsGlobal' => 1,
608			 'output'            => \$output,
609			 'outputFile'        => 't/ManualTest/manualTest4.htm'
610		}
611	);
612	ok($output, <<EOT);
613<html>
614<head>
615   <title>Manual</title>
616    <style type="text/css">
617       ul.toc_appendix1 {
618         list-style-type: none;
619         margin-left: 0;
620         margin-top: 1em;
621         margin-bottom: 1em;
622       }
623       ul.toc_h1 {
624         list-style-type: none;
625         margin-left: 1;
626         margin-top: 1em;
627         margin-bottom: 1em;
628       }
629       ul.toc_h2 {
630         list-style-type: none;
631       }
632       ul.toc_h3 {
633         list-style-type: none;
634       }
635       ul.toc_part1 {
636         list-style-type: none;
637         margin-left: 1;
638         margin-top: 1em;
639         margin-bottom: 1em;
640       }
641       ul.toc_prelude1 {
642         list-style: none;
643       }
644       p.captionFigure {
645         font-style: italic;
646         font-weight: bold;
647       }
648       p.captionTable {
649         font-style: italic;
650         font-weight: bold;
651       }
652    </style>
653</head>
654<body>
655
656<!-- #BeginTocAnchorNameBegin --><a name=prelude-1><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Preface</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
657Better C than never.
658
659<h1 class=hidden>Table of Contents</h1>
660<!-- Table of Contents --><!-- #BeginToc -->
661<!-- Table of Contents generated by Perl - HTML::Toc -->
662<ul class=toc_prelude1>
663   <li><a href=#prelude-1>Preface</a>
664   <li><a href=#prelude-2>Table of Figures</a>
665   <li><a href=#prelude-3>Table of Tables</a>
666   <li><a href=#prelude-4>Introduction</a>
667   <ul class=toc_part1>
668      <li>Part 1 &nbsp;<a href=#part-1>Disks</a>
669      <ul class=toc_h1>
670         <li>1. &nbsp;<a href=#h-1>Compiler Disk v1</a>
671         <ul class=toc_h2>
672            <li>1. &nbsp;<a href=#h-1.1>System</a>
673            <li>2. &nbsp;<a href=#h-1.2>Standard Library</a>
674         </ul>
675         <li>2. &nbsp;<a href=#h-2>Compiler Disk v2</a>
676         <ul class=toc_h2>
677            <li>1. &nbsp;<a href=#h-2.1>System</a>
678            <ul class=toc_h3>
679               <li>1. &nbsp;<a href=#h-2.1.1>parser.com</a>
680               <li>2. &nbsp;<a href=#h-2.1.2>compiler.com</a>
681               <li>3. &nbsp;<a href=#h-2.1.3>linker.com</a>
682            </ul>
683            <li>2. &nbsp;<a href=#h-2.2>Standard Library</a>
684         </ul>
685         <li>3. &nbsp;<a href=#h-3>Library System Disk</a>
686      </ul>
687      <li>Part 2 &nbsp;<a href=#part-2>Personal</a>
688      <ul class=toc_h1>
689         <li>4. &nbsp;<a href=#h-4>Tips & Tricks</a>
690      </ul>
691      <li>Part 3 &nbsp;<a href=#part-3>Appendixes</a>
692      <ul class=toc_appendix1>
693         <li>A &nbsp;<a href=#appendix-A>Functions Standard Library v1</a>
694         <li>B &nbsp;<a href=#appendix-B>Functions Standard Library v2</a>
695         <li>C &nbsp;<a href=#appendix-C>Functions Graphic Library</a>
696      </ul>
697   </ul>
698   <li><a href=#prelude-5>Bibliography</a>
699</ul>
700<!-- End of generated Table of Contents -->
701<!-- #EndToc -->
702
703<!-- #BeginTocAnchorNameBegin --><a name=prelude-2><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Figures</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
704<!-- Table of Figures --><!-- #BeginToc -->
705<!-- Table of Contents generated by Perl - HTML::Toc -->
706<ol>
707   <li><a href=#Figure-1>Contents Compiler Disk v1</a>
708   <li><a href=#Figure-2>Contents Compiler Disk v2</a>
709</ol>
710<!-- End of generated Table of Contents -->
711<!-- #EndToc -->
712
713<!-- #BeginTocAnchorNameBegin --><a name=prelude-3><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Table of Tables</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
714<!-- Table of Tables --><!-- #BeginToc -->
715<!-- Table of Contents generated by Perl - HTML::Toc -->
716<ol>
717   <li><a href=#Table-1>Compile Steps</a>
718</ol>
719<!-- End of generated Table of Contents -->
720<!-- #EndToc -->
721
722<!-- #BeginTocAnchorNameBegin --><a name=prelude-4><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Introduction</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
723Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.
724<!-- #BeginTocAnchorNameBegin --><a name=Table-1><!-- #EndTocAnchorNameBegin --><p class=captionTable><!-- #BeginTocNumber -->Table 1: &nbsp;<!-- #EndTocNumber -->Compile Steps</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
725<ul><pre>
726   Parser
727   Compiler
728   Linker
729</pre></ul>
730
731<!-- #BeginTocAnchorNameBegin --><a name=part-1><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 1 &nbsp;<!-- #EndTocNumber -->Disks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
732<!-- #BeginTocAnchorNameBegin --><a name=h-1><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->1 &nbsp;<!-- #EndTocNumber -->Compiler Disk v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
733<img src=img.gif alt="Contents Compiler Disk v1">
734<!-- #BeginTocAnchorNameBegin --><a name=Figure-1><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 1: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v1</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
735
736<!-- #BeginTocAnchorNameBegin --><a name=h-1.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
737<!-- #BeginTocAnchorNameBegin --><a name=h-1.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->1.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
738
739<!-- #BeginTocAnchorNameBegin --><a name=h-2><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->2 &nbsp;<!-- #EndTocNumber -->Compiler Disk v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
740<img src=img.gif alt="Contents Compiler Disk v2">
741<!-- #BeginTocAnchorNameBegin --><a name=Figure-2><!-- #EndTocAnchorNameBegin --><p class=captionFigure><!-- #BeginTocNumber -->Figure 2: &nbsp;<!-- #EndTocNumber -->Contents Compiler Disk v2</p><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
742
743<!-- #BeginTocAnchorNameBegin --><a name=h-2.1><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.1 &nbsp;<!-- #EndTocNumber -->System</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
744<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.1><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.1 &nbsp;<!-- #EndTocNumber -->parser.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
745<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.2><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.2 &nbsp;<!-- #EndTocNumber -->compiler.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
746<!-- #BeginTocAnchorNameBegin --><a name=h-2.1.3><!-- #EndTocAnchorNameBegin --><h3><!-- #BeginTocNumber -->2.1.3 &nbsp;<!-- #EndTocNumber -->linker.com</h3><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
747<!-- #BeginTocAnchorNameBegin --><a name=h-2.2><!-- #EndTocAnchorNameBegin --><h2><!-- #BeginTocNumber -->2.2 &nbsp;<!-- #EndTocNumber -->Standard Library</h2><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
748
749<!-- #BeginTocAnchorNameBegin --><a name=h-3><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->3 &nbsp;<!-- #EndTocNumber -->Library System Disk</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
750<!-- #BeginTocAnchorNameBegin --><a name=part-2><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 2 &nbsp;<!-- #EndTocNumber -->Personal</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
751<!-- #BeginTocAnchorNameBegin --><a name=h-4><!-- #EndTocAnchorNameBegin --><h1><!-- #BeginTocNumber -->4 &nbsp;<!-- #EndTocNumber -->Tips & Tricks</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
752<!-- #BeginTocAnchorNameBegin --><a name=part-3><!-- #EndTocAnchorNameBegin --><h1 class=part><!-- #BeginTocNumber -->Part 3 &nbsp;<!-- #EndTocNumber -->Appendixes</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
753<!-- #BeginTocAnchorNameBegin --><a name=appendix-A><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->A &nbsp;<!-- #EndTocNumber -->Functions Standard Library v1</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
754<!-- #BeginTocAnchorNameBegin --><a name=appendix-B><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->B &nbsp;<!-- #EndTocNumber -->Functions Standard Library v2</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
755<!-- #BeginTocAnchorNameBegin --><a name=appendix-C><!-- #EndTocAnchorNameBegin --><h1 class=appendix><!-- #BeginTocNumber -->C &nbsp;<!-- #EndTocNumber -->Functions Graphic Library</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
756<!-- #BeginTocAnchorNameBegin --><a name=prelude-5><!-- #EndTocAnchorNameBegin --><h1 class=prelude>Bibliography</h1><!-- #BeginTocAnchorNameEnd --></a><!-- #EndTocAnchorNameEnd -->
757</body>
758</html>
759EOT
760}  # TestUpdateManual()
761
762
763	# Test inserting ToC into manual
764TestInsertManualToc();
765	# Test inserting ToC with update tokens into manual
766TestInsertManualForUpdating();
767	# Test updating ToC
768TestUpdateManual();
769