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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
|
# -*-perl-*-
#+##############################################################################
#
# html32.init: output HTML 3.2
#
# Copyright (C) 2003-2008 Patrice Dumas <dumas@centre-cired.fr>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
#
#-##############################################################################
# APA: Add SystemLiteral to identify the canonical DTD.
# [Definition:] The SystemLiteral is called the entity's system
# identifier. It is a URI, which may be used to retrieve the entity.
# See http://www.xml.com/axml/target.html#NT-ExternalID
$DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN" "http://www.w3.org/TR/html32/loose.dtd">';
$FRAMESET_DOCTYPE = $DOCTYPE;
$BODYTEXT = 'bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"';
# this controls the pre style for menus
$MENU_PRE_STYLE = '';
$NO_BULLET_LIST_STYLE ='';
$USE_ISO = 0;
$MENU_SYMBOL = '*';
# This lines are inserted before and after the shortcontents
$BEFORE_OVERVIEW = "";
$AFTER_OVERVIEW = '';
# This lines are inserted before and after the contents
$BEFORE_TOC_LINES = "";
$AFTER_TOC_LINES = '';
# html version for latex2html
$L2H_HTML_VERSION = "3.2";
# no class in html 32
$NO_BULLET_LIST_ATTRIBUTE = '';
# no css
$CSS_LINES = "";
%css_map = ();
$things_map{'oe'} = 'œ';
$things_map{'OE'} = 'Œ';
$things_map{'dots'} = '<small>...</small>';
$things_map{'enddots'} = '<small>...</small>';
$things_map{'euro'} = 'Euro';
$things_map{'geq'} = '>=';
$things_map{'leq'} = '<=';
$things_map{'quotedblleft'} = '``';
$things_map{'quotedblright'} = "''";
$things_map{'quoteleft'} = '`';
$things_map{'quoteright'} = "'";
$things_map{'quotedblbase'} = ',,';
$things_map{'quotesinglbase'} = ',';
$things_map{'guillemetleft'} = '<<';
$things_map{'guillemetright'} = '>>';
$things_map{'guillemotleft'} = '<<';
$things_map{'guillemotright'} = '>>';
$things_map{'guilsinglleft'} = '<';
$things_map{'guilsinglright'} = '>';
foreach my $style ('oe', 'OE', 'quotedblleft', 'quotedblright',
'quoteleft', 'quoteright',
'quotedblbase', 'quotesinglbase', 'guillemetleft', 'guillemetright',
'guillemotleft', 'guillemotright', 'guilsinglleft', 'guilsinglright')
{
$pre_map{$style} = $things_map{$style};
}
$style_map{'sansserif'} = {};
$style_map{'r'} = {};
$style_map_pre{'r'} = {};
$style_map_pre{'sansserif'} = {};
$style_map{'titlefont'} = {'function' => \&t2h_html32_titlefont,
'type' => 'simple_style'};
$style_map_pre{'titlefont'} = {};
$format_map{'multitable'} = 'table';
# Avoid adding h1 if the text is empty
# no class in html 3.2
sub t2h_html32_titlefont($$$)
{
shift;
my $args = shift;
return "<h1>$args->[0]</h1>" if ($args->[0] =~ /\S/);
return '';
}
# formatting functions
$summary_letter = \&t2h_html32_summary_letter;
$print_index = \&t2h_html32_print_index;
$protect_text = \&t2h_html32_protect_text;
$normal_text = \&t2h_html32_normal_text;
$heading = \&t2h_html32_heading;
$preformatted = \&t2h_html32_preformatted;
$raw = \&t2h_html32_raw;
$menu = \&t2h_html32_menu;
$foot_section = \&t2h_html32_foot_section;
$cartouche = \&t2h_html32_cartouche;
$listoffloats = \&t2h_html32_listoffloats;
$float = \&t2h_html32_float;
$acronym_like = \&t2h_html32_acronym_like;
$row = \&t2h_html32_row;
$cell = \&t2h_html32_cell;
$quotation = \&t2h_html32_quotation;
# " is not in html 3.2
sub t2h_html32_protect_text($)
{
my $text = shift;
$text =~ s/&/&/g;
$text =~ s/</</g;
$text =~ s/>/>/g;
$text =~ s/\"/"/g;
return $text;
}
sub t2h_html32_normal_text($$$$$)
{
my $text = shift;
my $in_raw_text = shift;
my $in_preformatted = shift;
my $in_code = shift;
my $in_simple = shift;
my $style_stack = shift;
$text = uc($text) if (in_cmd($style_stack, 'sc'));
$text = &$protect_text($text) unless($in_raw_text);
if (! $in_code and !$in_preformatted)
{
if ($in_raw_text) #FIXME really do that ? It is done by makeinfo
{
$text =~ s/``/"/g;
$text =~ s/''/"/g;
}
else
{
$text =~ s/``/"/g;
$text =~ s/''/"/g;
}
# temporary reuse '' to store --- !....
# FIXME won't '---' be handled wrongly?
# FIXME really do that in raw text?
$text =~ s/---/''/g;
$text =~ s/--/-/g;
$text =~ s/''/--/g;
}
return $text;
}
# a preformatted section
sub t2h_html32_preformatted($$$)
{
my $text = shift;
my $pre_style = shift;
my $class = shift;
return '' if ($text eq '');
return "<pre>$text</pre>";
}
# a heading for an element
sub t2h_html32_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;
return '' if (defined($command) and $command eq 'node' and !$element_heading);
my $level = 3;
if (!$element->{'node'})
{
$level = $element->{'level'};
}
$level = 1 if ($level == 0);
my $text = $element->{'text'};
if (!$element->{'node'} and (!$NUMBER_SECTIONS))
{
$text = $element->{'name'};
}
return '' if ($text !~ /\S/);
if (defined($element->{'tocid'}) and $TOC_LINKS)
{
$text = &$anchor ('', "$Texi2HTML::THISDOC{'toc_file'}#$element->{'tocid'}", $text);
}
return "<h$level> $text </h$level>\n";
}
# formatting of raw regions
# ih L2H is true another mechanism is used for tex
sub t2h_html32_raw($$)
{
my $style = shift;
my $text = shift;
if ($style eq 'verbatim' or $style eq 'tex')
{
return "<pre>" . &$protect_text($text) . '</pre>';
}
elsif ($style eq 'html')
{
return $text;
}
else
{
warn "$WARN (bug) unknown style $style\n";
return &$protect_text($text);
}
}
# a whole menu
sub t2h_html32_menu($)
{
my $text = shift;
if ($text =~ /\S/)
{
return "<table border=\"0\" cellspacing=\"0\">\n"
. $text . "</table>\n";
}
}
# a simple menu entry ref in case we aren't in a standard menu context
sub t2h_html32_foot_section($)
{
my $lines = shift;
unshift (@$lines, "<hr>\n", "<h3>Footnotes</h3>\n");
return $lines;
}
# a cartouche
sub t2h_html32_cartouche($)
{
my $text = shift;
if ($text =~ /\S/)
{
return "<table border=\"1\"><tr><td>\n" . $text . "</td></tr></table>\n";
}
return '';
}
# no style
sub t2h_html32_summary_letter($$$$$$$)
{
my $letter = shift;
my $file = shift;
my $identifier = shift;
my $index_element_id = shift;
my $number = shift;
my $index_element = shift;
my $index_name = shift;
return &$anchor('', $file . '#' . $identifier, '<b>' . &$protect_text($letter) . '</b>');
}
# format a whole index
#
# argument:
# index text
# index name
sub t2h_html32_print_index($$)
{
my $text = shift;
my $name = shift;
return '' if (!defined($text));
return "<table border=\"0\">\n" .
"<tr><td></td><th align=\"left\">" . &$I('Index Entry') . "</th><th align=\"left\"> " . &$I('Section') . "</th></tr>\n"
. "<tr><td colspan=\"3\"> $DEFAULT_RULE</td></tr>\n" . $text .
"</table>\n";
}
sub t2h_html32_float($$$$$)
{
my $text = shift;
my $float = shift;
my $caption = shift;
my $shortcaption = shift;
my $label = '';
if (exists($float->{'id'}))
{
$label = &$anchor($float->{'id'});
}
my $caption_text = '';
if (defined($float->{'caption_texi'}))
{
$caption_text = $caption;
}
elsif (defined($float->{'shortcaption_texi'}))
{
$caption_text = $shortcaption;
}
elsif (defined($caption))
{
$caption_text = $caption;
}
return "$label\n" . $text . $caption_text;
}
sub t2h_html32_listoffloats($$$)
{
my $style_texi = shift;
my $style = shift;
my $float_entries = shift;
my $result = "<dl>\n" ;
foreach my $float_entry (@$float_entries)
{
$result .= $float_entry;
}
return $result . "</dl>\n";
}
# no acronym, and no abbr in html 3.2
sub t2h_html32_acronym_like($$$$$$)
{
my $command = shift;
my $acronym_texi = shift;
my $acronym_text = shift;
my $with_explanation = shift;
my $explanation_lines = shift;
my $explanation_text = shift;
my $explanation_simply_formatted = shift;
if ($with_explanation)
{
return &$I('%{acronym_like} (%{explanation})', {'acronym_like' => $acronym_text, 'explanation' => $explanation_text},{'duplicate'=>1})
}
else
{
return $acronym_text;
}
}
# row in multitable
sub t2h_html32_row($$)
{
my $text = shift;
my $macro = shift;
if ($text =~ /\S/)
{
return '<tr>' . $text . '</tr>' . "\n";
}
return '';
}
# cell in multitable
sub t2h_html32_cell($$)
{
my $text = shift;
my $row_macro = shift;
my $columnfractions = shift;
my $prototype_row = shift;
$text =~ s/^\s*//;
$text =~ s/\s*$//;
if ($row_macro eq 'headitem')
{
return "<th>" . $text . '</th>';
}
return "<td>" . $text . '</td>';
}
sub t2h_html32_quotation($$$$)
{
my $command = shift;
my $text = shift;
my $argument_text = shift;
my $argument_text_texi = shift;
return "<blockquote>" . $text . "</blockquote>\n";
}
|