1# -*-perl-*-
2#+##############################################################################
3#
4# html32.init: output HTML 3.2
5#
6#    Copyright (C) 2003-2008  Patrice Dumas <pertusus@free.fr>
7#
8#    This program is free software; you can redistribute it and/or modify
9#    it under the terms of the GNU General Public License as published by
10#    the Free Software Foundation; either version 2 of the License, or
11#    (at your option) any later version.
12#
13#    This program is distributed in the hope that it will be useful,
14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#    GNU General Public License for more details.
17#
18#    You should have received a copy of the GNU General Public License
19#    along with this program; if not, write to the Free Software
20#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21#    02110-1301  USA
22#
23#-##############################################################################
24# APA: Add SystemLiteral to identify the canonical DTD.
25# [Definition:] The SystemLiteral is called the entity's system
26# identifier. It is a URI, which may be used to retrieve the entity.
27# See http://www.xml.com/axml/target.html#NT-ExternalID
28
29use strict;
30
31$COMPLEX_FORMAT_IN_TABLE = 1;
32
33#html_default_load();
34t2h_default_load_format('html');
35
36$DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN" "http://www.w3.org/TR/html32/loose.dtd">';
37
38$FRAMESET_DOCTYPE = $DOCTYPE;
39
40$BODYTEXT = 'bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"';
41# this controls the pre style for menus
42$MENU_PRE_STYLE = '';
43
44$NO_BULLET_LIST_STYLE ='';
45
46$MENU_SYMBOL = '*';
47
48# This lines are inserted before and after the shortcontents
49$BEFORE_OVERVIEW = "";
50$AFTER_OVERVIEW = '';
51
52# This lines are inserted before and after the contents
53$BEFORE_TOC_LINES = "";
54$AFTER_TOC_LINES = '';
55
56# html version for latex2html
57$L2H_HTML_VERSION = "3.2";
58
59# no class in html 32
60$NO_BULLET_LIST_ATTRIBUTE = '';
61$NO_BULLET_LIST_CLASS = '';
62
63# no css. NO_CSS also triggers no class if html_default_attribute_class
64# is used, which is the case for all the dynamically output elements.
65$NO_CSS = 1;
66
67# no accesskey in html 3.2
68$USE_ACCESSKEY = 0;
69
70# Similar with what t2h_default_set_iso_symbols(0) does but without changing
71# all the things command, only a selected list.
72$USE_ISO = 0;
73$OPEN_QUOTE_SYMBOL = '`';
74$CLOSE_QUOTE_SYMBOL = "'";
75t2h_remove_text_substitutions("'", 1, 0, 0, 1);
76t2h_remove_text_substitutions('`', 1, 0, 0, 1);
77
78foreach my $command ('euro', 'geq', 'leq',
79   'bullet', 'equiv', 'expansion', 'point', 'result', 'arrow',
80   'quotedblleft', 'quotedblright',
81   'quoteleft', 'quoteright',
82   'quotedblbase', 'quotesinglbase', 'guillemetleft', 'guillemetright',
83   'guillemotleft', 'guillemotright', 'guilsinglleft', 'guilsinglright')
84{
85    $things_map{$command} = &$protect_text($default_things_map{$command});
86    $pre_map{$command} = $things_map{$command};
87}
88
89$things_map{'oe'} = '&#156;';
90$things_map{'OE'} = '&#140;';
91$things_map{'dots'} = '<small>...</small>';
92$things_map{'enddots'} = '<small>...</small>';
93
94$pre_map{'dots'} = '...';
95$pre_map{'oe'} = $things_map{'oe'};
96$pre_map{'OE'} = $things_map{'OE'};
97
98
99$style_map{'sansserif'} = {};
100$style_map{'r'} = {};
101$style_map_pre{'r'} = {};
102$style_map_pre{'sansserif'} = {};
103
104$format_map{'multitable'} = 'table';
105
106# formatting functions
107
108$protect_text      = \&t2h_html32_protect_text;
109$normal_text       = \&t2h_html32_normal_text;
110#$acronym_like      = \&t2h_html32_acronym_like;
111$acronym_like      = \&t2h_default_acronym_like;
112$row               = \&t2h_html32_row;
113$cell              = \&t2h_html32_cell;
114
115
116# &quot; is not in html 3.2
117sub t2h_html32_protect_text($)
118{
119   my $text = shift;
120   $text =~ s/&/&amp;/g;
121   $text =~ s/</&lt;/g;
122   $text =~ s/>/&gt;/g;
123   $text =~ s/\"/&#34;/g;
124   return $text;
125}
126
127sub t2h_html32_normal_text($$$$$$$;$)
128{
129   my $text = shift;
130   my $in_raw_text = shift;
131   my $in_preformatted = shift;
132   my $in_code = shift;
133   my $in_math = shift;
134   my $in_simple = shift;
135   my $style_stack = shift;
136   my $state = shift;
137
138   $text = uc($text) if (in_cmd($style_stack, 'sc'));
139   $text = &$protect_text($text) unless($in_raw_text);
140   if (! $in_code and !$in_preformatted)
141   {
142       if ($in_raw_text) #FIXME really do that ? It is done by makeinfo
143       {
144           $text =~ s/``/"/g;
145           $text =~ s/''/"/g;
146       }
147       else
148       {
149           $text =~ s/``/&#34;/g;
150           $text =~ s/''/&#34;/g;
151       }
152       # FIXME really do that in raw text?
153       $text =~ s/---/\x{1F}/g;
154       $text =~ s/--/-/g;
155       $text =~ s/\x{1F}/--/g;
156   }
157   return $text;
158}
159
160# no acronym, and no abbr in html 3.2
161sub t2h_html32_acronym_like($$$$$$)
162{
163    my $command = shift;
164    my $acronym_texi = shift;
165    my $acronym_text = shift;
166    my $with_explanation = shift;
167    my $explanation_lines = shift;
168    my $explanation_text = shift;
169    my $explanation_simply_formatted = shift;
170
171    if ($with_explanation)
172    {
173        return gdt('{acronym_like} ({explanation})', {'acronym_like' => $acronym_text, 'explanation' => $explanation_text},{'duplicate'=>1})
174    }
175    else
176    {
177        return $acronym_text;
178    }
179}
180
181# row in multitable. no thead in html 3.2
182sub t2h_html32_row($$)
183{
184    my $text = shift;
185    my $macro = shift;
186
187    if ($text =~ /\S/)
188    {
189         return '<tr>' . $text . '</tr>' . "\n";
190    }
191    return '';
192}
193
194# cell in multitable. in html 3.2 width is in pixel and not in percent in
195# th or td.
196sub t2h_html32_cell($$)
197{
198    my $text = shift;
199    my $row_macro = shift;
200    my $columnfractions = shift;
201    my $prototype_row = shift;
202
203    $text =~ s/^\s*//;
204    $text =~ s/\s*$//;
205
206    if ($row_macro eq 'headitem')
207    {
208        return "<th>" . $text . '</th>';
209    }
210    return "<td>" . $text . '</td>';
211}
212