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 style="width: 95%; margin: auto">
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 # Customized file ending
190 sub ffmpeg_end_file($)
193 my $program_string = &{$self->{'format_program_string'}}($self);
194 my $program_text = <<EOT;
195 <p style="font-size: small;">
199 my $footer = $ENV{FFMPEG_FOOTER} || <<EOT;
204 return $program_text . $footer;
206 texinfo_register_formatting_function('end_file', \&ffmpeg_end_file);
208 # Dummy title command
209 # Ignore title. Title is handled through ffmpeg_begin_file().
210 set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
211 sub ffmpeg_title($$$$)
216 texinfo_register_command_formatting('titlefont',
219 # Customized float command. Part of code borrowed from GNU Texinfo.
220 sub ffmpeg_float($$$$$)
228 my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
230 my $caption_text = '';
232 my $prepended_save = '';
234 if ($self->in_string()) {
236 $prepended_text = $self->convert_tree_new_formatting_context(
237 $prepended, 'float prepended');
239 $prepended_text = '';
242 $caption_text = $self->convert_tree_new_formatting_context(
243 {'contents' => $caption->{'args'}->[0]->{'contents'}},
246 return $prepended.$content.$caption_text;
249 my $id = $self->command_id($command);
251 if (defined($id) and $id ne '') {
252 $label = "<a name=\"$id\"></a>";
259 # prepend the prepended tree to the first paragraph
260 my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}};
261 my @caption_contents;
263 while (@caption_original_contents) {
264 my $content = shift @caption_original_contents;
265 if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
266 %{$new_paragraph} = %{$content};
267 $new_paragraph->{'contents'} = [@{$content->{'contents'}}];
268 unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong',
269 'args' => [{'type' => 'brace_command_arg',
270 'contents' => [$prepended]}]});
271 push @caption_contents, $new_paragraph;
274 push @caption_contents, $content;
277 push @caption_contents, @caption_original_contents;
278 if ($new_paragraph) {
279 $caption_text = $self->convert_tree_new_formatting_context(
280 {'contents' => \@caption_contents}, 'float caption');
281 $prepended_text = '';
284 if ($caption_text eq '') {
285 $prepended_text = $self->convert_tree_new_formatting_context(
286 $prepended, 'float prepended');
287 if ($prepended_text ne '') {
288 $prepended_save = $prepended_text;
289 $prepended_text = '<p><strong>'.$prepended_text.'</strong></p>';
293 $prepended_text = '';
296 if ($caption and $caption_text eq '') {
297 $caption_text = $self->convert_tree_new_formatting_context(
298 $caption->{'args'}->[0], 'float caption');
300 if ($prepended_text.$caption_text ne '') {
301 $prepended_text = $self->_attribute_class('div','float-caption'). '>'
303 $caption_text .= '</div>';
306 if ($prepended_save =~ /NOTE/) {
307 $html_class = 'info';
308 $prepended_text = '';
310 } elsif ($prepended_save =~ /IMPORTANT/) {
311 $html_class = 'warning';
312 $prepended_text = '';
315 return $self->_attribute_class('div', $html_class). '>' . "\n" .
316 $prepended_text . $caption_text . $content . '</div>';
319 texinfo_register_command_formatting('float',