#--- manual.t ----------------------------------------------------------------- # function: Test HTML::ToC generating a manual. use strict; use Test; BEGIN { plan tests => 3; } use HTML::Toc; use HTML::TocGenerator; use HTML::TocInsertor; use HTML::TocUpdator; #--- AssembleTocLine() -------------------------------------------------------- # function: Assemble ToC line. sub AssembleTocLine { # Get arguments my ($aLevel, $aGroupId, $aNode, $aSequenceNr, $aText) = @_; # Local variables my ($result); # Assemble ToC line SWITCH: { if ($aGroupId eq "prelude") { $result = "
  • $aText\n"; last SWITCH; } if ($aGroupId eq "part") { $result = "
  • Part $aNode  $aText\n"; last SWITCH; } if ($aGroupId eq "h") { $result = "
  • $aSequenceNr.  $aText\n"; last SWITCH; } else { $result = "
  • $aNode  $aText\n"; last SWITCH; } } # Return value return $result; } # AssembleTocLine() #--- AssembleTokenNumber() ---------------------------------------------------- # function: Assemble token number. sub AssembleTokenNumber { # Get arguments my ($aNode, $aGroupId, $aFile, $aGroupLevel, $aLevel, $aToc) = @_; # Local variables my ($result); # Assemble token number SWITCH: { if ($aGroupId eq "part") { $result = "Part $aNode  "; last SWITCH; } else { $result = "$aNode  "; last SWITCH; } } # Return value return $result; } # AssembleTokenNumber() #--- TestInsertManualToc ------------------------------------------------------ # function: Test inserting ToC into manual. sub TestInsertManualToc { my $output; # Create objects my $toc = new HTML::Toc; my $tocOfFigures = new HTML::Toc; my $tocOfTables = new HTML::Toc; my $tocInsertor = new HTML::TocInsertor; # Set ToC options $toc->setOptions({ 'doNestGroup' => 1, 'doNumberToken' => 1, 'insertionPoint' => "replace ", 'templateLevel' => \&AssembleTocLine, 'templateLevelBegin' => '"\n"', 'templateTokenNumber' => \&AssembleTokenNumber, 'tokenToToc' => [{ 'groupId' => 'part', 'doNumberToken' => 1, 'level' => 1, 'tokenBegin' => '

    ', }, { 'tokenBegin' => '

    ' }, { 'tokenBegin' => '

    ', 'level' => 2 }, { 'tokenBegin' => '

    ', 'level' => 3 }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'numberingStyle' => 'upper-alpha', }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'level' => 2 }, { 'groupId' => 'prelude', 'tokenBegin' => '

    ', 'level' => 1, 'doNumberToken' => 0, }], }); $tocOfFigures->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "replace ", 'templateLevelBegin' => '"
      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Figure $node:  "', 'tokenToToc' => [{ 'groupId' => 'Figure', 'tokenBegin' => '

    ' }] }); $tocOfTables->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "replace ", 'templateLevelBegin' => '"

      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Table $node:  "', 'tokenToToc' => [{ 'groupId' => 'Table', 'tokenBegin' => '

    ' }] }); # Insert ToC $tocInsertor->insertIntoFile( [$toc, $tocOfFigures, $tocOfTables], 't/ManualTest/manualTest1.htm', { 'doUseGroupsGlobal' => 1, 'output' => \$output, 'outputFile' => 't/ManualTest/manualTest2.htm' } ); ok($output, < Manual

    Preface

    Better C than never.

    Table of Contents

    Table of Figures

    1. Contents Compiler Disk v1
    2. Contents Compiler Disk v2

    Table of Tables

    1. Compile Steps

    Introduction

    Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.

    Table 1:  Compile Steps

    Part 1  Disks

    1  Compiler Disk v1

    Contents Compiler Disk v1

    Figure 1:  Contents Compiler Disk v1

    1.1  System

    1.2  Standard Library

    2  Compiler Disk v2

    Contents Compiler Disk v2

    Figure 2:  Contents Compiler Disk v2

    2.1  System

    2.1.1  parser.com

    2.1.2  compiler.com

    2.1.3  linker.com

    2.2  Standard Library

    3  Library System Disk

    Part 2  Personal

    4  Tips & Tricks

    Part 3  Appendixes

    A  Functions Standard Library v1

    B  Functions Standard Library v2

    C  Functions Graphic Library

    Bibliography

    EOT } # TestInsertManualToc() #--- TestInsertManualForUpdating() -------------------------------------------- # function: Test inserting ToC into manual. sub TestInsertManualForUpdating { my $output; # Create objects my $toc = new HTML::Toc; my $tocOfFigures = new HTML::Toc; my $tocOfTables = new HTML::Toc; my $tocUpdator = new HTML::TocUpdator; # Set ToC options $toc->setOptions({ 'doNestGroup' => 1, 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevel' => \&AssembleTocLine, 'templateLevelBegin' => '"\n"', 'templateTokenNumber' => \&AssembleTokenNumber, 'tokenToToc' => [{ 'groupId' => 'part', 'doNumberToken' => 1, 'level' => 1, 'tokenBegin' => '

    ', }, { 'tokenBegin' => '

    ' }, { 'tokenBegin' => '

    ', 'level' => 2 }, { 'tokenBegin' => '

    ', 'level' => 3 }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'numberingStyle' => 'upper-alpha', }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'level' => 2 }, { 'groupId' => 'prelude', 'tokenBegin' => '

    ', 'level' => 1, 'doNumberToken' => 0, }], }); $tocOfFigures->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevelBegin' => '"
      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Figure $node:  "', 'tokenToToc' => [{ 'groupId' => 'Figure', 'tokenBegin' => '

    ' }] }); $tocOfTables->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevelBegin' => '"

      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Table $node:  "', 'tokenToToc' => [{ 'groupId' => 'Table', 'tokenBegin' => '

    ' }] }); # Insert ToC $tocUpdator->updateFile( [$toc, $tocOfFigures, $tocOfTables], 't/ManualTest/manualTest1.htm', { 'doUseGroupsGlobal' => 1, 'output' => \$output, 'outputFile' => 't/ManualTest/manualTest3.htm' } ); ok($output, < Manual

    Preface

    Better C than never.

    Table of Contents

    Table of Figures

    1. Contents Compiler Disk v1
    2. Contents Compiler Disk v2

    Table of Tables

    1. Compile Steps

    Introduction

    Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.

    Table 1:  Compile Steps

    Part 1  Disks

    1  Compiler Disk v1

    Contents Compiler Disk v1

    Figure 1:  Contents Compiler Disk v1

    1.1  System

    1.2  Standard Library

    2  Compiler Disk v2

    Contents Compiler Disk v2

    Figure 2:  Contents Compiler Disk v2

    2.1  System

    2.1.1  parser.com

    2.1.2  compiler.com

    2.1.3  linker.com

    2.2  Standard Library

    3  Library System Disk

    Part 2  Personal

    4  Tips & Tricks

    Part 3  Appendixes

    A  Functions Standard Library v1

    B  Functions Standard Library v2

    C  Functions Graphic Library

    Bibliography

    EOT } # TestInsertManualForUpdating() #--- TestUpdateManual() ------------------------------------------------------- # function: Test inserting ToC into manual. sub TestUpdateManual { my $output; # Create objects my $toc = new HTML::Toc; my $tocOfFigures = new HTML::Toc; my $tocOfTables = new HTML::Toc; my $tocUpdator = new HTML::TocUpdator; # Set ToC options $toc->setOptions({ 'doNestGroup' => 1, 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevel' => \&AssembleTocLine, 'templateLevelBegin' => '"\n"', 'templateTokenNumber' => \&AssembleTokenNumber, 'tokenToToc' => [{ 'groupId' => 'part', 'doNumberToken' => 1, 'level' => 1, 'tokenBegin' => '

    ', }, { 'tokenBegin' => '

    ' }, { 'tokenBegin' => '

    ', 'level' => 2 }, { 'tokenBegin' => '

    ', 'level' => 3 }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'numberingStyle' => 'upper-alpha', }, { 'groupId' => 'appendix', 'tokenBegin' => '

    ', 'level' => 2 }, { 'groupId' => 'prelude', 'tokenBegin' => '

    ', 'level' => 1, 'doNumberToken' => 0, }], }); $tocOfFigures->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevelBegin' => '"
      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Figure $node:  "', 'tokenToToc' => [{ 'groupId' => 'Figure', 'tokenBegin' => '

    ' }] }); $tocOfTables->setOptions({ 'doNumberToken' => 1, 'insertionPoint' => "after ", 'templateLevelBegin' => '"

      \n"', 'templateLevelEnd' => '"
    \n"', 'templateTokenNumber' => '"Table $node:  "', 'tokenToToc' => [{ 'groupId' => 'Table', 'tokenBegin' => '

    ' }] }); # Insert ToC $tocUpdator->updateFile( [$toc, $tocOfFigures, $tocOfTables], 't/ManualTest/manualTest3.htm', { 'doUseGroupsGlobal' => 1, 'output' => \$output, 'outputFile' => 't/ManualTest/manualTest4.htm' } ); ok($output, < Manual

    Preface

    Better C than never.

    Table of Contents

    Table of Figures

    1. Contents Compiler Disk v1
    2. Contents Compiler Disk v2

    Table of Tables

    1. Compile Steps

    Introduction

    Thanks to standardisation and the excellent work of the QWERTY corporation it is possible to learn C with almost any C manual.

    Table 1:  Compile Steps

    Part 1  Disks

    1  Compiler Disk v1

    Contents Compiler Disk v1

    Figure 1:  Contents Compiler Disk v1

    1.1  System

    1.2  Standard Library

    2  Compiler Disk v2

    Contents Compiler Disk v2

    Figure 2:  Contents Compiler Disk v2

    2.1  System

    2.1.1  parser.com

    2.1.2  compiler.com

    2.1.3  linker.com

    2.2  Standard Library

    3  Library System Disk

    Part 2  Personal

    4  Tips & Tricks

    Part 3  Appendixes

    A  Functions Standard Library v1

    B  Functions Standard Library v2

    C  Functions Graphic Library

    Bibliography

    EOT } # TestUpdateManual() # Test inserting ToC into manual TestInsertManualToc(); # Test inserting ToC with update tokens into manual TestInsertManualForUpdating(); # Test updating ToC TestUpdateManual();