| 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 | # General Public License for more details. |
| 18 | # |
| 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 |
| 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="bootstrap.min.css"> |
| 73 | <link rel="stylesheet" type="text/css" href="style.min.css"> |
| 74 | </head> |
| 75 | <body> |
| 76 | <div style="width: 95%; margin: auto"> |
| 77 | <h1> |
| 78 | EOT |
| 79 | |
| 80 | my $head3 = $ENV{"FFMPEG_HEADER3"} || <<EOT; |
| 81 | </h1> |
| 82 | EOT |
| 83 | |
| 84 | return $head1 . $head_title . $head2 . $head_title . $head3; |
| 85 | } |
| 86 | texinfo_register_formatting_function('begin_file', \&ffmpeg_begin_file); |
| 87 | |
| 88 | # Customized file ending |
| 89 | sub ffmpeg_end_file($) |
| 90 | { |
| 91 | my $self = shift; |
| 92 | my $program_string = &{$self->{'format_program_string'}}($self); |
| 93 | my $program_text = <<EOT; |
| 94 | <p style="font-size: small;"> |
| 95 | $program_string |
| 96 | </p> |
| 97 | EOT |
| 98 | my $footer = $ENV{FFMPEG_FOOTER} || <<EOT; |
| 99 | </div> |
| 100 | </body> |
| 101 | </html> |
| 102 | EOT |
| 103 | return $program_text . $footer; |
| 104 | } |
| 105 | texinfo_register_formatting_function('end_file', \&ffmpeg_end_file); |
| 106 | |
| 107 | # Dummy title command |
| 108 | # Ignore title. Title is handled through ffmpeg_begin_file(). |
| 109 | set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1); |
| 110 | sub ffmpeg_title($$$$) |
| 111 | { |
| 112 | return ''; |
| 113 | } |
| 114 | |
| 115 | texinfo_register_command_formatting('titlefont', |
| 116 | \&ffmpeg_title); |
| 117 | |
| 118 | # Customized float command. Part of code borrowed from GNU Texinfo. |
| 119 | sub ffmpeg_float($$$$$) |
| 120 | { |
| 121 | my $self = shift; |
| 122 | my $cmdname = shift; |
| 123 | my $command = shift; |
| 124 | my $args = shift; |
| 125 | my $content = shift; |
| 126 | |
| 127 | my ($caption, $prepended) = Texinfo::Common::float_name_caption($self, |
| 128 | $command); |
| 129 | my $caption_text = ''; |
| 130 | my $prepended_text; |
| 131 | my $prepended_save = ''; |
| 132 | |
| 133 | if ($self->in_string()) { |
| 134 | if ($prepended) { |
| 135 | $prepended_text = $self->convert_tree_new_formatting_context( |
| 136 | $prepended, 'float prepended'); |
| 137 | } else { |
| 138 | $prepended_text = ''; |
| 139 | } |
| 140 | if ($caption) { |
| 141 | $caption_text = $self->convert_tree_new_formatting_context( |
| 142 | {'contents' => $caption->{'args'}->[0]->{'contents'}}, |
| 143 | 'float caption'); |
| 144 | } |
| 145 | return $prepended.$content.$caption_text; |
| 146 | } |
| 147 | |
| 148 | my $id = $self->command_id($command); |
| 149 | my $label; |
| 150 | if (defined($id) and $id ne '') { |
| 151 | $label = "<a name=\"$id\"></a>"; |
| 152 | } else { |
| 153 | $label = ''; |
| 154 | } |
| 155 | |
| 156 | if ($prepended) { |
| 157 | if ($caption) { |
| 158 | # prepend the prepended tree to the first paragraph |
| 159 | my @caption_original_contents = @{$caption->{'args'}->[0]->{'contents'}}; |
| 160 | my @caption_contents; |
| 161 | my $new_paragraph; |
| 162 | while (@caption_original_contents) { |
| 163 | my $content = shift @caption_original_contents; |
| 164 | if ($content->{'type'} and $content->{'type'} eq 'paragraph') { |
| 165 | %{$new_paragraph} = %{$content}; |
| 166 | $new_paragraph->{'contents'} = [@{$content->{'contents'}}]; |
| 167 | unshift (@{$new_paragraph->{'contents'}}, {'cmdname' => 'strong', |
| 168 | 'args' => [{'type' => 'brace_command_arg', |
| 169 | 'contents' => [$prepended]}]}); |
| 170 | push @caption_contents, $new_paragraph; |
| 171 | last; |
| 172 | } else { |
| 173 | push @caption_contents, $content; |
| 174 | } |
| 175 | } |
| 176 | push @caption_contents, @caption_original_contents; |
| 177 | if ($new_paragraph) { |
| 178 | $caption_text = $self->convert_tree_new_formatting_context( |
| 179 | {'contents' => \@caption_contents}, 'float caption'); |
| 180 | $prepended_text = ''; |
| 181 | } |
| 182 | } |
| 183 | if ($caption_text eq '') { |
| 184 | $prepended_text = $self->convert_tree_new_formatting_context( |
| 185 | $prepended, 'float prepended'); |
| 186 | if ($prepended_text ne '') { |
| 187 | $prepended_save = $prepended_text; |
| 188 | $prepended_text = '<p><strong>'.$prepended_text.'</strong></p>'; |
| 189 | } |
| 190 | } |
| 191 | } else { |
| 192 | $prepended_text = ''; |
| 193 | } |
| 194 | |
| 195 | if ($caption and $caption_text eq '') { |
| 196 | $caption_text = $self->convert_tree_new_formatting_context( |
| 197 | $caption->{'args'}->[0], 'float caption'); |
| 198 | } |
| 199 | if ($prepended_text.$caption_text ne '') { |
| 200 | $prepended_text = $self->_attribute_class('div','float-caption'). '>' |
| 201 | . $prepended_text; |
| 202 | $caption_text .= '</div>'; |
| 203 | } |
| 204 | my $html_class = ''; |
| 205 | if ($prepended_save =~ /NOTE/) { |
| 206 | $html_class = 'info'; |
| 207 | $prepended_text = ''; |
| 208 | $caption_text = ''; |
| 209 | } elsif ($prepended_save =~ /IMPORTANT/) { |
| 210 | $html_class = 'warning'; |
| 211 | $prepended_text = ''; |
| 212 | $caption_text = ''; |
| 213 | } |
| 214 | return $self->_attribute_class('div', $html_class). '>' . "\n" . |
| 215 | $prepended_text . $caption_text . $content . '</div>'; |
| 216 | } |
| 217 | |
| 218 | texinfo_register_command_formatting('float', |
| 219 | \&ffmpeg_float); |
| 220 | |
| 221 | 1; |