Here is a proposed patch for portability of doc/t2h.pm for GNU Texinfo 7.1 and 7.1.90 (7.2 pretest). I tested against 7.1 and 7.1.90 (7.2 pretest). There is a difference in the headings compared to the website version, maybe related to FA_ICONS not being set the same, but the result seems correct. I also renamed $element to $output_unit in ffmpeg_heading_command as in new equivalent makeinfo/texi2any code the $element variable is the $command variable in ffmpeg_heading_command, which is very confusing. I left as is the $command variable to have a patch easier to read, but it could make sense to rename $command as $element later on. The patch could also have effects with Texinfo 7.0, since some of the changes are for that version, but that probably never show up because it is for situations that may not exist in ffmpeg manuals (for example @node without sectioning command), or because the code is robust to some missing information (case of $heading_level in ffmpeg_heading_command that was not set, as far as I can tell).
Unified · Split
| @@ -54,12 +54,24 @@ sub get_formatting_function($$) { · 53 unmodified lines | ||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | # determine texinfo version |
| 57 | −my $program_version_num = version->declare(ff_get_conf('PACKAGE_VERSION'))->numify; | |
| 57 | +my $package_version = ff_get_conf('PACKAGE_VERSION'); | |
| 58 | +$package_version =~ s/\+dev$//; | |
| 59 | +my $program_version_num = version->declare($package_version)->numify; | |
| 58 | 60 | my $program_version_6_8 = $program_version_num >= 6.008000; |
| 59 | 61 | |
| 60 | 62 | # no navigation elements |
| 61 | 63 | ff_set_from_init_file('HEADERS', 0); |
| 62 | 64 | |
| 65 | +my %sectioning_commands = %Texinfo::Common::sectioning_commands; | |
| 66 | +if (scalar(keys(%sectioning_commands)) == 0) { | |
| 67 | + %sectioning_commands = %Texinfo::Commands::sectioning_heading_commands; | |
| 68 | +} | |
| 69 | + | |
| 70 | +my %root_commands = %Texinfo::Common::root_commands; | |
| 71 | +if (scalar(keys(%root_commands)) == 0) { | |
| 72 | + %root_commands = %Texinfo::Commands::root_commands; | |
| 73 | +} | |
| 74 | + | |
| 63 | 75 | sub ffmpeg_heading_command($$$$$) |
| 64 | 76 | { |
| 65 | 77 | my $self = shift; |
| @@ -77,6 +89,9 @@ sub ffmpeg_heading_command($$$$$) · 11 unmodified lines | ||
| 77 | 89 | return $result; |
| 78 | 90 | } |
| 79 | 91 | |
| 92 | + # no need to set it as the $element_id is output unconditionally | |
| 93 | + my $heading_id; | |
| 94 | + | |
| 80 | 95 | my $element_id = $self->command_id($command); |
| 81 | 96 | $result .= "<a name=\"$element_id\"></a>\n" |
| 82 | 97 | if (defined($element_id) and $element_id ne ''); |
| @@ -84,24 +99,40 @@ sub ffmpeg_heading_command($$$$$) · 1 unmodified line | ||
| 84 | 99 | print STDERR "Process $command " |
| 85 | 100 | .Texinfo::Structuring::_print_root_command_texi($command)."\n" |
| 86 | 101 | if ($self->get_conf('DEBUG')); |
| 87 | − my $element; | |
| 88 | − if ($Texinfo::Common::root_commands{$command->{'cmdname'}} | |
| 89 | − and $command->{'parent'} | |
| 90 | − and $command->{'parent'}->{'type'} | |
| 91 | − and $command->{'parent'}->{'type'} eq 'element') { | |
| 92 | − $element = $command->{'parent'}; | |
| 102 | + my $output_unit; | |
| 103 | + if ($root_commands{$command->{'cmdname'}}) { | |
| 104 | + if ($command->{'associated_unit'}) { | |
| 105 | + $output_unit = $command->{'associated_unit'}; | |
| 106 | + } elsif ($command->{'structure'} | |
| 107 | + and $command->{'structure'}->{'associated_unit'}) { | |
| 108 | + $output_unit = $command->{'structure'}->{'associated_unit'}; | |
| 109 | + } elsif ($command->{'parent'} | |
| 110 | + and $command->{'parent'}->{'type'} | |
| 111 | + and $command->{'parent'}->{'type'} eq 'element') { | |
| 112 | + $output_unit = $command->{'parent'}; | |
| 113 | + } | |
| 93 | 114 | } |
| 94 | − if ($element) { | |
| 115 | + | |
| 116 | + if ($output_unit) { | |
| 95 | 117 | $result .= &{get_formatting_function($self, 'format_element_header')}($self, $cmdname, |
| 96 | − $command, $element); | |
| 118 | + $command, $output_unit); | |
| 97 | 119 | } |
| 98 | 120 | |
| 99 | 121 | my $heading_level; |
| 100 | 122 | # node is used as heading if there is nothing else. |
| 101 | 123 | if ($cmdname eq 'node') { |
| 102 | − if (!$element or (!$element->{'extra'}->{'section'} | |
| 103 | − and $element->{'extra'}->{'node'} | |
| 104 | − and $element->{'extra'}->{'node'} eq $command | |
| 124 | + if (!$output_unit or | |
| 125 | + (((!$output_unit->{'extra'}->{'section'} | |
| 126 | + and $output_unit->{'extra'}->{'node'} | |
| 127 | + and $output_unit->{'extra'}->{'node'} eq $command) | |
| 128 | + or | |
| 129 | + ((($output_unit->{'extra'}->{'unit_command'} | |
| 130 | + and $output_unit->{'extra'}->{'unit_command'} eq $command) | |
| 131 | + or | |
| 132 | + ($output_unit->{'unit_command'} | |
| 133 | + and $output_unit->{'unit_command'} eq $command)) | |
| 134 | + and $command->{'extra'} | |
| 135 | + and not $command->{'extra'}->{'associated_section'})) | |
| 105 | 136 | # bogus node may not have been normalized |
| 106 | 137 | and defined($command->{'extra'}->{'normalized'}))) { |
| 107 | 138 | if ($command->{'extra'}->{'normalized'} eq 'Top') { |
| @@ -111,7 +142,15 @@ sub ffmpeg_heading_command($$$$$) · 3 unmodified lines | ||
| 111 | 142 | } |
| 112 | 143 | } |
| 113 | 144 | } else { |
| 114 | − $heading_level = $command->{'level'}; | |
| 145 | + if (defined($command->{'extra'}) | |
| 146 | + and defined($command->{'extra'}->{'section_level'})) { | |
| 147 | + $heading_level = $command->{'extra'}->{'section_level'}; | |
| 148 | + } elsif ($command->{'structure'} | |
| 149 | + and defined($command->{'structure'}->{'section_level'})) { | |
| 150 | + $heading_level = $command->{'structure'}->{'section_level'}; | |
| 151 | + } else { | |
| 152 | + $heading_level = $command->{'level'}; | |
| 153 | + } | |
| 115 | 154 | } |
| 116 | 155 | |
| 117 | 156 | my $heading = $self->command_text($command); |
| @@ -119,8 +158,8 @@ sub ffmpeg_heading_command($$$$$) · 1 unmodified line | ||
| 119 | 158 | # if there is an error in the node. |
| 120 | 159 | if (defined($heading) and $heading ne '' and defined($heading_level)) { |
| 121 | 160 | |
| 122 | − if ($Texinfo::Common::root_commands{$cmdname} | |
| 123 | − and $Texinfo::Common::sectioning_commands{$cmdname}) { | |
| 161 | + if ($root_commands{$cmdname} | |
| 162 | + and $sectioning_commands{$cmdname}) { | |
| 124 | 163 | my $content_href = $self->command_contents_href($command, 'contents', |
| 125 | 164 | $self->{'current_filename'}); |
| 126 | 165 | if ($content_href) { |
| @@ -140,7 +179,13 @@ sub ffmpeg_heading_command($$$$$) · 13 unmodified lines | ||
| 140 | 179 | } |
| 141 | 180 | } |
| 142 | 181 | |
| 143 | − if ($self->in_preformatted()) { | |
| 182 | + my $in_preformatted; | |
| 183 | + if ($program_version_num >= 7.001090) { | |
| 184 | + $in_preformatted = $self->in_preformatted_context(); | |
| 185 | + } else { | |
| 186 | + $in_preformatted = $self->in_preformatted(); | |
| 187 | + } | |
| 188 | + if ($in_preformatted) { | |
| 144 | 189 | $result .= $heading."\n"; |
| 145 | 190 | } else { |
| 146 | 191 | # if the level was changed, set the command name right |
| @@ -149,21 +194,25 @@ sub ffmpeg_heading_command($$$$$) · 2 unmodified lines | ||
| 149 | 194 | $cmdname |
| 150 | 195 | = $Texinfo::Common::level_to_structuring_command{$cmdname}->[$heading_level]; |
| 151 | 196 | } |
| 152 | − # format_heading_text expects an array of headings for texinfo >= 7.0 | |
| 153 | 197 | if ($program_version_num >= 7.000000) { |
| 154 | − $heading = [$heading]; | |
| 155 | − } | |
| 156 | − $result .= &{get_formatting_function($self,'format_heading_text')}( | |
| 198 | + $result .= &{get_formatting_function($self,'format_heading_text')}($self, | |
| 199 | + $cmdname, [$cmdname], $heading, | |
| 200 | + $heading_level +$self->get_conf('CHAPTER_HEADER_LEVEL') -1, | |
| 201 | + $heading_id, $command); | |
| 202 | + | |
| 203 | + } else { | |
| 204 | + $result .= &{get_formatting_function($self,'format_heading_text')}( | |
| 157 | 205 | $self, $cmdname, $heading, |
| 158 | 206 | $heading_level + |
| 159 | 207 | $self->get_conf('CHAPTER_HEADER_LEVEL') - 1, $command); |
| 208 | + } | |
| 160 | 209 | } |
| 161 | 210 | } |
| 162 | 211 | $result .= $content if (defined($content)); |
| 163 | 212 | return $result; |
| 164 | 213 | } |
| 165 | 214 | |
| 166 | −foreach my $command (keys(%Texinfo::Common::sectioning_commands), 'node') { | |
| 215 | +foreach my $command (keys(%sectioning_commands), 'node') { | |
| 167 | 216 | texinfo_register_command_formatting($command, \&ffmpeg_heading_command); |
| 168 | 217 | } |
| 169 | 218 | |
| @@ -188,28 +237,56 @@ sub ffmpeg_begin_file($$$) · 18 unmodified lines | ||
| 188 | 237 | my $filename = shift; |
| 189 | 238 | my $element = shift; |
| 190 | 239 | |
| 191 | − my $command; | |
| 192 | − if ($element and $self->get_conf('SPLIT')) { | |
| 193 | − $command = $self->element_command($element); | |
| 240 | + my ($element_command, $node_command, $command_for_title); | |
| 241 | + if ($element) { | |
| 242 | + if ($element->{'unit_command'}) { | |
| 243 | + $element_command = $element->{'unit_command'}; | |
| 244 | + } elsif ($self->can('tree_unit_element_command')) { | |
| 245 | + $element_command = $self->tree_unit_element_command($element); | |
| 246 | + } elsif ($self->can('tree_unit_element_command')) { | |
| 247 | + $element_command = $self->element_command($element); | |
| 248 | + } | |
| 249 | + | |
| 250 | + $node_command = $element_command; | |
| 251 | + if ($element_command and $element_command->{'cmdname'} | |
| 252 | + and $element_command->{'cmdname'} ne 'node' | |
| 253 | + and $element_command->{'extra'} | |
| 254 | + and $element_command->{'extra'}->{'associated_node'}) { | |
| 255 | + $node_command = $element_command->{'extra'}->{'associated_node'}; | |
| 256 | + } | |
| 257 | + | |
| 258 | + $command_for_title = $element_command if ($self->get_conf('SPLIT')); | |
| 194 | 259 | } |
| 195 | 260 | |
| 196 | − my ($title, $description, $encoding, $date, $css_lines, | |
| 197 | − $doctype, $bodytext, $copying_comment, $after_body_open, | |
| 198 | − $extra_head, $program_and_version, $program_homepage, | |
| 261 | + my ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype, | |
| 262 | + $root_html_element_attributes, $body_attributes, $copying_comment, | |
| 263 | + $after_body_open, $extra_head, $program_and_version, $program_homepage, | |
| 199 | 264 | $program, $generator); |
| 200 | − if ($program_version_num >= 7.000000) { | |
| 201 | − ($title, $description, $encoding, $date, $css_lines, | |
| 202 | − $doctype, $bodytext, $copying_comment, $after_body_open, | |
| 265 | + if ($program_version_num >= 7.001090) { | |
| 266 | + ($title, $description, $keywords, $encoding, $date, $css_lines, $doctype, | |
| 267 | + $root_html_element_attributes, $body_attributes, $copying_comment, | |
| 268 | + $after_body_open, $extra_head, $program_and_version, $program_homepage, | |
| 269 | + $program, $generator) = $self->_file_header_information($command_for_title, | |
| 270 | + $filename); | |
| 271 | + } elsif ($program_version_num >= 7.000000) { | |
| 272 | + ($title, $description, $encoding, $date, $css_lines, $doctype, | |
| 273 | + $root_html_element_attributes, $copying_comment, $after_body_open, | |
| 203 | 274 | $extra_head, $program_and_version, $program_homepage, |
| 204 | − $program, $generator) = $self->_file_header_information($command); | |
| 275 | + $program, $generator) = $self->_file_header_information($command_for_title, | |
| 276 | + $filename); | |
| 205 | 277 | } else { |
| 206 | 278 | ($title, $description, $encoding, $date, $css_lines, |
| 207 | − $doctype, $bodytext, $copying_comment, $after_body_open, | |
| 208 | − $extra_head, $program_and_version, $program_homepage, | |
| 209 | − $program, $generator) = $self->_file_header_informations($command); | |
| 279 | + $doctype, $root_html_element_attributes, $copying_comment, | |
| 280 | + $after_body_open, $extra_head, $program_and_version, $program_homepage, | |
| 281 | + $program, $generator) = $self->_file_header_informations($command_for_title); | |
| 210 | 282 | } |
| 211 | 283 | |
| 212 | − my $links = $self->_get_links ($filename, $element); | |
| 284 | + my $links; | |
| 285 | + if ($program_version_num >= 7.000000) { | |
| 286 | + $links = $self->_get_links($filename, $element, $node_command); | |
| 287 | + } else { | |
| 288 | + $links = $self->_get_links ($filename, $element); | |
| 289 | + } | |
| 213 | 290 | |
| 214 | 291 | my $head1 = $ENV{"FFMPEG_HEADER1"} || <<EOT; |
| 215 | 292 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| @@ -252,13 +329,25 @@ sub ffmpeg_program_string($) · 36 unmodified lines | ||
| 252 | 329 | if (defined($self->get_conf('PROGRAM')) |
| 253 | 330 | and $self->get_conf('PROGRAM') ne '' |
| 254 | 331 | and defined($self->get_conf('PACKAGE_URL'))) { |
| 255 | − return $self->convert_tree( | |
| 332 | + if ($program_version_num >= 7.001090) { | |
| 333 | + return $self->convert_tree( | |
| 334 | + $self->cdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.', | |
| 335 | + { 'program_homepage' => {'text' => $self->get_conf('PACKAGE_URL')}, | |
| 336 | + 'program' => {'text' => $self->get_conf('PROGRAM') }})); | |
| 337 | + } else { | |
| 338 | + return $self->convert_tree( | |
| 256 | 339 | $self->gdt('This document was generated using @uref{{program_homepage}, @emph{{program}}}.', |
| 257 | − { 'program_homepage' => $self->get_conf('PACKAGE_URL'), | |
| 258 | − 'program' => $self->get_conf('PROGRAM') })); | |
| 340 | + { 'program_homepage' => {'text' => $self->get_conf('PACKAGE_URL')}, | |
| 341 | + 'program' => {'text' => $self->get_conf('PROGRAM') }})); | |
| 342 | + } | |
| 259 | 343 | } else { |
| 260 | − return $self->convert_tree( | |
| 261 | − $self->gdt('This document was generated automatically.')); | |
| 344 | + if ($program_version_num >= 7.001090) { | |
| 345 | + return $self->convert_tree( | |
| 346 | + $self->cdt('This document was generated automatically.')); | |
| 347 | + } else { | |
| 348 | + return $self->convert_tree( | |
| 349 | + $self->gdt('This document was generated automatically.')); | |
| 350 | + } | |
| 262 | 351 | } |
| 263 | 352 | } |
| 264 | 353 | if ($program_version_6_8) { |