1use strict; 2 3 4sub WalkTree 5{ 6 my $tree = shift; # a Pod::Tree object 7 my $root = $tree->get_root; # the root node of the tree 8 WalkNode($root); 9} 10 11 12sub WalkNode 13{ 14 my $node = shift; 15 my $type = $node->get_type; 16 17 for ($type) 18 { 19 /root/ and WalkRoot ($node), last; 20 /verbatim/ and WalkVerbatim($node), last; 21 /ordinary/ and WalkOrdinary($node), last; 22 /command/ and WalkCommand ($node), last; 23 /sequence/ and WalkSequence($node), last; 24 /text/ and WalkText ($node), last; 25 /list/ and WalkList ($node), last; 26 /item/ and WalkItem ($node), last; 27 /for/ and WalkFor ($node), last; 28 } 29} 30 31 32sub WalkRoot 33{ 34 my $node = shift; 35 WalkChildren($node); 36} 37 38 39sub WalkVerbatim 40{ 41 my $node = shift; 42 my $text = $node->get_text; 43} 44 45 46sub WalkOrdinary 47{ 48 my $node = shift; 49 WalkChildren($node); 50} 51 52 53sub WalkCommand 54{ 55 my $node = shift; 56 my $command = node->get_command; 57 WalkChildren($node); 58} 59 60 61sub WalkSequence 62{ 63 my $node = shift; 64 my $letter = node->get_letter; 65 66 is_link $node and do 67 { 68 my $target = $node->get_target; 69 my $page = $target->get_page; 70 my $section = $target->get_section; 71 }; 72 73 WalkChildren($node); 74} 75 76 77sub WalkText 78{ 79 my $node = shift; 80 my $text = $node->get_text; 81} 82 83 84sub WalkList 85{ 86 my $node = shift; 87 my $indent = $node->get_arg; 88 my $list_type = $node->get_list_type; 89 90 for ($list_type) 91 { 92 /bullet/ and last; 93 /number/ and last; 94 /text/ and last; 95 } 96 97 WalkChildren($node); # text of the =over paragraph 98 WalkSiblings($node); # items in the list 99} 100 101 102sub WalkItem 103{ 104 my $node = shift; 105 my $item_type = $node->get_list_type; 106 107 for ($item_type) # could be different from $list_type 108 { 109 /bullet/ and last; 110 /number/ and last; 111 /text/ and last; 112 } 113 114 WalkChildren($node); # text of the =item paragraph 115} 116 117 118sub WalkFor 119{ 120 my $node = shift; 121 my $formatter = $node->get_arg; 122 my $text = $node->get_text; 123} 124 125 126sub WalkChildren 127{ 128 my $node = shift; 129 my $children = $node->get_children; 130 131 for my $child (@$children) 132 { 133 WalkNode($child); 134 } 135} 136 137 138sub WalkSiblings 139{ 140 my $node = shift; 141 my $siblings = $node->get_siblings; 142 143 for my $sibling (@$siblings) 144 { 145 WalkNode($sibling); 146 } 147} 148 149