
               #'lbracechar'    => '{',
               #'rbracechar'    => '}',

               # symbols
               'arrow'             => '&rarr;',
               'bullet'            => '&bull;',
               'copyright'         => '&copy;',
               'dots'              => '&hellip;',
               #'enddots'           => '...',
               'equiv'             => '&equiv;',
               'euro'              => '&euro;',
               'exclamdown'        => '&iexcl;',
               'expansion'         => '&rarr;',
               'geq'               => '&ge;',
               #'LaTeX'             => 'LaTeX',
               'leq'               => '&le;',
               'minus'             => '&minus;',
               'ordf'              => '&ordf;',
               'ordm'              => '&ordm;',
               'point'             => '&lowast;',
               'pounds'            => '&pound;',
               #'print'             => '-|',
               'questiondown'      => '&iquest;',
               'registeredsymbol'  => '&reg;',
               'result'            => '&rArr;',
               #'TeX'               => 'TeX',
               'textdegree'        => '&deg;',

               # quotes
               'guillemetleft'     => '&laquo;',
               'guillemetright'    => '&raquo;',
               'guillemotleft'     => '&laquo;',
               'guillemotright'    => '&raquo;',
               'guilsinglleft'     => '&lsaquo;',
               'guilsinglright'    => '&rsaquo;',
               'quotedblbase'      => '&bdquo;',
               'quotedblleft'      => '&ldquo;',
               'quotedblright'     => '&rdquo;',
               'quoteleft'         => '&lsquo;',
               'quoteright'        => '&rsquo;',
               'quotesinglbase'    => '&sbquo;',

               # letters
               'AA'           => '&Aring;',
               'aa'           => '&aring;',
               'AE'           => '&AElig;',
               'ae'           => '&aelig;',
               'DH'           => '&ETH;',
               'dh'           => '&eth;',
               'L'            => '&#321;',
               'l'            => '&#322;',
               'OE'           => '&OElig;', # &OElig; not in html 3.2
               'oe'           => '&oelig;', # &oelig; not in html 3.2
               'O'            => '&Oslash;',
               'o'            => '&oslash;',
               'ss'           => '&szlig;',
               'TH'           => '&THORN;',
               'th'           => '&thorn;',

               # other
               'click'        => '&rarr;',
               # in general the following is not used since error
               # appears in 'translated_commands'
               'error'        => 'error--&gt;',
               'tie'          => '&nbsp;',
);

our %xml_text_entity_no_arg_commands_formatting
  = %xml_text_entity_no_arg_commands;

foreach my $brace_no_arg_command
     (keys(%Texinfo::Common::text_brace_no_arg_commands)) {
  if (!defined($xml_text_entity_no_arg_commands_formatting{
                                                $brace_no_arg_command})) {
    $xml_text_entity_no_arg_commands_formatting{$brace_no_arg_command}
      = $Texinfo::Common::text_brace_no_arg_commands{$brace_no_arg_command};
  }
}

foreach my $no_brace_command (keys(%Texinfo::Common::nobrace_symbol_text)) {
  if (!defined($xml_text_entity_no_arg_commands_formatting{
                                                $no_brace_command})) {
    $xml_text_entity_no_arg_commands_formatting{$no_brace_command}
      = $Texinfo::Common::nobrace_symbol_text{$no_brace_command};
  }
}

sub xml_comment($$)
{
  my $self = shift;
  my $text = shift;
  chomp $text;
  $text =~ s/--+/-/go;
  return '<!--' . $text . ' -->' . "\n";
}

our %xml_accent_entities = (
          '"',  'uml',
          '~',  'tilde',
          '^',  'circ',
          '`',  'grave',
          "'", 'acute',
          ",", 'cedil',
          'ringaccent', 'ring',
          'ogonek', 'ogon',
          'dotless', 'nodot',
         );

our %xml_accent_text_with_entities = (
      'ringaccent' => 'aA',
      "'"          => 'aeiouyAEIOUY',
      ','          => 'cC',
      '^'          => 'aeiouAEIOU',
      '`'          => 'aeiouAEIOU',
      '~'          => 'nNaoAO',
      '"'          => 'aeiouyAEIOU',
      'dotless'    => 'i',
# according to http://www2.lib.virginia.edu/small/vhp/download/ISO.txt
# however this doesn't seems to work in firefox
#      'ogonek'     => 'aeiuAEIU',
);

sub xml_numeric_entity_accent($$)
{
  my $accent = shift;
  my $text = shift;

  if (exists($Texinfo::Convert::Unicode::unicode_accented_letters{$accent})
      and exists($Texinfo::Convert::Unicode::unicode_accented_letters{$accent}->{$text})) {
    return '&#' .
      hex($Texinfo::Convert::Unicode::unicode_accented_letters{$accent}->{$text}). ';';
  }
  if (exists($Texinfo::Convert::Unicode::unicode_diacritics{$accent})) {
    my $diacritic = '&#'
       .hex($Texinfo::Convert::Unicode::unicode_diacritics{$accent}). ';';
    if ($accent ne 'tieaccent') {
      return $text . $diacritic;
    } else {
      # tieaccent diacritic is naturally and correctly composed
      # between two characters
      my $remaining_text = $text;
      # we consider that letters are either characters or entities
      if ($remaining_text =~ s/^([\p{L}\d]|&[a-zA-Z0-9]+;)([\p{L}\d]|&[a-zA-Z0-9]+;)(.*)$/$3/) {
        return $1.$diacritic.$2 . $remaining_text;
      } else {
        return $text . $diacritic;
      }
    }
  }
  return undef;
}

sub xml_accent($$$;$$$)
{
  my $self = shift;
  my $text = shift;
  my $command = shift;
  my $in_upper_case = shift;
  my $use_numeric_entities = shift;
  my $accent = $command->{'cmdname'};

  if ($in_upper_case and $text =~ /^\w$/) {
    $text = uc ($text);
  }

  # do not return a dotless i or j as such if it is further composed
  # with an accented letter, return the letter as is
  if ($accent eq 'dotless') {
    if ($Texinfo::Convert::Unicode::unicode_accented_letters{$accent}
        and exists($Texinfo::Convert::Unicode::unicode_accented_letters{$accent}->{$text})
        and ($command->{'parent'}
             and $command->{'parent'}->{'parent'}
             and $command->{'parent'}->{'parent'}->{'cmdname'}
             and $Texinfo::Convert::Unicode::unicode_accented_letters{$command->{'parent'}
                                        ->{'parent'}->{'cmdname'}})) {
      return $text;
    }
  }

  if ($use_numeric_entities) {
    my $formatted_accent = xml_numeric_entity_accent($accent, $text);
    if (defined($formatted_accent)) {
      return $formatted_accent;
    }
  } else {
    return "&${text}$xml_accent_entities{$accent};"
      if (defined($xml_accent_entities{$accent})
          and defined($xml_accent_text_with_entities{$accent})
          and ($text =~ /^[$xml_accent_text_with_entities{$accent}]$/));
    my $formatted_accent = xml_numeric_entity_accent($accent, $text);
    if (defined($formatted_accent)) {
      return $formatted_accent;
    }
  }

  # There are diacritics for every accent command except for dotless.
  # We should only get there with dotless if the argument is not recognized.
  return $text;
}

sub _xml_numeric_entities_accent($$$;$)
{
  my $self = shift;
  my $text = shift;
  my $command = shift;
  my $in_upper_case = shift;

  return xml_accent($self, $text, $command, $in_upper_case, 1);
}

sub xml_accents($$;$)
{
  my $self = shift;
  my $accent = shift;
  my $in_upper_case = shift;

  my $format_accents;
  if ($self->get_conf('USE_NUMERIC_ENTITY')) {
    $format_accents = \&_xml_numeric_entities_accent;
  } else {
    $format_accents = \&xml_accent;
  }

  return $self->convert_accents($accent, $format_accents,
                                $self->get_conf('OUTPUT_CHARACTERS'),
                                $in_upper_case);
}

1;

__END__

=head1 NAME

Texinfo::Convert::Converter - Parent class for Texinfo tree converters

=head1 SYNOPSIS

  package Texinfo::Convert::MyConverter;

  use Texinfo::Convert::Converter;
  @ISA = qw(Texinfo::Convert::Converter);

  sub converter_defaults ($$) {
    return \%myconverter_defaults;
  }
  sub converter_initialize($) {
    my $self = shift;
    ...
  }

  sub conversion_initialization($;$) {
    my $self = shift;
    my $document = shift;

    if ($document) {
      $self->set_document($document);
    }

    $self->{'document_context'} = [{}];
    ...
  }

  sub conversion_finalization($) {
    my $self = shift;
  }

  sub convert_tree($$) {
    ...
  }

  sub convert($$) {
    my $self = shift;
    my $document = shift;

    $self->conversion_initialization($document);

    ...
    $self->conversion_finalization();
  }

  sub output($$) {
    my $self = shift;
    my $document = shift;

    $self->conversion_initialization($document);

    ...
    $self->conversion_finalization();
    ...
  }

  # end of Texinfo::Convert::MyConverter

  my $converter = Texinfo::Convert::MyConverter->converter();
  $converter->output($texinfo_parsed_document);

=head1 NOTES

The Texinfo Perl module main purpose is to be used in C<texi2any> to convert
Texinfo to other formats.  There is no promise of API stability.

=head1 DESCRIPTION

C<Texinfo::Convert::Converter> is a super class that can be used to
simplify converters initialization.  The class also provide some
useful methods.  In turn, the converter should define some methods for
conversion.  In general C<convert_tree>, C<output> and C<convert> should be
defined.

=over

=item $result = $converter->convert_tree($tree)
X<C<convert_tree>>

The C<convert_tree> method is mandatory and should convert portions of Texinfo
tree. Takes a I<$converter> and Texinfo tree I<$tree> in arguments.  Returns
the converted output.

=item $result = $converter->output($document)

=item $result = $converter->output_tree($document)
X<C<output>>X<C<output_tree>>

The C<output> method is used by converters as entry point for conversion
to a file with headers and so on.  This method should be implemented by
converters.  C<output> is called from C<texi2any>.  C<output> takes a
I<$converter> and a Texinfo parsed document C<Texinfo::Document> I<$document>
as arguments.

C<Texinfo::Convert::Converter> implements a generic C<output_tree>
function suitable for conversion of the Texinfo tree, with the conversion
result output into a file or returned from the function. C<output_tree>
takes a I<$converter> and a Texinfo parsed document C<Texinfo::Document>
I<$document> as arguments. In a converter that uses C<output_tree>,
C<output> is in general defined as:

  sub output($$) {
    my $self = shift;
    my $document = shift;

    return $self->output_tree($document);
  }

In general, C<output> and C<output_tree> output to files and return C<undef>.
When the output file name is an empty string, however, it is customary
for C<output> and C<output_tree> to return the output as a character string
instead.  The output file name is obtained in C<output_tree> through a call to
L<<< C<determine_files_and_directory>|/($output_file, $destination_directory, $output_filename, $document_name, $input_basefile) = $converter->determine_files_and_directory($output_format) >>>.
In general C<determine_files_and_directory> is also used when C<output_tree> is not used.

=item $result = $converter->convert($document)
X<C<convert>>

Entry point for the conversion of a Texinfo parsed document to an output
format, without the headers usually done when outputting to a file.  C<convert>
takes a I<$converter> and a Texinfo parsed document C<Texinfo::Document>
I<$document> as arguments.  Returns the output as a character string.  Not
mandatory, not called from C<texi2any>, but used in the C<texi2any> test suite.

=item $result = $converter->convert_output_unit($output_unit)
X<C<convert_output_unit>>

Can be used for the conversion of output units by converters.
C<convert_output_unit> takes a I<$converter> and an output unit
I<$output_unit> as argument.  The implementation of
C<convert_output_unit> of C<Texinfo::Convert::Converter> could be suitable in
many cases.  Output units are typically returned by L<C<Texinfo::OutputUnits>
C<split_by_section>|Texinfo::OutputUnits/$output_units = split_by_section($document)>
or L<C<Texinfo::OutputUnits> C<split_by_node>|Texinfo::OutputUnits/$output_units =
split_by_node($document)>.

=back

Two methods, C<converter_defaults> and C<converter_initialize> are
used for initialization, to give information
to C<Texinfo::Convert::Converter> and can be redefined in converters.

To help with the conversion, the C<set_document> function associates a
C<Texinfo::Document> to a converter.  Other methods are called in default
implementations to be redefined to call code at specific moments of the
conversion. C<conversion_initialization>, for instance, is generally
called at the beginning of C<output>, C<output_tree> and C<convert>.
C<conversion_finalization> is generally called at the end of C<output_tree>,
C<output> and C<convert>.  C<output_tree> also calls the
C<conversion_output_begin> method before the Texinfo tree conversion to obtain
the beginning of the output. C<output_tree> calls the
C<conversion_output_end> method after the Texinfo tree conversion to obtain
the end of the output.

For output formats based on output units conversion, the
C<Texinfo::Convert::Plaintext> C<output> method could be a good starting
point.  HTML and Info output are also based on output units conversion.
Output units are not relevant for all the formats, the Texinfo tree can also be
converted directly, in general by using C<output_tree>.  This is how the other
Converters are implemented.

Existing backends based on C<output_tree> may be used as examples.
C<Texinfo::Convert::Texinfo> together with C<Texinfo::Convert::PlainTexinfo>,
as well as C<Texinfo::Convert::TextContent> are trivial examples.
C<Texinfo::Convert::Text> is less trivial, although still simple, while
C<Texinfo::Convert::DocBook> is a real converter that is also not too complex.

The documentation of L<Texinfo::Common>, L<Texinfo::OutputUnits>,
L<Texinfo::Convert::Unicode> and L<Texinfo::Convert::Text> describes modules or
additional function that may be useful for backends, while the parsed Texinfo
tree is described in L<Texinfo::Parser>.


=head1 METHODS

=head2 Converter Initialization

X<C<converter>>
X<C<Texinfo::Convert::Converter> initialization>

A module subclassing C<Texinfo::Convert::Converter> is created by calling
the C<converter> method that should be inherited from
C<Texinfo::Convert::Converter>.

=over

=item $converter = MyConverter->converter($options)

The I<$options> hash reference holds options for the converter.
These options should be Texinfo customization options.  The
customization options are described in the Texinfo manual or in the
customization API manual.

The C<converter> function returns a converter object (a blessed hash
reference) after checking the options and performing some initializations.

=back

To help with the initializations, the modules subclassing C<Texinfo::Convert::Converter>
can define two methods:

=over

=item \%defaults = $converter_or_class->converter_defaults($options)
X<C<converter_defaults>>

Returns a reference on a hash with defaults for the converter module
customization options or C<undef>.  The I<$options> hash reference holds
options for the converter.  This method is called through a converter by L<<<
C<converter>|/$converter = MyConverter->converter($options) >>>, but it may also
be called through a converter module class.

=item converter_initialize
X<C<converter_initialize>>

This method is called at the end of the C<Texinfo::Convert::Converter>
converter initialization.

=back

=head2 Conversion

For conversion with C<output> and C<convert> a document to convert should be
associated to the converter, in general the document passed in argument of
C<output> or C<convert>.  The C<set_document> function associates a
C<Texinfo::Document> to a converter.  This function is used in the default
implementations.

=over

=item $converter->set_document($document)
X<C<set_document>>

Associate I<$document> to I<$converter>.  Also set the encoding related customization
options based on I<$converter> customization information and information on
document encoding, and setup converter hash C<convert_text_options> value that
can be used to call L<C<Texinfo::Convert::Text::convert_to_text>|Texinfo::Convert::Text/$result = convert_to_text($tree, $text_options)>.

=back

The C<conversion_initialization>, C<conversion_finalization>,
C<conversion_output_begin> and C<conversion_output_end> can be redefined to
call code at diverse moments:

=over

=item $converter->conversion_initialization($document)

=item $converter->conversion_finalization()
X<C<conversion_initialization>>X<C<conversion_finalization>>

C<conversion_initialization> is called at the beginning of C<output_tree> and
of the default implementations of the C<output> and C<convert> functions.
C<conversion_finalization> is called at the end of C<output_tree> and of
the default C<output> and C<convert> methods implementations.
These functions should be redefined to have code run before a document
conversion and after the document conversion.

In the default case, C<conversion_initialization> calls
L<< set_document|/$converter->set_document($document) >> to associate the C<Texinfo::Document>
document passed in argument to the converter.  A subclass converter redefining
C<conversion_initialization> should in general call C<set_document> in the
redefined function too to associate the converted document to the converter.

=item $beginning = $converter->conversion_output_begin($output_file, $output_filename)

=item $end = $converter->conversion_output_end()
X<C<conversion_output_begin>>X<C<conversion_output_end>>

C<conversion_output_begin> returned string I<$beginning> is output
by the C<output_tree> calling method before the Texinfo tree conversion.
The I<$output_file> argument is the output file path.
If I<$output_file> is an empty string, it means that text will be returned by
the converter instead of being written to an output file.
I<$output_filename> is, in general, the file name portion of I<$output_file>
(without directory) but can also be set based on C<@setfilename>.

C<conversion_output_end> returned string I<$end> is output
by the C<output_tree> calling method after the Texinfo tree conversion.

The default methods implementations return an empty string.

=back

Calling C<conversion_initialization> and, if needed, C<conversion_finalization>
in redefined C<output> and C<convert> methods is not mandated, but it is
recommended to have similar converter codes.  In subclassed converters that do
not need to define C<conversion_initialization>, calling the default
C<Texinfo::Convert::Converter> C<conversion_initialization> implementation is
also recommended to avoid having to explictely call C<set_document>.
If C<conversion_initialization> is defined in a converter subclass it is
recommended to call C<set_document> at the very beginning of the function to
have the document associated to the converter.


=head2 Getting and setting customization variables

C<Texinfo::Convert::Converter> implements a simple interface to
set and retrieve Texinfo customization variables.  Helper
functions from diverse Texinfo modules needing customization
information expect an object implementing C<get_conf> and/or
C<set_conf>.  The converter itself can therefore be used in
such cases.

Customization variables are typically setup when
initializing a converter with L<<< C<converter>|/$converter = MyConverter->converter($options) >>>
and completed by Texinfo informative @-commands tree element values,
for commands such as C<@frenchspacing> or C<@footnotestyle>.

=over

=item $converter->force_conf($variable_name, $variable_value)
X<C<force_conf>>

Set the Texinfo customization option I<$variable_name> to I<$variable_value>.
This should rarely be used, but the purpose of this method is to be able
to revert a customization that is always wrong for a given output
format, like the splitting for example.

=item $converter->get_conf($variable_name)
X<C<get_conf>>

Returns the value of the Texinfo customization variable I<$variable_name>.

=item $status = $converter->set_conf($variable_name, $variable_value)
X<C<set_conf>>

Set the Texinfo customization option I<$variable_name> to I<$variable_value> if
not set as a converter option.  Returns false if the customization options
was not set.

=back

=head2 Registering error and warning messages

C<Texinfo::Convert::Converter> implements an interface to register error and
warning messages in the converter, that can be retrieved later on, in general
to be given to C<Texinfo::Report::add_formatted_message>.  Underneath,
C<Texinfo::Report> is used to setup the messages data structure.

=over

=item $converter->converter_document_error($text, $continuation)

=item $converter->converter_document_warn($text, $continuation)
X<C<converter_document_error>>X<C<converter_document_warn>>

Register a warning or an error.  The I<$text> is the text of the error or
warning.

The I<$continuation> optional arguments, if true, conveys that the line is a
continuation line of a message.

=item $converter->converter_line_error($text, $error_location_info, $continuation)

=item $converter->converter_line_warn($text, $error_location_info, $continuation)
X<C<converter_line_error>>X<C<converter_line_warn>>

Register a warning or an error with a line information.  The I<$text> is the
text of the error or warning.  The I<$error_location_info> argument holds the
information on the error or warning location.  The I<$error_location_info>
reference on hash may be obtained from Texinfo elements I<source_info> keys.
It may also be setup to point to a file name, using the C<file_name> key and to
a line number, using the C<line_nr> key.  The C<file_name> key value should be
a binary string.

The I<$continuation> optional arguments, if true, conveys that
the line is a continuation line of a message.

=item \@error_warning_messages = $converter->get_converter_errors()
X<C<get_converter_errors>>

Return a reference on an array containing the error or warning messages
registered in the converter.  Error and warning messages are hash references as
described in L<Texinfo::Report::errors|Texinfo::Report/($error_warnings_list,
$error_count) = errors($registrar)> and can be used in input of L<<
Texinfo::Report::add_formatted_message|Texinfo::Report/$registrar->add_formatted_message
($msg) >>.

=back

=head2 Translations in output documents

C<Texinfo::Convert::Converter> provides wrappers around
L<Texinfo::Translations> methods that sets the language to the current
C<documentlanguage>.

The C<cdt> and C<pcdt> methods are used to translate strings to be output in
converted documents, and return a Texinfo tree.  The C<cdt_string> is similar
but returns a simple string, for already converted strings.

=over

=item $tree = $converter->cdt($string, $replaced_substrings, $translation_context)

=item $string = $converter->cdt_string($string, $replaced_substrings, $translation_context)
X<C<cdt>> X<C<cdt_string>>

The I<$string> is a string to be translated.  With C<cdt>
the function returns a Texinfo tree, as the string is interpreted
as Texinfo code after translation.  With C<cdt_string> a string
is returned.

I<$replaced_substrings> is an optional hash reference specifying
some substitution to be done after the translation.  The key of the
I<$replaced_substrings> hash reference identifies what is to be substituted.
In the string to be translated word in brace matching keys of
I<$replaced_substrings> are replaced.
For C<cdt>, the value is a Texinfo tree that is substituted in the
resulting Texinfo tree. For C<cdt_string>, the value is a string that
is replaced in the resulting string.

The I<$translation_context> is optional.  If not C<undef> this is a translation
context string for I<$string>.  It is the first argument of C<pgettext>
in the C API of Gettext.

=item $tree = $object->pcdt($translation_context, $string, $replaced_substrings)
X<C<pcdt>>

Same to C<cdt> except that the I<$translation_context> is not optional.
This function is useful to mark strings with a translation context for
translation.  This function is similar to pgettext in the Gettext C API.

=back

=head2 Index sorting

You should call the following methods to sort indices in conversion:

=over

=item $sorted_indices = $converter->get_converter_indices_sorted_by_index()

=item $sorted_indices = $converter->get_converter_indices_sorted_by_letter()
X<C<get_converter_indices_sorted_by_index>>
X<C<get_converter_indices_sorted_by_letter>>

C<get_converter_indices_sorted_by_letter> returns the indices sorted by index
and letter, while C<get_converter_indices_sorted_by_index> returns the indices
with all entries of an index together.

When sorting by letter, an array reference of letter hash references is
associated with each index name.  Each letter hash reference has two
keys, a I<letter> key with the letter, and an I<entries> key with an array
reference of sorted index entries beginning with the letter.  The letter
is a character string suitable for sorting letters, but is not necessarily
the best to use for output.

When simply sorting, the array of the sorted index entries is associated
with the index name.

The functions call L<< C<Texinfo::Document::sorted_indices_by_letter>|Texinfo::Document/$sorted_indices = $document->sorted_indices_by_letter($customization_information, $use_unicode_collation, $locale_lang) >>
or L<< C<Texinfo::Document::sorted_indices_by_index>|Texinfo::Document/$sorted_indices = $document->sorted_indices_by_index($customization_information, $use_unicode_collation, $locale_lang) >>
with arguments based on C<USE_UNICODE_COLLATION>, C<COLLATION_LANGUAGE> and
C<DOCUMENTLANGUAGE_COLLATION> customization options, and, if relevant, current
C<@documentlanguage>.

=back

=head2 Conversion to XML

Some C<Texinfo::Convert::Converter> methods target conversion to XML.
Most methods take a I<$converter> as argument to get some
information and use methods for error reporting.

=over

=item $formatted_text = $converter->xml_format_text_with_numeric_entities($text)
X<C<xml_format_text_with_numeric_entities>>

Replace quotation marks and hyphens used to represent dash in
Texinfo text with numeric XML entities.

=item $protected_text = $converter->xml_protect_text($text)
X<C<xml_protect_text>>

Protect special XML characters (&, E<lt>, E<gt>, ") of I<$text>.

=item $comment = $converter->xml_comment($text)
X<C<xml_comment>>

Returns an XML comment for I<$text>.

=item $result = xml_accent($text, $accent_command, $in_upper_case, $use_numeric_entities)
X<C<xml_accent>>

I<$text> is the text appearing within an accent command.  I<$accent_command>
should be a Texinfo tree element corresponding to an accent command taking
an argument.  I<$in_upper_case> is optional, and, if set, the text is put
in upper case.  The function returns the accented letter as XML named entity
if possible, falling back to numeric entities if there is no named entity
and returns the argument as last resort.  I<$use_numeric_entities>
is optional.  If set, numerical entities are used instead of named entities
if possible.

=item $result = $converter->xml_accents($accent_command, $in_upper_case)
X<C<xml_accents>>

I<$accent_command> is an accent command, which may have other accent
commands nested.  If I<$in_upper_case> is set, the result should be
upper cased.  The function returns the accents formatted as XML.

=item $result = xml_numeric_entity_accent($accent_command_name, $text)
X<C<xml_numeric_entity_accent>>

I<$accent_command_name> is the name of an accent command.  I<$text> is the text
appearing within the accent command.  Returns the accented letter as XML numeric
entity, or C<undef> is there is no such entity.

=back

=head2 Helper methods

The module provides methods that may be useful for converter.
Most methods take a I<$converter> as argument to get some
information and use methods for error reporting, see L</Registering error and
warning messages>.  Also to translate strings, see L</Translations in output
documents>.  For useful methods that need a converter optionally and can be
used in converters that do not inherit from C<Texinfo::Convert::Converter>, see
L<Texinfo::Convert::Utils>.

=over

=item $contents_element = $converter->comma_index_subentries_tree($entry, $separator)
X<C<comma_index_subentries_tree>>

I<$entry> is a Texinfo tree index entry element. The function sets up
an array with the C<@subentry> contents.  The result is returned as
C<contents> in the I<$contents_element> element, or C<undef> if there is no
such content.  I<$separator> is an optional separator argument used, if given,
instead of the default: a comma followed by a space.

=item $result = $converter->convert_accents($accent_command, \&format_accents, $output_encoded_characters, $in_upper_case)
X<C<convert_accents>>

I<$accent_command> is an accent command, which may have other accent
commands nested.  The function returns the accents formatted either
as encoded letters if I<$output_encoded_characters> is set, or formatted
using I<\&format_accents>.  If I<$in_upper_case> is set, the result should be
uppercased.

=item $succeeded = $converter->create_destination_directory($destination_directory_path, $destination_directory_name)
X<C<create_destination_directory>>

Create destination directory I<$destination_directory_path>.
I<$destination_directory_path> should be a binary string, while
I<$destination_directory_name> should be a character string, that can be used in
error messages.  I<$succeeded> is true if the creation was successful or
uneeded, false otherwise.

=item ($output_file, $destination_directory, $output_filename, $document_name, $input_basefile) = $converter->determine_files_and_directory($output_format)
X<C<determine_files_and_directory>>

Determine output file and directory, as well as names related to files.  The
result depends on the presence of C<@setfilename>, on the Texinfo input file
name, and on customization options such as C<OUTPUT>, C<SUBDIR> or C<SPLIT>,
as described in the Texinfo manual.  If I<$output_format> is defined and not an
empty string, C<_$output_format> is prepended to the default directory name.

I<$output_file> is mainly relevant when not split and should be used as the
output file name.  In general, if not split and I<$output_file> is an empty
string, it means that text should be returned by the converter instead of being
written to an output file.  This is used in the test suite.
I<$destination_directory> is either the directory I<$output_file> is in, or if
split, the directory where the files should be created.  I<$output_filename>
is, in general, the file name portion of I<$output_file> (without directory)
but can also be set based on C<@setfilename>, in particular when
I<$output_file> is an empty string. I<$document_name> is I<$output_filename>
without extension.  I<$input_basefile> is based on the input Texinfo file name,
with the file name portion only (without directory).

The strings returned are text strings.

=item ($encoded_name, $encoding) = $converter->encoded_input_file_name($character_string_name, $input_file_encoding)

=item ($encoded_name, $encoding) = $converter->encoded_output_file_name($character_string_name)
X<C<encoded_input_file_name>> X<C<encoded_output_file_name>>

Encode I<$character_string_name> in the same way as other file names are
encoded in the converter, based on customization variables, and possibly
on the input file encoding.  Return the encoded name and the encoding
used to encode the name.  The C<encoded_input_file_name> and
C<encoded_output_file_name> functions use different customization variables to
determine the encoding.

The I<$input_file_encoding> argument is optional.  If set, it is used for
the input file encoding.  It is useful if there is more precise information
on the input file encoding where the file name appeared.

Note that C<encoded_output_file_name> is a wrapper around the
function with the same name in L<<< C<Texinfo::Convert::Utils::encoded_output_file_name>|Texinfo::Convert::Utils/($encoded_name, $encoding) = $converter->encoded_output_file_name($character_string_name) >>>,
and C<encoded_input_file_name> is a wrapper around the
function with the same name in L<<< C<Texinfo::Convert::Utils::encoded_input_file_name>|Texinfo::Convert::Utils/($encoded_name, $encoding) = $converter->encoded_input_file_name($character_string_name, $input_file_encoding) >>>.

=item ($caption, $prepended) = $converter->float_name_caption($float)
X<C<float_name_caption>>

I<$float> is a Texinfo tree C<@float> element.  This function
returns the caption element that should be used for the float formatting
and the I<$prepended> Texinfo tree combining the type and label
of the float.

=item $tree = $converter->float_type_number($float)
X<C<float_type_number>>

I<$float> is a Texinfo tree C<@float> element.  This function
returns the type and number of the float as a Texinfo tree with
translations.

=item $end_line = $converter->format_comment_or_return_end_line($element)
X<C<format_comment_or_return_end_line>>

Format comment at end of line or return the end of line associated with
the element.  In many cases, converters ignore comments and output is
better formatted with new lines added independently of the presence
of newline or comment in the initial Texinfo line, so most converters
are better off not using this method.

=item $filename = sub $converter->node_information_filename($normalized, $label_element)
X<C<node_information_filename>>

Returns the normalized file name corresponding to the I<$normalized>
node name and to the I<$label_element> node name element contents.

=item ($normalized_name, $filename) = $converter->normalized_sectioning_command_filename($element)
X<C<normalized_sectioning_command_filename>>

Returns a normalized name I<$normalized_name> corresponding to a sectioning
command tree element I<$element>, expanding the command argument using
transliteration and characters protection.  Also returns I<$filename>
the corresponding filename based on I<$normalized_name> taking into
account additional constraint on file names and adding a file extension.

=item $converter->present_bug_message($message, $element)
X<C<present_bug_message>>

Show a bug message using I<$message> text.  Use information on
I<$element> tree element if given in argument.

=item $converter->set_global_document_commands($commands_location, $selected_commands)
X<C<set_global_document_commands>>

Set the Texinfo customization options for @-commands.  I<$selected_commands>
is an array reference containing the @-commands set.  I<$commands_location>
specifies where in the document the value should be taken from. The
possibilities are:

=over

=item before

Set to the values before document conversion, from defaults and command-line.

=item last

Set to the last value for the command.

=item preamble

Set sequentially to the values in the Texinfo preamble.

=item preamble_or_first

Set to the first value of the command if the first command is not
in the Texinfo preamble, else set as with I<preamble>,
sequentially to the values in the Texinfo preamble.

=back

Notice that the only effect of this function is to set a customization
variable value, no @-command side effects are run, no associated customization
variables are set.

For more information on the function used to set the value for each of the command, see
L<C<Texinfo::Common> C<set_global_document_command>|Texinfo::Common/$element = set_global_document_command($customization_information, $global_commands_information, $cmdname, $command_location)>.

=item $table_item_tree = $converter->table_item_content_tree($element)
X<C<table_item_content_tree>>

I<$element> should be an C<@item> or C<@itemx> tree element.
Returns a tree in which the @-command in argument of C<@*table>
of the I<$element> has been applied to the I<$element> line argument,
or C<undef>.

=item $result = $converter->top_node_filename($document_name)
X<C<top_node_filename>>

Returns a file name for the Top node file using either C<TOP_FILE>
customization value, or C<EXTENSION> customization value and I<$document_name>.

=back

Finally, there is:

=over

=item $result = $converter->output_internal_links()
X<C<output_internal_links>>

At this level, the method just returns undef.  It is used in the HTML
output, following the C<--internal-links> option of C<texi2any>
specification.

=back

=head1 SEE ALSO

L<Texinfo::Common>, L<Texinfo::Convert::Unicode>, L<Texinfo::Report>,
L<Texinfo::Translations>, L<Texinfo::Convert::Utils> and L<Texinfo::Parser>.

=head1 AUTHOR

Patrice Dumas, E<lt>pertusus@free.frE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2011- Free Software Foundation, Inc.  See the source file for
all copyright years.

This library 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.

=cut
