#
# for bniit-0.6.sty 
# 11/04 2003 version 0.1
# shige
# bniit.perl
#
# (1)	styles/amsmath.perl を参考にする。
# (2)	実装するのは
# 	  \authors{}{}{}, \kiyouname{},\jtitle{},\etitle{},\recieved{},
# 	  \synopsis{}, \keywords{}
# 	およびこれらを使って \maketitle を再定義する。

package main;

# \authors は引数が 3 つ、それに複数指定があるとそれにともなって
# 追加する必要がある。
# @t_authors, @t_eauthors, @t_belonging に各々保存していく。
sub do_cmd_authors {
    local($_) = @_;
    local($jauthor,$eauthor,$belong);
    $jauthor = &missing_braces unless (
       (s/$next_pair_pr_rx/$jauthor=$2;''/eo)
        ||(s/$next_pair_rx/$jauthor=$2;''/eo));
    ($jauthor) = &translate_commands($jauthor);
    $eauthor = &missing_braces unless (
       (s/$next_pair_pr_rx/$eauthor=$2;''/eo)
        ||(s/$next_pair_rx/$eauthor=$2;''/eo));
    ($eauthor) = &translate_commands($eauthor);
    $belong  = &missing_braces unless (
       (s/$next_pair_pr_rx/$belong=$2;''/eo)
        ||(s/$next_pair_rx/$belong=$2;''/eo));
    ($belong) = &translate_commands($belong);
    $t_authors[$#t_authors+1]=$jauthor;
    $t_eauthors[$#t_eauthors+1]=$eauthor;
    $t_belonging[$#t_belonging+1]=$belong;
    print STDOUT "DEBUG: author = ($jauthor,$eauthor,$belong)\n" if $VERBOSITY;
    $_;
}

sub do_cmd_kiyouname {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_kiyouname) = &translate_commands($next);
    print STDOUT "DEBUG: t_kiyouname = $t_kiyouname\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_jtitle {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_jtitle) = &translate_commands($next);
    print STDOUT "DEBUG: t_jtitle = $t_jtitle\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_etitle {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_etitle) = &translate_commands($next);
    print STDOUT "DEBUG: t_etitle = $t_etitle\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_recieved {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_recieved) = &translate_commands($next);
    print STDOUT "DEBUG: t_recieved = $t_recieved\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_synopsis {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_synopsis) = &translate_commands($next);
    print STDOUT "DEBUG: t_synopsis = $t_synopsis\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_keywords {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_keywords) = &translate_commands($next);
    print STDOUT "DEBUG: t_keywords = $t_keywords\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_maketitle {
    local($_) = @_;
    local($the_title) = '';
    local($author);

    if ($t_jtitle) {
	$the_title .= "<h1 align=\"center\">$t_jtitle</h1>\n";
    }
    if (@t_authors) {
	foreach $j (0 .. $#t_authors){
	    $the_title .= "<p align=\"center\"><strong>$t_authors[$j]";
	    $the_title .= " ($t_belonging[$j])</strong></p>\n";
	}
    }
    if ($t_etitle) {
	$the_title .= "<h1 align=\"center\">$t_etitle</h1>\n";
    }
    if (@t_authors) {
	foreach $j (0 .. $#t_eauthors){
	    $the_title .= "<p align=\"center\"><strong>$t_eauthors[$j]";
	    $the_title .= "</strong></p>\n";
	}
    }
    if ($t_kiyouname) {
	$the_title .= "<p align=\"center\">($t_kiyouname)</p>\n";
	$the_title .= "<br>\n";
    }
    
    if ($t_synopsis) {	
	$the_title .= "<blockquote>\n";
	$the_title .= "$t_synopsis\n";
	$the_title .= "</blockquote>\n";
	$the_title .= "<br>\n";
    }
    if ($t_keywords) {	
	$the_title .= "<em>Keywords</em>\n";
	$the_title .= "<blockquote>\n";
	$the_title .= "$t_keywords\n";
	$the_title .= "</blockquote>\n";
    }

    # $the_title .= "<hr>\n";
    $the_title . $_ ;
}

1;
