1 # makeinfo HTML output init file
3 # Copyright (c) 2011, 2012 Free Software Foundation, Inc.
4 # Copyright (c) 2014 Andreas Cadhalpun
5 # Copyright (c) 2014 Tiancheng "Timothy" Gu
7 # This file is part of FFmpeg.
9 # FFmpeg is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # FFmpeg is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # General Public License for more details.
19 # You should have received a copy of the GNU General Public
20 # License along with FFmpeg; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # no navigation elements
24 set_from_init_file('HEADERS', 0);
26 sub ffmpeg_heading_command($$$$$)
36 # not clear that it may really happen
37 if ($self->in_string) {
38 $result .= $self->command_string($command) ."\n" if ($cmdname ne 'node');
39 $result .= $content if (defined($content));
43 my $element_id = $self->command_id($command);
44 $result .= "<a name=\"$element_id\"></a>\n"
45 if (defined($element_id) and $element_id ne '');
47 print STDERR "Process $command "
48 .Texinfo::Structuring::_print_root_command_texi($command)."\n"
49 if ($self->get_conf('DEBUG'));
51 if ($Texinfo::Common::root_commands{$command->{'cmdname'}}
52 and $command->{'parent'}
53 and $command->{'parent'}->{'type'}
54 and $command->{'parent'}->{'type'} eq 'element') {
55 $element = $command->{'parent'};
58 $result .= &{$self->{'format_element_header'}}($self, $cmdname,
63 # node is used as heading if there is nothing else.
64 if ($cmdname eq 'node') {
65 if (!$element or (!$element->{'extra'}->{'section'}
66 and $element->{'extra'}->{'node'}
67 and $element->{'extra'}->{'node'} eq $command
68 # bogus node may not have been normalized
69 and defined($command->{'extra'}->{'normalized'}))) {
70 if ($command->{'extra'}->{'normalized'} eq 'Top') {
77 $heading_level = $command->{'level'};
80 my $heading = $self->command_text($command);
81 # $heading not defined may happen if the command is a @node, for example
82 # if there is an error in the node.
83 if (defined($heading) and $heading ne '' and defined($heading_level)) {
85 if ($Texinfo::Common::root_commands{$cmdname}
86 and $Texinfo::Common::sectioning_commands{$cmdname}) {
87 my $content_href = $self->command_contents_href($command, 'contents',
88 $self->{'current_filename'});
90 my $this_href = $content_href =~ s/^\#toc-/\#/r;
91 $heading .= '<span class="pull-right">'.
92 '<a class="anchor hidden-xs" '.
93 "href=\"$this_href\" aria-hidden=\"true\">".
94 ($ENV{"FA_ICONS"} ? '<i class="fa fa-link"></i>'
97 '<a class="anchor hidden-xs"'.
98 "href=\"$content_href\" aria-hidden=\"true\">".
99 ($ENV{"FA_ICONS"} ? '<i class="fa fa-navicon"></i>'
106 if ($self->in_preformatted()) {
107 $result .= $heading."\n";
109 # if the level was changed, set the command name right
110 if ($cmdname ne 'node'
111 and $heading_level ne $Texinfo::Common::command_structuring_level{$cmdname}) {
113 = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
115 $result .= &{$self->{'format_heading_text'}}(
116 $self, $cmdname, $heading,
118 $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
121 $result .= $content if (defined($content));
125 foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') {
126 texinfo_register_command_formatting($command, \&ffmpeg_heading_command);
129 # print the TOC where @contents is used
130 set_from_init_file('INLINE_CONTENTS', 1);
133 set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
136 set_from_init_file('DEFAULT_RULE', '');
137 set_from_init_file('BIG_RULE', '');
139 # Customized file beginning
140 sub ffmpeg_begin_file($$$)
143 my $filename = shift;
147 if ($element and $self->get_conf('SPLIT')) {
148 $command = $self->element_command($element);
151 my ($title, $description, $encoding, $date, $css_lines,
152 $doctype, $bodytext, $copying_comment, $after_body_open,
153 $extra_head, $program_and_version, $program_homepage,
154 $program, $generator) = $self->_file_header_informations($command);
156 my $links = $self->_get_links ($filename, $element);
158 my $head1 = $ENV{"FFMPEG_HEADER1"} || <<EOT;
159 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
161 <!-- Created by $program_and_version, $program_homepage -->
163 <meta charset="utf-8">
166 my $head_title = <<EOT;
170 my $head2 = $ENV{"FFMPEG_HEADER2"} || <<EOT;
172 <meta name="viewport" content="width=device-width,initial-scale=1.0">
173 <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
174 <link rel="stylesheet" type="text/css" href="style.min.css">
177 <div class="container">
181 my $head3 = $ENV{"FFMPEG_HEADER3"} || <<EOT;
185 return $head1 . $head_title . $head2 . $head_title . $head3;
187 texinfo_register_formatting_function('begin_file', \&ffmpeg_begin_file);
189 sub ffmpeg_program_string($)
192 if (defined($self->get_conf('PROGRAM'))
193 and $self->get_conf('PROGRAM') ne ''
194 and defined($self->get_conf('PACKAGE_URL'))) {
195 return $self->convert_tree(
196 $self->gdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.',
197 { 'program_homepage' => $self->get_conf('PACKAGE_URL'),
198 'program' => $self->get_conf('PROGRAM') }));
200 return $self->convert_tree(
201 $self->gdt('This document was generated automatically.'));
204 texinfo_register_formatting_function('program_string', \&ffmpeg_program_string);
206 # Customized file ending
207 sub ffmpeg_end_file($)
210 my $program_string = &{$self->{'format_program_string'}}($self);
211 my $program_text = <<EOT;
212 <p style="font-size: small;">
216 my $footer = $ENV{FFMPEG_FOOTER} || <<EOT;
221 return $program_text . $footer;
223 texinfo_register_formatting_function('end_file', \&ffmpeg_end_file);
225 # Dummy title command
226 # Ignore title. Title is handled through ffmpeg_begin_file().
227 set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
228 sub ffmpeg_title($$$$)
233 texinfo_register_command_formatting('titlefont',
236 # Customized float command. Part of code borrowed from GNU Texinfo.
237 sub ffmpeg_float($$$$$)
245 my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
247 my $caption_text = '';
249 my $prepended_save = '';
251 if ($self->in_string()) {
253 $prepended_text = $self->convert_tree_new_formatting_context(
254 $prepended, 'float prepended');
256 $prepended_text = '';
259 $caption_text = $self->convert_tree_new_formatting_context(
260 {'contents' => $caption->{'args'}->[0]->{'contents'}},
263 return $prepended.$content.$caption_text;
266 my $id = $self->command_id($command);
268 if (defined($id) and $id ne '') {
269 $label = "<a name=\"$id\"></a>";
276 # prepend the prepended tree to the first paragraph
277 my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}};
278 my @caption_contents;
280 while (@caption_original_contents) {
281 my $content = shift @caption_original_contents;
282 if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
283 %{$new_paragraph} = %{$content};
284 $new_paragraph->{'contents'} = [@{$content->{'contents'}}];
285 unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong',
286 'args' => [{'type' => 'brace_command_arg',
287 'contents' => [$prepended]}]});
288 push @caption_contents, $new_paragraph;
291 push @caption_contents, $content;
294 push @caption_contents, @caption_original_contents;
295 if ($new_paragraph) {
296 $caption_text = $self->convert_tree_new_formatting_context(
297 {'contents' => \@caption_contents}, 'float caption');
298 $prepended_text = '';
301 if ($caption_text eq '') {
302 $prepended_text = $self->convert_tree_new_formatting_context(
303 $prepended, 'float prepended');
304 if ($prepended_text ne '') {
305 $prepended_save = $prepended_text;
306 $prepended_text = '<p><strong>'.$prepended_text.'</strong></p>';
310 $prepended_text = '';
313 if ($caption and $caption_text eq '') {
314 $caption_text = $self->convert_tree_new_formatting_context(
315 $caption->{'args'}->[0], 'float caption');
317 if ($prepended_text.$caption_text ne '') {
318 $prepended_text = $self->_attribute_class('div','float-caption'). '>'
320 $caption_text .= '</div>';
323 if ($prepended_save =~ /NOTE/) {
324 $html_class = 'info';
325 $prepended_text = '';
327 } elsif ($prepended_save =~ /IMPORTANT/) {
328 $html_class = 'warning';
329 $prepended_text = '';
332 return $self->_attribute_class('div', $html_class). '>' . "\n" .
333 $prepended_text . $caption_text . $content . '</div>';
336 texinfo_register_command_formatting('float',