patch-texinfo-7.diff

Air 43, 11/26/2023 10:59 am

Download (7.7 kB)

 
doc/t2h.pm 2023-11-21 13:32:35
20 20
# License along with FFmpeg; if not, write to the Free Software
21 21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 22

  
23
# Texinfo 7.0 changed the syntax of various functions.
24
# Provide a shim for older versions.
25
sub ff_set_from_init_file($$) {
26
    my $key = shift;
27
    my $value = shift;
28
    if (exists &{'texinfo_set_from_init_file'}) {
29
        texinfo_set_from_init_file($key, $value);
30
    } else {
31
        set_from_init_file($key, $value);
32
    }
33
}
34

  
35
sub ff_get_conf($) {
36
    my $key = shift;
37
    if (exists &{'texinfo_get_conf'}) {
38
        texinfo_get_conf($key);
39
    } else {
40
        get_conf($key);
41
    }
42
}
43

  
44
sub get_formatting_function($$) {
45
    my $obj = shift;
46
    my $func = shift;
47

  
48
    my $sub = $obj->can('formatting_function');
49
    if ($sub) {
50
        return $obj->formatting_function($func);
51
    } else {
52
        return $obj->{$func};
53
    }
54
}
55

  
56
# determine texinfo version
57
my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify;
58
my $program_version_6_8 = $program_version_num >= 6.008000;
59

  
23 60
# no navigation elements
24
set_from_init_file('HEADERS', 0);
61
ff_set_from_init_file('HEADERS', 0);
25 62

  
26 63
sub ffmpeg_heading_command($$$$$)
27 64
{
......
55 92
        $element = $command->{'parent'};
56 93
    }
57 94
    if ($element) {
58
        $result .= &{$self->{'format_element_header'}}($self, $cmdname,
95
        $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname,
59 96
                                                       $command, $element);
60 97
    }
61 98

  
......
112 149
                $cmdname
113 150
                    = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level];
114 151
            }
115
            $result .= &{$self->{'format_heading_text'}}(
152
            # format_heading_text expects an array of headings for texinfo >= 7.0
153
            if ($program_version_num >= 7.000000) {
154
                $heading = [$heading];
155
            }
156
            $result .= &{get_formatting_function($self,'format_heading_text')}(
116 157
                        $self, $cmdname, $heading,
117 158
                        $heading_level +
118 159
                        $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command);
......
127 168
}
128 169

  
129 170
# print the TOC where @contents is used
130
set_from_init_file('INLINE_CONTENTS', 1);
171
ff_set_from_init_file('INLINE_CONTENTS', 1);
131 172

  
132 173
# make chapters <h2>
133
set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
174
ff_set_from_init_file('CHAPTER_HEADER_LEVEL', 2);
134 175

  
135 176
# Do not add <hr>
136
set_from_init_file('DEFAULT_RULE', '');
137
set_from_init_file('BIG_RULE', '');
177
ff_set_from_init_file('DEFAULT_RULE', '');
178
ff_set_from_init_file('BIG_RULE', '');
138 179

  
139 180
# Customized file beginning
140 181
sub ffmpeg_begin_file($$$)
......
151 192
    my ($title, $description, $encoding, $date, $css_lines,
152 193
        $doctype, $bodytext, $copying_comment, $after_body_open,
153 194
        $extra_head, $program_and_version, $program_homepage,
154
        $program, $generator) = $self->_file_header_informations($command);
195
        $program, $generator);
196
    if ($program_version_num >= 7.000000) {
197
        ($title, $description, $encoding, $date, $css_lines,
198
         $doctype, $bodytext, $copying_comment, $after_body_open,
199
         $extra_head, $program_and_version, $program_homepage,
200
         $program, $generator) = $self->_file_header_information($command);
201
    } else {
202
        ($title, $description, $encoding, $date, $css_lines,
203
         $doctype, $bodytext, $copying_comment, $after_body_open,
204
         $extra_head, $program_and_version, $program_homepage,
205
         $program, $generator) = $self->_file_header_informations($command);
206
    }
155 207

  
156 208
    my $links = $self->_get_links ($filename, $element);
157 209

  
......
207 259
sub ffmpeg_end_file($)
208 260
{
209 261
    my $self = shift;
210
    my $program_string = &{$self->{'format_program_string'}}($self);
262
    my $program_string = &{get_formatting_function($self,'format_program_string')}($self);
211 263
    my $program_text = <<EOT;
212 264
      <p style="font-size: small;">
213 265
        $program_string
......
224 276

  
225 277
# Dummy title command
226 278
# Ignore title. Title is handled through ffmpeg_begin_file().
227
set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
279
ff_set_from_init_file('USE_TITLEPAGE_FOR_TITLE', 1);
228 280
sub ffmpeg_title($$$$)
229 281
{
230 282
    return '';
......
242 294
    my $args = shift;
243 295
    my $content = shift;
244 296

  
245
    my ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
246
                                                                $command);
297
    my ($caption, $prepended);
298
    if ($program_version_num >= 7.000000) {
299
        ($caption, $prepended) = Texinfo::Convert::Converter::float_name_caption($self,
300
                                                                                 $command);
301
    } else {
302
        ($caption, $prepended) = Texinfo::Common::float_name_caption($self,
303
                                                                     $command);
304
    }
247 305
    my $caption_text = '';
248 306
    my $prepended_text;
249 307
    my $prepended_save = '';
......
315 373
            $caption->{'args'}->[0], 'float caption');
316 374
    }
317 375
    if ($prepended_text.$caption_text ne '') {
318
        $prepended_text = $self->_attribute_class('div','float-caption'). '>'
319
                . $prepended_text;
376
        if ($program_version_num >= 7.000000) {
377
            $prepended_text = $self->html_attribute_class('div',['float-caption']). '>'
378
                    . $prepended_text;
379
        } else {
380
            $prepended_text = $self->_attribute_class('div','float-caption'). '>'
381
                    . $prepended_text;
382
        }
320 383
        $caption_text .= '</div>';
321 384
    }
322 385
    my $html_class = '';
......
329 392
        $prepended_text = '';
330 393
        $caption_text   = '';
331 394
    }
332
    return $self->_attribute_class('div', $html_class). '>' . "\n" .
333
        $prepended_text . $caption_text . $content . '</div>';
395
    if ($program_version_num >= 7.000000) {
396
        return $self->html_attribute_class('div', [$html_class]). '>' . "\n" .
397
            $prepended_text . $caption_text . $content . '</div>';
398
    } else {
399
        return $self->_attribute_class('div', $html_class). '>' . "\n" .
400
            $prepended_text . $caption_text . $content . '</div>';
401
    }
334 402
}
335 403

  
336 404
texinfo_register_command_formatting('float',