File: makeinfo.init

package info (click to toggle)
texi2html 1.82%2Bdfsg1-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 32,848 kB
  • ctags: 16,527
  • sloc: perl: 15,888; xml: 6,075; sh: 3,977; makefile: 545
file content (407 lines) | stat: -rw-r--r-- 11,920 bytes parent folder | download | duplicates (6)
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
403
404
405
406
407
# -*-perl-*-
#+##############################################################################
#
# makeinfo.init: output html in the makeinfo style. Tend not to be up-to-date
#
#    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
#
#-##############################################################################

$TOP_FILE = 'index.html';

$SHOW_MENU = 1;

$USE_NODES = 1;

#$ONLY_NODES = 1;

$SPLIT = 'node';

$NODE_FILES = 1;

$USE_SETFILENAME = 1;

$IGNORE_BEFORE_SETFILENAME = 1;

# to mimic makeinfo the following have to be set.
#$USE_MENU_DIRECTIONS = 0;

#$USE_UP_FOR_ADJACENT_NODES = 0;

$SECTION_NAVIGATION = 1;

$SHORT_REF = 1;

$NODE_NAME_IN_MENU = 1;

$AVOID_MENU_REDUNDANCY = 0;

$SPLIT_INDEX = 0;

$MENU_SYMBOL = '*';

$WORDS_IN_PAGE = 200;

$SEPARATED_FOOTNOTES = 0;

$USE_ACCESSKEY = 1;

$USE_REL_REV = 1;

$USE_LINKS = 1;

$INLINE_CONTENTS = 1;

$OVERVIEW_LINK_TO_TOC = 1;

@SECTION_BUTTONS =
    (
     \"node: ", \$Texi2HTML::NODE{This}, [ 'NodeNext', \$Texi2HTML::NODE{NodeNext} ] , \",", [ 'NodePrev', \$Texi2HTML::NODE{NodePrev} ], \",", [ 'NodeUp', \$Texi2HTML::NODE{NodeUp} ], 'Following'
    );

push @command_handler_process, \&makeinfo_like_initialize_variables;

my $makekinfo_like_footnote_absolute_number;
my %makekinfo_like_paragraph_in_footnote_nr;

sub makeinfo_like_initialize_variables()
{
   $makekinfo_like_footnote_absolute_number = 0;
   %makekinfo_like_paragraph_in_footnote_nr = ();
}

my $default_init_out = $init_out;
$init_out = \&makeinfo_like_init_out;

sub makeinfo_like_init_out()
{
   &$default_init_out();
   $NAVIGATION_TEXT{'Following'} = ' &gt; ';
}

# FIXME: images not in paragraphs are in <div class="block-image">

@MISC_BUTTONS = @SECTION_BUTTONS;

$foot_line_and_ref  = \&makeinfo_like_foot_line_and_ref;
$foot_lines         = \&makeinfo_like_foot_lines;
$paragraph          = \&makeinfo_like_paragraph;
$index_summary      = \&makeinfo_like_index_summary;
$summary_letter     = \&makeinfo_like_summary_letter;
$index_entry        = \&makeinfo_like_index_entry;
$index_letter       = \&makeinfo_like_index_letter;
$print_index        = \&makeinfo_like_print_index;
$listoffloats       = \&makeinfo_like_listoffloats;
$listoffloats_entry = \&makeinfo_like_listoffloats_entry;
$menu_link          = \&makeinfo_like_menu_link;
$menu_description   = \&makeinfo_like_menu_description;
$menu_comment       = \&makeinfo_like_menu_comment;
$menu               = \&makeinfo_like_menu;

sub makeinfo_like_foot_line_and_ref($$$$$$$$)
{
    my $foot_num = shift;
    my $relative_num = shift;
    my $footid = shift;
    my $docid = shift;
    my $from_file = shift;
    my $footnote_file = shift;
    my $lines = shift;
    my $state = shift;
    
    $makekinfo_like_footnote_absolute_number++;

    # this is a bit obscure, this allows to add an anchor only if formatted
    # as part of the document.
    $docid = '' if ($state->{'outside_document'} or $state->{'multiple_pass'});

    if ($from_file eq $footnote_file)
    { 
        $from_file = $footnote_file = '';
    }

    my $foot_anchor = "<sup>" . &$anchor($docid, "$footnote_file#$footid", $relative_num) . "</sup>";
    $foot_anchor = &$anchor($docid, "$footnote_file#$footid", "($relative_num)") if ($state->{'preformatted'});

#    unshift @$lines, "<li>";
#    push @$lines, "</li>\n";
    return ($lines, $foot_anchor);
}

sub makeinfo_like_foot_lines($)
{
    my $lines = shift;
    unshift @$lines, "<hr>\n<h4>$Texi2HTML::I18n::WORDS->{'Footnotes_Title'}</h4>\n";
#<ol type=\"1\">\n";
#    push @$lines, "</ol>";
    return $lines;
}

sub makeinfo_like_paragraph ($$$$$$$$$$$$$)
{
    my $text = shift;
    my $align = shift;
    my $indent = shift;
    my $paragraph_command = shift;
    my $paragraph_command_formatted = shift;
    my $paragraph_number = shift;
    my $format = shift;
    my $item_nr = shift;
    my $enumerate_style = shift;
    my $number = shift;
    my $command_stack_at_end = shift;
    my $command_stack_at_begin = shift;
    my $state = shift;
#print STDERR "format: $format\n" if (defined($format));
#print STDERR "paragraph @$command_stack_at_end; @$command_stack_at_begin\n";
    $paragraph_command_formatted = '' if (!defined($paragraph_command_formatted) or
          exists($special_list_commands{$format}->{$paragraph_command}));
    return '' if ($text =~ /^\s*$/);
    foreach my $style(t2h_collect_styles($command_stack_at_begin))
    {
       $text = t2h_begin_style($style, $text);
    }
    foreach my $style(t2h_collect_styles($command_stack_at_end))
    {
       $text = t2h_end_style($style, $text);
    }
    if (defined($paragraph_number) and defined($$paragraph_number))
    {
         $$paragraph_number++;
         return $text  if (($format eq 'itemize' or $format eq 'enumerate') and
            ($$paragraph_number == 1));
    }
    my $open = '<p';
    if ($align)
    {
        $open .= " align=\"$paragraph_style{$align}\"";
    }

    my $footnote_text = '';
    if (defined($command_stack_at_begin->[0]) and $command_stack_at_begin->[0] eq 'footnote')
    {
        my $state = $Texi2HTML::THISDOC{'state'};
        $makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number}++;
        if ($makekinfo_like_paragraph_in_footnote_nr{$makekinfo_like_footnote_absolute_number} <= 1)
        {
           $open.=' class="footnote"';
           my $document_file = $state->{'footnote_document_file'};
           if ($document_file eq $state->{'footnote_footnote_file'})
           {
               $document_file = '';
           }
           my $docid = $state->{'footnote_place_id'};
           my $doc_state = $state->{'footnote_document_state'};
           $docid = '' if ($doc_state->{'outside_document'} or $doc_state->{'multiple_pass'});
           my $foot_label = &$anchor($state->{'footnote_footnote_id'}, 
                 $document_file . "#$state->{'footnote_place_id'}", 
                 "$state->{'footnote_number_in_page'}");
           $footnote_text = "<small>[${foot_label}]</small> ";
        }
    }

    $text = $footnote_text.$text;

    my $top_stack = '';
    $top_stack = $command_stack_at_begin->[-1] if (scalar (@$command_stack_at_begin));
    if ($top_stack eq 'multitable')
# FIXME
# paragraph_number is not by cell, so it is not possible to know if it
# is the first paragraph in cell. Also currently there is no hook for a
# cell beginning which means that it is not possible to reset the cell 
# paragraph count at a cell beginning
# and (!defined($paragraph_number) or !defined($$paragraph_number) or $$paragraph_number == 1))
    {
       return $text;
    }

    return $open.'>'.$text.'</p>';
}


sub makeinfo_like_index_summary
{
    return '';
}

sub makeinfo_like_summary_letter
{
    return '';
}

sub makeinfo_like_index_entry($$$$)
{
    my $text_href = shift;
    my $entry = shift;
    my $element_href = shift;
    my $element_text = shift;
    
    return '<li>' . $entry . ': ' .  &$anchor('', $element_href, $element_text)
    . "</li>\n";
}

sub makeinfo_like_index_letter($$$)
{
     my $letter = shift;
     my $id = shift;
     my $text = shift;
     return $text;
}

sub makeinfo_like_print_index($$)
{
    my $text = shift;
    my $name = shift;
    return '' if (!defined($text));
    return "<ul class=\"index-$name\" compact>\n" . $text . "</ul>\n";
}

sub makeinfo_like_listoffloats_entry($$$$)
{
    my $style_texi = shift;
    my $float = shift;
    my $float_style = shift;
    my $caption = shift;
    my $href = shift;

    if ($caption ne '')
    {
        return '<li>' . &$I('%{href}: %{caption}', { 'href' => &$anchor('', $href, $float_style), 'caption' => $caption }) . "</li>\n";
    }
    else
    {
        return '<li>' . &$anchor('', $href, $float_style) . "</li>\n";
    }
}

sub makeinfo_like_listoffloats($$$)
{
    my $style_texi = shift;
    my $style = shift;
    my $float_entries = shift;

    my $result = "<ul class=\"listoffloats\">\n" ;
    foreach my $float_entry (@$float_entries)
    {
         $result .= $float_entry;
    }
    return $result . "</ul>\n";
}

# a whole menu
#
# argument:
# the whole menu text (entries and menu comments)
#
# argument:
# whole menu text.
sub makeinfo_like_menu($)
{
    my $text = shift;
    $menu_entry_index=0;
    if ($text =~ /\S/)
    {
        return "<ul>\n" 
        . $text . "</ul>\n";
    }
}

# formats a menu entry link pointing to a node or section 
#
# arguments:
# the entry text
# the state, a hash reference holding informations about the context, with a 
#     usefull entry, 'preformatted', true if we are in a preformatted format
#     (a format keeping space between words). In that case a function
#     of the main program, main::do_preformatted($text, $state) might 
#     be used to format the text with the current format style.
# href is optionnal. It is the reference to the section or the node anchor
#     which should be used to make the link (typically it is the argument 
#     of a href= attribute in a <a> element).
sub makeinfo_like_menu_link($$$$$$$)
{
    my $entry = shift;
    my $state = shift;
    my $href = shift;
    my $node = shift;
    my $title = shift;
    my $ending = shift;
    my $has_title = shift;
    $title = '' unless ($has_title);
    if (($entry eq '') or $NODE_NAME_IN_MENU or $state->{'preformatted'})
    {
        
        $title .= ':' if ($title ne '');
        $entry = "$title$node";
    }
    $menu_entry_index++;
    my $accesskey;
    $accesskey = "accesskey=\"$menu_entry_index\"" if ($USE_ACCESSKEY and ($menu_entry_index < 10));
    $entry = &$anchor ('', $href, $entry, $accesskey) if (defined($href));
    return $entry if ($SIMPLE_MENU); 
#    if ($state->{'preformatted'})
#    {
#        return '<li>' . main::do_preformatted($entry . $ending, $state);
#    }
    return "<li> $entry";
}

# formats a menu entry description, ie the text appearing after the node
# specification in a menu entry an spanning until there is another
# menu entry, an empty line or some text at the very beginning of the line
# (we consider that text at the beginning of the line begins a menu comment) 
#
# arguments:
# the description text
# the state. See menu_entry.
sub makeinfo_like_menu_description($$)
{
    my $text = shift;
    my $state = shift;
    return $text if ($SIMPLE_MENU); 
#    if ($state->{'preformatted'})
#    {
#        return main::do_preformatted($text, $state) . '</td></tr>';
#    }
    return "$text</li>\n";
}

# a menu comment (between menu lines)
# formats the container of a menu comment. A menu comment is any text 
# appearing between menu lines, either separated by an empty line from
# the preceding menu entry, or a text beginning at the first character
# of the line (text not at the very beginning of the line is considered to
# be the continuation of a menu entry description text).
#
# The text itself is considered to be in a preformatted environment
# with name 'menu-commment' and with style $MENU_PRE_STYLE.
#
# argument
# text contained in the menu comment.
sub makeinfo_like_menu_comment($)
{
   my $text = shift;
   return $text if ($SIMPLE_MENU); 
   if ($text =~ /\S/)
   {
       return "</ul>$text<ul>";
   }
   return '';
}

1;