You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
6.9KB

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