1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
|
# This is based on the scriptbasic style
$DO_CONTENTS = 1;
$INLINE_CONTENTS = 1;
@SECTION_BUTTONS =
(
'Back', 'Forward', ' ', 'Contents', 'Index', 'About'
);
@CHAPTER_BUTTONS =
(
'Back', 'Forward', ' ', 'Contents', 'Index', 'About'
);
@MISC_BUTTONS = ('Contents', 'Index', 'About');
@SECTION_FOOTER_BUTTONS = ('Contents', 'Index', 'About');
@NODE_FOOTER_BUTTONS = ('Back', 'Forward');
$WORDS_IN_PAGE = undef;
$SHOW_MENU = 0;
$BIG_RULE = '<hr size="2">';
push @command_handler_init, \&book_initialize_variables;
sub book_print_sub_toc($$);
sub book_print_sub_toc($$)
{
my $parent_element = shift;
my $element = shift;
my $result = "<li> ".&$anchor('', main::href($element, $parent_element->{'file'}), $element->{'text'}) . " </li>\n";
#print STDERR "SUB_TOC $element->{'text'}\n"; #sleep 1;
if (exists($element->{'child'}))
{
#print STDERR "SUB_TOC child $element->{'child'}->{'text'}\n";
$result .= "<li><ul${NO_BULLET_LIST_ATTRIBUTE}>\n". book_print_sub_toc($parent_element, $element->{'child'}) ."</ul></li>\n";
}
if (exists($element->{'sectionnext'}))
{
#print STDERR "SUB_TOC next($element->{'text'}) $element->{'next'}->{'text'}\n";
$result .= book_print_sub_toc($parent_element, $element->{'sectionnext'});
}
return $result;
}
sub book_print_up_toc($)
{
my $element = shift;
my $result = '';
my $current_element = $element;
my @elements;
while (defined($current_element->{'sectionup'}) and ($current_element->{'sectionup'} ne $current_element))
{
unshift (@elements, $current_element->{'sectionup'});
$current_element = $current_element->{'sectionup'};
}
#print $fh "<ul>" . &$anchor('', $Texi2HTML::HREF{Contents}, '[' . $Texi2HTML::NAME{Contents} . ']') . " <br>\n";
my $elem = shift @elements;
$result .= "<ul${NO_BULLET_LIST_ATTRIBUTE}><li>" . &$anchor('', main::href($elem, $element->{'file'}), $elem->{'text'}) . " </li>\n";
foreach my $elem (@elements)
{
$result .= "<li><ul${NO_BULLET_LIST_ATTRIBUTE}><li>" . &$anchor('', main::href($elem, $element->{'file'}), $elem->{'text'}) . " </li>\n";
}
foreach my $elem (@elements)
{
$result .= "</ul></li>\n";
}
$result .= "</ul>\n";
}
#$print_section = \&book_print_section;
$print_element_header = \&book_print_element_header;
$print_Top = \&book_print_Top;
$print_Toc = \&book_print_Toc;
$element_file_name = \&book_element_file_name;
sub book_print_element_header($$)
{
my $first_in_page = shift;
my $previous_is_top = shift;
my $buttons = \@SECTION_BUTTONS;
my $result;
if ($first_in_page and $SECTION_NAVIGATION)
{
#print_up_toc($fh, $Texi2HTML::THIS_ELEMENT) if ($SPLIT eq 'node');
$result = book_print_up_toc($Texi2HTML::THIS_ELEMENT);
$result .= &$print_head_navigation(undef, $buttons);
}
else
{ # got to do this here, as it isn't done in print_head_navigation
$result = &$print_navigation($buttons) if ($SECTION_NAVIGATION);
}
return $result;
}
sub book_print_Top($$)
{
my $fh = shift;
my $has_top_heading = shift;
my $buttons = \@MISC_BUTTONS;
# head navigation is printed with heading, and is in THIS_SECTION
# &$print_head_navigation($fh, $buttons) if ($SPLIT or $SECTION_NAVIGATION);
my ($titlepage_text, $titlepage_no_texi, $titlepage_simple_text) = main::do_special_region_lines('titlepage',$Texi2HTML::THISDOC{'state'});
&$titlepage([],$titlepage_text, $titlepage_no_texi, $titlepage_simple_text);
print $fh $Texi2HTML::TITLEPAGE;
print $fh "<h1 class=\"settitle\">$Texi2HTML::NAME{Top}</h1>\n"
unless ($has_top_heading);
main::print_lines($fh, $Texi2HTML::THIS_SECTION);
if (!$INLINE_CONTENTS and !$Texi2HTML::THISDOC{'setcontentsaftertitlepage'})
{
print $fh '<h2> ' . $Texi2HTML::NAME{'Contents'} . "</h2>\n" ;
main::print_lines($fh, $Texi2HTML::TOC_LINES);
}
}
sub book_print_Toc
{
my $fh = shift;
&$print_page_head($fh) if $SPLIT;
#print $fh $Texi2HTML::TITLEPAGE;
print $fh '<h2> ' . $Texi2HTML::NAME{'Contents'} . "</h2>\n" ;
main::print_lines($fh);
&$print_misc_footer($fh, \@MISC_BUTTONS);
}
my $unumbered_nr;
my $previous_nr;
my $previous_file_name;
sub book_initialize_variables()
{
$unumbered_nr = -1;
$previous_nr = undef;
$previous_file_name = undef;
}
sub book_element_file_name($$$)
{
my $element = shift;
my $type = shift;
my $prefix = shift;
return undef if ($NODE_FILES or !$SPLIT);
return undef if (!defined($element));
if (defined($previous_nr) and ($element->{'doc_nr'} == $previous_nr))
{
return $previous_file_name;
}
if ($type eq 'top')
{
$previous_file_name = "${prefix}_top.html";
}
elsif (defined($element->{'number'}) and ($element->{'number'} ne ''))
{
my $number = $element->{'number'};
$number .= '.' unless ($number =~ /\.$/);
$previous_file_name = "${prefix}_$number" . 'html';
}
else
{
$unumbered_nr++;
$previous_file_name = "${prefix}_U." . $unumbered_nr . '.html';
}
$previous_nr = $element->{'doc_nr'};
return $previous_file_name;
}
$heading = \&book_heading;
sub book_heading($$$$$$;$$)
{
my $element = shift;
my $command = shift;
my $texi_line = shift;
my $line = shift;
my $in_preformatted = shift;
my $one_section = shift;
my $element_heading = shift;
my $level = 3;
return '' if ($element->{'top'});
if (!$element->{'node'})
{
$level = $element->{'level'};
}
$level = 1 if ($level == 0);
my $text = $element->{'text'};
if (!$element->{'node'} and (!$NUMBER_SECTIONS))
{
$text = $element->{'text_nonumber'};
}
return '' if ($text !~ /\S/);
my $class = $element->{'tag_level'};
$class = 'unnumbered' if ($class eq 'top');
if (defined($element->{'tocid'}) and $TOC_LINKS)
{
$text = &$anchor ('', "$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
}
$text = "<h$level class=\"$class\"> $text </h$level>\n";
#if (defined($SPLIT) and ($SPLIT eq 'node')
if (exists($element->{'child'})
and ($element->{'tag_level'} !~ /heading/))
{
$text .= "<ul${NO_BULLET_LIST_ATTRIBUTE}>\n";
$text .= "" . book_print_sub_toc($element, $element->{'child'});
$text .= "</ul>\n";
}
return $text;
}
1;
|