unsupported
  A   )ˆl–ß=¿J
j"T% íÆ^¸ÛÊbÑ¿�þYåY²ÆèœŒ¸óÀþÚ„� ¿Ù_ˆI|¥�+V[(ÁØ 1ž    )# highlight_syntax.pm: interface to source-highlight for syntax highlighting
#
#    Copyright (C) 2021 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 5.0;
use strict;

use File::Spec;

# FIXME does not seems to be needed in latex2html.pm?
use Texinfo::Common;
use Texinfo::Convert::Text;
use Texinfo::Convert::NodeNameNormalization;

my %languages_name_mapping = (
  'C++' => 'C',
);

my %languages_extensions = (
  'texinfo' => 'texi',
);

texinfo_add_valid_option('HIGHLIGHT_SYNTAX_DEFAULT');

texinfo_register_handler('structure', \&highlight_process);

texinfo_register_command_formatting('example', \&highlight_preformatted_command);

# the end of a string were randomly generated once for all.
my $range_separator = '_______________________________________ highlight texinfo _GT Haib0aik zei4YieH';

my %languages = ();
my %commands = ();
my $highlight_out_dir;

my %highlighted_languages_list;

sub _get_highlighted_languages($)
{
  my $self = shift;

  my $cmd = 'source-highlight --lang-list';
  if (not(open(HIGHLIGHT_LANG_LIST, '-|', $cmd))) {
    $self->document_warn(sprintf(__(
                         'highlight_syntax.pm: command failed: %s'), $cmd));
    return 0;
  }
  my $line;
  while (defined($line = <HIGHLIGHT_LANG_LIST>)) {
    chomp($line);
    if ($line =~ /^([A-Za-z0-9_\-]+) =/) {
       my $language = $1;
       $highlighted_languages_list{$language} = 1;
    } else {
      $self->document_warn(sprintf(__(
                         'highlight_syntax.pm: %s: %s: cannot parse language line'), 
                          $cmd, $line));
    }
  }
  close(HIGHLIGHT_LANG_LIST);
  return 1;
}

sub _get_language($$$)
{
  my $self = shift;
  my $cmdname = shift;
  my $command = shift;

  my $language;
  my $converted_language;

  if ($cmdname eq 'example') {
    if ($command->{'args'} and scalar(@{$command->{'args'}}) > 0) {
      $converted_language = Texinfo::Convert::NodeNameNormalization::convert($command->{'args'}->[0]);
      if ($converted_language eq '') {
        $converted_language = undef;
      }
    }
  }

  if (not defined($converted_language) and defined($self)) {
    my $default_highlight_language = $self->get_conf('HIGHLIGHT_SYNTAX_DEFAULT');
    if (defined($default_highlight_language)) {
      $converted_language = $default_highlight_language;
    }
  }

  if (defined($converted_language) and defined($languages_name_mapping{$converted_language})) {
    $language = $languages_name_mapping{$converted_language};
  } else {
    $language = $converted_language;
  }

  if ($highlighted_languages_list{$language}) {
    return $language;
  } else {
    return undef;
  }
}

sub highlight_process($$)
{
  my $self = shift;
  my $document_root = shift;

  return 1 if (defined($self->get_conf('OUTFILE'))
        and $Texinfo::Common::null_device_file{$self->get_conf('OUTFILE')});

  return 0 if (not _get_highlighted_languages($self));

  my $document_name = $self->{'document_name'};
  my $highlight_basename = "${document_name}_highlight";

  $highlight_out_dir = $self->{'destination_directory'};

  my @highlighted_commands = ('example');

  my $collected_commands = Texinfo::Common::collect_commands_in_tree($document_root, \@highlighted_commands);
  foreach my $cmdname (@highlighted_commands) {
    if (scalar(@{$collected_commands->{$cmdname}}) > 0) {
      foreach my $root (@{$collected_commands->{$cmdname