(root)/
texinfo-7.1/
tp/
t/
init/
t2h_singular.init
# -*-perl-*-
######################################################################
# 
# File: t2h_singular.init init file for singular t2h
#

use strict;

my $T2H_BLUE_BUTTONS = 0;

# we only redefine things which ar of relevance to singular
# all the others we simply "include"

# Set the output file prefix, prepended to all .html, .png and .pl files.
texinfo_set_from_init_file('setfilename', 'sing');

# add html and tex to expanded formats.  html should be redundant.
texinfo_add_to_option_list('EXPANDED_FORMATS', ['html', 'tex']);

# if set, creates one html file per node
texinfo_set_from_init_file('SPLIT', 'node');

# we use .htm, but not for external references, both as target and
# source.
my $external_extension = 'html';
texinfo_set_from_init_file('EXTERNAL_CROSSREF_EXTENSION',
                           $external_extension);

#if set cross-references use the xref node name argument
texinfo_set_from_init_file('XREF_USE_NODE_NAME_ARG', 1);

# if set, chatter about what we are doing
texinfo_set_from_init_file('VERBOSE', 1);

my $T2H_SING_base_images = '../singular_images/';

# inside <BODY ..>
texinfo_set_from_init_file('BODYTEXT','lang="en"  background="'.${T2H_SING_base_images}.'Mybg.png"');

# after <BODY>
texinfo_set_from_init_file('AFTER_BODY_OPEN', "\n");

# before </BODY>
texinfo_set_from_init_file('PRE_BODY_CLOSE', "\n");

# there is a redefinition of about special element body formatting
# function to replace the text at the same place as PROGRAM_NAME_IN_ABOUT.
texinfo_set_from_init_file('PROGRAM_NAME_IN_ABOUT', 0);

# if using tex4ht, must be in latex mode due to \textbf
$Texinfo::TeX4HT::STYLE='latex';

# title is already in the manual
#$print_title = \&T2H_DEFAULT_print_title;
texinfo_set_from_init_file('SHOW_TITLE', 0);

# footer

texinfo_register_formatting_function('format_element_footer' , \&singular_format_footer);

sub singular_format_footer($$$$)
{
  my $self = shift;
  my $type = shift;
  my $element = shift;
  my $content = shift;


  my $end_page = (!$element->{'structure'}->{'unit_next'}
   or (defined($element->{'structure'}->{'unit_filename'})
       and $element->{'structure'}->{'unit_filename'}
           ne $element->{'structure'}->{'unit_next'}->{'structure'}->{'unit_filename'}
       and $self->count_elements_in_filename('current',
                   $element->{'structure'}->{'unit_filename'}) == 1));

  if ($self->element_is_tree_unit_top($element)) {
    my $buttons = $self->get_conf('TOP_BUTTONS');
    my $content_href = $self->from_element_direction('Contents', 'href', $element);
    my $about_href = $self->from_element_direction('About', 'href', $element);
    my $result = '';
    if ($content_href or $about_href) {
      $result .= "<blockquote>\n";
      $result .= "<a href=\"$content_href\">Table of Contents</a>\n<br>\n"
         if ($content_href);
      $result .= "<a href=\"$about_href\">About this document</a>"
         if ($about_href);
      $result .= "</blockquote>";
    }
    $result .= "</td>
</tr>
</table>
"
       if ($self->get_conf('VERTICAL_HEAD_NAVIGATION'));
    $result .= $self->get_conf('DEFAULT_RULE')."\n"
       if (defined($self->get_conf('DEFAULT_RULE')));
    if ($end_page) {
      $result .= join('', $self->close_registered_sections_level(0));
      $result .= &{$self->formatting_function('format_navigation_panel')}($self,
                                            $buttons, undef, $element);
    }
    return $result;
  }

  return &{$self->default_formatting_function('format_element_footer')}($self,
                                            $type, $element, $content);
}


texinfo_register_formatting_function('format_end_file' , \&singular_format_end_file);

# footer of page
sub singular_format_end_file($$$)
{
  my $self = shift;
  my $pre_body_close = $self->get_conf('PRE_BODY_CLOSE');
  my $program_homepage = $self->get_conf('PACKAGE_URL');
  my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION');
  my $version = $self->get_value('VERSION');
  my $version_date = $self->get_value('VERSION_DATE');
  $version = 'NO VERSION' if (!defined($version));
  $version_date = 'NO VERSION DATE' if (!defined($version_date));
  my $result = '
<font size="-1">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; User manual for <a href="http://www.singular.uni-kl.de/"><i>Singular</i></a> version '."$version, $version_date,
generated by <a href=\"$program_homepage\"><i>$program_and_version</i></a>.
</font>
$pre_body_close
</body>
</html>
";
}


sub singular_banner
{
  my $result = '';
  $result .= <<EOT;
  <a href="index.htm"><img
    src="${T2H_SING_base_images}singular-icon-transparent.png" width="50"
      border="0" alt="Top"></a>
EOT
  return ($result, 0);
}

# always use bottom navigation
texinfo_set_from_init_file('WORDS_IN_PAGE', 0);

texinfo_set_from_init_file('VERTICAL_HEAD_NAVIGATION', 1);
my @SECTION_BUTTONS =
  (
   \&singular_banner,
   'Back', 'Forward',   'FastBack', 'FastForward',
   'Up', 'Top', 'Contents', 'Index', 'About'
  );

texinfo_set_from_init_file ('SECTION_BUTTONS', \@SECTION_BUTTONS);

my @NODE_FOOTER_BUTTONS = @SECTION_BUTTONS;
texinfo_set_from_init_file ('NODE_FOOTER_BUTTONS', \@SECTION_BUTTONS);

# buttons for misc stuff
my @MISC_BUTTONS = (\&singular_banner, 'Top', 'Contents', 'Index', 'About');
my @TOP_BUTTONS = (\&singular_banner, 'Top', 'Contents', 'Index', 'About');

texinfo_set_from_init_file ('MISC_BUTTONS', \@MISC_BUTTONS);
texinfo_set_from_init_file ('TOP_BUTTONS', \@TOP_BUTTONS);

texinfo_set_from_init_file('ICONS', 1);

my %ACTIVE_ICONS;
my %PASSIVE_ICONS;

if ($T2H_BLUE_BUTTONS) {
  
  %ACTIVE_ICONS =
  (
   'Top',      'blue_top.png',
   'Contents', 'blue_dir.png',
   'Overview', '',
   'Index',    'blue_readme.png',
   'Back',     'blue_prev.png',
   'FastBack', 'blue_pprev.png',
   'Prev',     'blue_pprev.png',
   'Up',       'blue_up.png',
   'Next',     'blue_nnext.png',
   'Forward',  'blue_next.png',
   'FastForward', 'blue_nnext.png',
   'About' ,    'blue_help.png',
   ' ',        ''
  );

  %PASSIVE_ICONS =
  (
   'Top',      'blue_top.png',
   'Contents', 'blue_dir.png',
   'Overview', '',
   'Index',    'blue_readme.png',
   'Back',     'blue_prev.png',
   'FastBack', 'blue_pprev.png',
   'Prev',     'blue_pprev.png',
   'Up',       'blue_up.png',
   'Next',     'blue_nnext.png',
   'Forward',  'blue_next.png',
   'FastForward', 'blue_nnext.png',
   'About' ,    'blue_help.png',
  );

} else {

  %ACTIVE_ICONS =
  (
   'Top',      'a_top.png',
   'Contents', 'a_tableofcon.png',
   'Overview', '',
   'Index',    'a_index.png',
   'Back',     'a_left.png',
   'FastBack', 'a_leftdouble.png',
   'Prev',     'a_leftdouble.png',
   'Up',       'a_up.png',
   'Next',     'a_rightdouble.png',
   'Forward',  'a_right.png',
   'FastForward', 'a_rightdouble.png',
   'About' ,    'a_help.png',
   ' ',        'a_empty.png'
  );

  %PASSIVE_ICONS =
  (
   'Top',      'a_top_na.png',
   'Contents', 'a_tableofcon_na.png',
   'Overview', '',
   'Index',    'a_index_na.png',
   'Back',     'a_left_na.png',
   'FastBack', 'a_leftdouble_na.png',
   'Prev',     'a_leftdouble_na.png',
   'Up',       'a_up_na.png',
   'Next',     'a_rightdouble_na.png',
   'Forward',  'a_right_na.png',
   'FastForward', 'a_rightdouble_na.png',
   'About' ,    'a_help_na.png',
  );
}

foreach my $hash_ref((\%ACTIVE_ICONS, \%PASSIVE_ICONS)) {
  foreach my $key (keys(%$hash_ref)) {
    next if ($hash_ref->{$key} eq '');
    $hash_ref->{$key} = $T2H_SING_base_images.$hash_ref->{$key};
  }
}

texinfo_set_from_init_file ('ACTIVE_ICONS', \%ACTIVE_ICONS);
texinfo_set_from_init_file ('PASSIVE_ICONS', \%PASSIVE_ICONS);

sub singular_format_special_body_about($$$)
{
  my $self = shift;
  my $special_type = shift;
  my $element = shift;

  my $version = $self->get_value('VERSION');
  my $version_date = $self->get_value('VERSION_DATE');
  $version = 'NO VERSION' if (!defined($version));
  $version_date = 'NO VERSION DATE' if (!defined($version_date));
  my $program_homepage = $self->get_conf('PACKAGE_URL');
  my $program_and_version = $self->get_conf('PACKAGE_AND_VERSION');
  my $result = '';
  $result .= <<EOT;
<p>
This document is the user manual for <a href="http://www.singular.uni-kl.de/"><i>Singular</i></a> version $version, $version_date.
<br>

For questions and comments about Singular, send email to <a href="mailto:singular\@mathematik.uni-kl.de">singular\@mathematik.uni-kl.de</a>.

</p>
<p>
This document was generated by <a href="$program_homepage"><i>$program_and_version</i></a>
and <a href="http://www-dsed.llnl.gov/files/programs/unix/latex2html/manual/">LaTeX2<tt>HTML</tt></a>
and is best  viewed with a 16 or 18 point screen font.
</p>
EOT

  $result .= &{$self->defaults_special_element_body_formatting($special_type)}(
                                                 $self, $special_type, $element);
  return $result;
}

texinfo_register_formatting_special_element_body ('about',
                       \&singular_format_special_body_about);

# a whole menu
texinfo_register_command_formatting('menu', \&t2h_sing_menu);

sub t2h_sing_menu($$$$$)
{
  my $self = shift;
  my $cmdname = shift;
  my $command = shift;
  my $args = shift;
  my $content = shift;

  if ($content =~ /\S/) {
    return "<blockquote><table class=\"menu\" border=\"0\" cellspacing=\"0\">\n" . $content. "</table></blockquote>\n";
  }
  return '';
}

# We want to use EXTENSION for non node files only
sub t2h_node_file_name($$$)
{
  my $self = shift;
  my $element = shift;
  my $filename = shift;

  my $external_file_extension = '.' . $external_extension;

  my $orig_filename = $filename;

  my $extension = '';
  $extension = '.'.$self->get_conf('EXTENSION')
          if (defined($self->get_conf('EXTENSION'))
              and $self->get_conf('EXTENSION') ne '');
  if ($extension eq '') {
    $filename .= $external_file_extension;
  } else {
    my $quoted_extension = quotemeta($extension);
    $filename =~ s/${quoted_extension}$/${external_file_extension}/;
  }

  return $filename;
}

texinfo_register_file_id_setting_function('node_file_name', \&t2h_node_file_name);

1;    # This must be the last line