#
# for bthesis-0.32
# 01/26 2004
# shige
# bthesis.perl
#
# (1)	bniit.perl を参考にする。
# (2)	実装するのは
#         \papername{},\authors{}{},\jtitle{}{},\jabstract{},
#         \recieved{}
# 	およびこれらを使って \maketitle を再定義する。

package main;

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

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

sub do_cmd_jtitle {
    local($_) = @_;
    local($jtitle,$komidasi);
    $jtitle = &missing_braces unless (
        (s/$next_pair_pr_rx/$jtitle = $&;''/eo)
        ||(s/$next_pair_rx/$jtitle = $&;''/eo));
    ($t_jtitle) = &translate_commands($jtitle);
    $komidashi = &missing_braces unless (
        (s/$next_pair_pr_rx/$komidashi = $&;''/eo)
        ||(s/$next_pair_rx/$komidashi = $&;''/eo));
    ($t_komidashi) = &translate_commands($komidashi);
    $TITLE = (($komidashi)? $komidashi : $default_title);
    print STDOUT "DEBUG: jtitle = ($t_jtitle,$t_komidashi)\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_jabstract {
    local($_) = @_;
    local($next);
    $next = &missing_braces unless (
        (s/$next_pair_pr_rx/$next = $&;''/eo)
        ||(s/$next_pair_rx/$next = $&;''/eo));
    ($t_jabstract) = &translate_commands($next);
    print STDOUT "DEBUG: t_jabstract = $t_jabstract\n" if ($VERBOSITY);
    $_;
}

sub do_cmd_largearticlestyle{ @_[0]; }
sub do_cmd_numadjusttosection{ @_[0]; }

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_papername) {
	$the_title .= "<p align=\"center\">($t_papername)</p>\n";
	$the_title .= "<br>\n";
    }
    
    if ($t_jabstract) {  
        $the_title .= "<blockquote>\n";
        $the_title .= "$t_jabstract\n";
        $the_title .= "</blockquote>\n";
        $the_title .= "<br>\n";
    }

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

1;
