]> git.sesse.net Git - ffmpeg/blob - doc/t2h.pm
avutil/md5: workaround clang 3.5 #20849
[ffmpeg] / doc / t2h.pm
1 # makeinfo HTML output init file
2 #
3 # Copyright (c) 2011, 2012 Free Software Foundation, Inc.
4 # Copyright (c) 2014 Andreas Cadhalpun
5 # Copyright (c) 2014 Tiancheng "Timothy" Gu
6 #
7 # This file is part of FFmpeg.
8 #
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.
13 #
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 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser 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
22
23 # no navigation elements
24 set_from_init_file('HEADERS', 0);
25
26 # TOC and Chapter headings link
27 set_from_init_file('TOC_LINKS', 1);
28
29 # print the TOC where @contents is used
30 set_from_init_file('INLINE_CONTENTS', 1);
31
32 # make chapters <h2>
33 set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
34
35 # Do not add <hr>
36 set_from_init_file('DEFAULT_RULE', '');
37 set_from_init_file('BIG_RULE', '');
38
39 # Customized file beginning
40 sub ffmpeg_begin_file($$$)
41 {
42     my $self = shift;
43     my $filename = shift;
44     my $element = shift;
45
46     my $command;
47     if ($element and $self->get_conf('SPLIT')) {
48         $command = $self->element_command($element);
49     }
50
51     my ($title, $description, $encoding, $date, $css_lines,
52         $doctype, $bodytext, $copying_comment, $after_body_open,
53         $extra_head, $program_and_version, $program_homepage,
54         $program, $generator) = $self->_file_header_informations($command);
55
56     my $links = $self->_get_links ($filename, $element);
57
58     my $head1 = $ENV{"FFMPEG_HEADER1"} || <<EOT;
59 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
60 <html>
61 <!-- Created by $program_and_version, $program_homepage -->
62   <head>
63     <meta charset="utf-8">
64     <title>
65 EOT
66     my $head_title = <<EOT;
67       $title
68 EOT
69
70     my $head2 = $ENV{"FFMPEG_HEADER2"} || <<EOT;
71     </title>
72     <link rel="stylesheet" type="text/css" href="style.min.css">
73   </head>
74   <body>
75     <div style="width: 95%; margin: auto">
76       <h1>
77 EOT
78
79     my $head3 = $ENV{"FFMPEG_HEADER3"} || <<EOT;
80       </h1>
81 EOT
82
83     return $head1 . $head_title . $head2 . $head_title . $head3;
84 }
85 texinfo_register_formatting_function('begin_file', \&ffmpeg_begin_file);
86
87 # Customized file ending
88 sub ffmpeg_end_file($)
89 {
90     my $self = shift;
91     my $program_string = &{$self->{'format_program_string'}}($self);
92     my $program_text = <<EOT;
93       <p style="font-size: small;">
94         $program_string
95       </p>
96 EOT
97     my $footer = $ENV{FFMPEG_FOOTER} || <<EOT;
98     </div>
99   </body>
100 </html>
101 EOT
102     return $program_text . $footer;
103 }
104 texinfo_register_formatting_function('end_file', \&ffmpeg_end_file);
105
106 # Dummy title command
107 # Ignore title. Title is handled through ffmpeg_begin_file().
108 set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
109 sub ffmpeg_title($$$$)
110 {
111     return '';
112 }
113
114 texinfo_register_command_formatting('titlefont',
115                                     \&ffmpeg_title);
116
117 # Customized float command. Part of code borrowed from GNU Texinfo.
118 sub ffmpeg_float($$$$$)
119 {
120     my $self = shift;
121     my $cmdname = shift;
122     my $command = shift;
123     my $args = shift;
124     my $content = shift;
125
126     my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
127                                                                 $command);
128     my $caption_text = '';
129     my $prepended_text;
130     my $prepended_save = '';
131
132     if ($self->in_string()) {
133         if ($prepended) {
134             $prepended_text = $self->convert_tree_new_formatting_context(
135                 $prepended, 'float prepended');
136         } else {
137             $prepended_text = '';
138         }
139         if ($caption) {
140             $caption_text = $self->convert_tree_new_formatting_context(
141                 {'contents' => $caption->{'args'}->[0]->{'contents'}},
142                 'float caption');
143         }
144         return $prepended.$content.$caption_text;
145     }
146
147     my $id = $self->command_id($command);
148     my $label;
149     if (defined($id) and $id ne '') {
150         $label = "<a name=\"$id\"></a>";
151     } else {
152         $label = '';
153     }
154
155     if ($prepended) {
156         if ($caption) {
157             # prepend the prepended tree to the first paragraph
158             my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}};
159             my @caption_contents;
160             my $new_paragraph;
161             while (@caption_original_contents) {
162                 my $content = shift @caption_original_contents;
163                 if ($content->{'type'} and $content->{'type'} eq 'paragraph') {
164                     %{$new_paragraph} = %{$content};
165                     $new_paragraph->{'contents'} = [@{$content->{'contents'}}];
166                     unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong',
167                              'args' => [{'type' => 'brace_command_arg',
168                                                     'contents' => [$prepended]}]});
169                     push @caption_contents, $new_paragraph;
170                     last;
171                 } else {
172                     push @caption_contents, $content;
173                 }
174             }
175             push @caption_contents, @caption_original_contents;
176             if ($new_paragraph) {
177                 $caption_text = $self->convert_tree_new_formatting_context(
178                  {'contents' => \@caption_contents}, 'float caption');
179                 $prepended_text = '';
180             }
181         }
182         if ($caption_text eq '') {
183             $prepended_text = $self->convert_tree_new_formatting_context(
184                 $prepended, 'float prepended');
185             if ($prepended_text ne '') {
186                 $prepended_save = $prepended_text;
187                 $prepended_text = '<p><strong>'.$prepended_text.'</strong></p>';
188             }
189         }
190     } else {
191         $prepended_text = '';
192     }
193
194     if ($caption and $caption_text eq '') {
195         $caption_text = $self->convert_tree_new_formatting_context(
196             $caption->{'args'}->[0], 'float caption');
197     }
198     if ($prepended_text.$caption_text ne '') {
199         $prepended_text = $self->_attribute_class('div','float-caption'). '>'
200                 . $prepended_text;
201         $caption_text .= '</div>';
202     }
203     my $html_class = '';
204     if ($prepended_save =~ /NOTE/) {
205         $html_class = 'info';
206         $prepended_text = '';
207         $caption_text   = '';
208     } elsif ($prepended_save =~ /IMPORTANT/) {
209         $html_class = 'warning';
210         $prepended_text = '';
211         $caption_text   = '';
212     }
213     return $self->_attribute_class('div', $html_class). '>' . "\n" .
214         $prepended_text . $caption_text . $content . '</div>';
215 }
216
217 texinfo_register_command_formatting('float',
218                                     \&ffmpeg_float);
219
220 1;