summaryrefslogtreecommitdiffstats
path: root/source/l/ffmpeg/texinfo.patch
blob: 2de58c15038f6b9d927e08b60fee56ca3ccf3844 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
--- ffmpeg-6.0/doc/t2h.pm	2022-11-04 22:16:28.000000000 +0200
+++ t2h.pm.BAK	2023-10-26 00:47:01.128352085 +0300
@@ -19,9 +19,11 @@
 # You should have received a copy of the GNU General Public
 # License along with FFmpeg; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use lib '/usr/share/texinfo/Texinfo/Convert';
+use Texinfo::Convert::Converter;
 
 # no navigation elements
-set_from_init_file('HEADERS', 0);
+texinfo_set_from_init_file('HEADERS', 0);
 
 sub ffmpeg_heading_command($$$$$)
 {
@@ -60,66 +62,68 @@
     }
 
     my $heading_level;
-    # node is used as heading if there is nothing else.
-    if ($cmdname eq 'node') {
-        if (!$element or (!$element->{'extra'}->{'section'}
-            and $element->{'extra'}->{'node'}
-            and $element->{'extra'}->{'node'} eq $command
-             # bogus node may not have been normalized
-            and defined($command->{'extra'}->{'normalized'}))) {
-            if ($command->{'extra'}->{'normalized'} eq 'Top') {
-                $heading_level = 0;
-            } else {
-                $heading_level = 3;
-            }
-        }
+
+if ($cmdname eq 'node') {
+    if (!$element or (
+        $element->{'extra'}->{'section'} and
+        $element->{'extra'}->{'node'} and
+        $element->{'extra'}->{'node'} eq $command and
+        defined($command->{'extra'}->{'normalized'})
+    )) {
+        $heading_level = 0;  # Set heading level to 0
     } else {
-        $heading_level = $command->{'level'};
+        $heading_level = 3;
     }
+} else {
+    $heading_level = $command->{'level'};
+}
 
-    my $heading = $self->command_text($command);
-    # $heading not defined may happen if the command is a @node, for example
-    # if there is an error in the node.
-    if (defined($heading) and $heading ne '' and defined($heading_level)) {
-
-        if ($Texinfo::Common::root_commands{$cmdname}
-            and $Texinfo::Common::sectioning_commands{$cmdname}) {
-            my $content_href = $self->command_contents_href($command, 'contents',
-                                                            $self->{'current_filename'});
-            if ($content_href) {
-                my $this_href = $content_href =~ s/^\#toc-/\#/r;
-                $heading .= '<span class="pull-right">'.
-                              '<a class="anchor hidden-xs" '.
-                                 "href=\"$this_href\" aria-hidden=\"true\">".
-            ($ENV{"FA_ICONS"} ? '<i class="fa fa-link"></i>'
-                              : '#').
-                              '</a> '.
-                              '<a class="anchor hidden-xs"'.
-                                 "href=\"$content_href\" aria-hidden=\"true\">".
-            ($ENV{"FA_ICONS"} ? '<i class="fa fa-navicon"></i>'
-                              : 'TOC').
-                              '</a>'.
-                            '</span>';
-            }
+my $heading = $self->command_text($command);
+
+if (defined($heading) and $heading ne '' and defined($heading_level)) {
+    if ($Texinfo::Common::root_commands{$cmdname}
+        and $Texinfo::Common::sectioning_commands{$cmdname}) {
+        my $content_href = $self->command_contents_href($command, 'contents', $self->{'current_filename'});
+        if ($content_href) {
+            my $this_href = $content_href =~ s/^\#toc-/\#/r;
+            $heading .= '<span class="pull-right">'.
+                '<a class="anchor hidden-xs" '.
+                "href=\"$this_href\" aria-hidden=\"true\">".
+                ($ENV{"FA_ICONS"} ? '<i class="fa fa-link"></i>'
+                                  : '#').
+                '</a> ' .
+                '<a class="anchor hidden-xs"'.
+                "href=\"$content_href\" aria-hidden=\"true\">".
+                ($ENV{"FA_ICONS"} ? '<i class="fa fa-navicon"></i>'
+                                  : 'TOC').
+                '</a>'.
+            '</span>';
         }
+    }
 
-        if ($self->in_preformatted()) {
-            $result .= $heading."\n";
-        } else {
-            # if the level was changed, set the command name right
-            if ($cmdname ne 'node'
-                and $heading_level ne $Texinfo::Common::command_structuring_level{$cmdname}) {
-                $cmdname
-                    = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
-            }
-            $result .= &{$self->{'format_heading_text'}}(
-                        $self, $cmdname, $heading,
-                        $heading_level +
-                        $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
+    if ($self->in_preformatted()) {
+        $result .= $heading."\n";
+    } else {
+        if ($cmdname ne 'node'
+            and $heading_level ne $Texinfo::Common::command_structuring_level{$cmdname}) {
+            $cmdname
+                = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
         }
+        if ($cmdname ne 'node') {
+    # Only add class if the command is not "node"
+    $result .= &{$self->formatting_function('format_heading_text')}(
+        $self, $cmdname, $heading,
+        $heading_level +
+        $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
+} else {
+    # Handle "Top" differently, without adding class
+    $result .= $heading . "\n";
+}
     }
-    $result .= $content if (defined($content));
-    return $result;
+}
+$result .= $content if (defined($content));
+
+return $result;
 }
 
 foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') {
@@ -127,22 +131,22 @@
 }
 
 # determine if texinfo is at least version 6.8
-my $program_version_num = version->declare(get_conf('PACKAGE_VERSION'))->numify;
+my $program_version_num = version->declare(texinfo_get_conf('PACKAGE_VERSION'))->numify;
 my $program_version_6_8 = $program_version_num >= 6.008000;
 
 # print the TOC where @contents is used
 if ($program_version_6_8) {
-    set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
+    texinfo_set_from_init_file('CONTENTS_OUTPUT_LOCATION', 'inline');
 } else {
-    set_from_init_file('INLINE_CONTENTS', 1);
+    texinfo_set_from_init_file('INLINE_CONTENTS', 1);
 }
 
 # make chapters <h2>
-set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
+texinfo_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
 
 # Do not add <hr>
-set_from_init_file('DEFAULT_RULE', '');
-set_from_init_file('BIG_RULE', '');
+texinfo_set_from_init_file('DEFAULT_RULE', '');
+texinfo_set_from_init_file('BIG_RULE', '');
 
 # Customized file beginning
 sub ffmpeg_begin_file($$$)
@@ -156,10 +160,10 @@
         $command = $self->element_command($element);
     }
 
-    my ($title, $description, $encoding, $date, $css_lines,
+my ($title, $description, $encoding, $date, $css_lines,
         $doctype, $bodytext, $copying_comment, $after_body_open,
         $extra_head, $program_and_version, $program_homepage,
-        $program, $generator) = $self->_file_header_informations($command);
+        $program, $generator) = $self->_file_header_information($command);
 
     my $links = $self->_get_links ($filename, $element);
 
@@ -201,13 +205,13 @@
 sub ffmpeg_program_string($)
 {
   my $self = shift;
-  if (defined($self->get_conf('PROGRAM'))
-      and $self->get_conf('PROGRAM') ne ''
-      and defined($self->get_conf('PACKAGE_URL'))) {
+  if (defined($self->texinfo_get_conf('PROGRAM'))
+      and $self->texinfo_get_conf('PROGRAM') ne ''
+      and defined($self->texinfo_get_conf('PACKAGE_URL'))) {
     return $self->convert_tree(
       $self->gdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.',
-         { 'program_homepage' => $self->get_conf('PACKAGE_URL'),
-           'program' => $self->get_conf('PROGRAM') }));
+         { 'program_homepage' => $self->texinfo_get_conf('PACKAGE_URL'),
+           'program' => $self->texinfo_get_conf('PROGRAM') }));
   } else {
     return $self->convert_tree(
       $self->gdt('This document was generated automatically.'));
@@ -223,7 +227,7 @@
 sub ffmpeg_end_file($)
 {
     my $self = shift;
-    my $program_string = &{$self->{'format_program_string'}}($self);
+    my $program_string = "This document was generated using TexinfoConverter.";
     my $program_text = <<EOT;
       <p style="font-size: small;">
         $program_string
@@ -244,7 +248,7 @@
 
 # Dummy title command
 # Ignore title. Title is handled through ffmpeg_begin_file().
-set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
+texinfo_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
 sub ffmpeg_title($$$$)
 {
     return '';
@@ -253,6 +257,8 @@
 texinfo_register_command_formatting('titlefont',
                                     \&ffmpeg_title);
 
+use lib '/usr/share/texinfo/Texinfo/Convert';
+
 # Customized float command. Part of code borrowed from GNU Texinfo.
 sub ffmpeg_float($$$$$)
 {
@@ -262,8 +268,9 @@
     my $args = shift;
     my $content = shift;
 
-    my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
+my ($caption, $prepended) = Texinfo::Convert::Converter::float_name_caption($self,
                                                                 $command);
+    
     my $caption_text = '';
     my $prepended_text;
     my $prepended_save = '';
@@ -335,24 +342,31 @@
             $caption->{'args'}->[0], 'float caption');
     }
     if ($prepended_text.$caption_text ne '') {
-        $prepended_text = $self->_attribute_class('div','float-caption'). '>'
-                . $prepended_text;
+        $prepended_text = '<div class="float-caption">' . $prepended_text;
         $caption_text .= '</div>';
+
     }
-    my $html_class = '';
-    if ($prepended_save =~ /NOTE/) {
-        $html_class = 'info';
-        $prepended_text = '';
-        $caption_text   = '';
-    } elsif ($prepended_save =~ /IMPORTANT/) {
-        $html_class = 'warning';
-        $prepended_text = '';
-        $caption_text   = '';
-    }
-    return $self->_attribute_class('div', $html_class). '>' . "\n" .
-        $prepended_text . $caption_text . $content . '</div>';
-}
+  my $html_class = [];
 
+if ($prepended_save =~ /NOTE/) {
+    $html_class = ['info'];
+    $prepended_text = '';
+    $caption_text = '';
+} elsif ($prepended_save =~ /IMPORTANT/) {
+    $html_class = ['warning'];
+    $prepended_text = '';
+    $caption_text = '';
+} elsif ($prepended_save =~ /Top/) {
+    $html_class = [grep { $_ ne 'Top' } @$html_class];  # Remove "Top" class
+    $prepended_text = '';
+    $caption_text = '';
+}
+
+# Set the class attribute directly in the HTML
+return $self->html_attribute_class('div', $html_class) . '>' . "\n" .
+    $prepended_text . $caption_text . $content . '</div>';
+
+}
 texinfo_register_command_formatting('float',
                                     \&ffmpeg_float);