英語論文の論文題名(タイトル)の各単語の1文字目を前置詞を除き、
自動的に大文字にすることを考えています。
試しに作成したbstファイルの関連箇所は以下のようなものですが、
希望どおりには動作せず、論文題名がtitleエントリーに入力したまま表示されます。
希望の動作を行うようにするにはどうすればいいか、教えていただけませんでしょうか?
--------------------------
% 前置詞判定
FUNCTION {is.preposition}
{
duplicate$ "of" = swap$
duplicate$ "in" = or swap$
duplicate$ "on" = or swap$
duplicate$ "at" = or swap$
duplicate$ "for" = or swap$
duplicate$ "and" = or swap$
duplicate$ "or" = or swap$
duplicate$ "the" = or swap$
duplicate$ "a" = or swap$
duplicate$ "an" = or
}
% 先頭1文字大文字化 + 残りは小文字のまま
FUNCTION {capitalize.word}
{
's :=
s empty$
{ "" }
{
s #1 text.prefix$ "t" change.case$
s text.length$ #2 <
{ "" }
{ s #2 global.max$ substring$ }
if$
*
}
if$
}
% 前置詞なら小文字化(全体をlowercase)
FUNCTION {lowercase.word}
{
"l" change.case$
}
% タイトル大文字化処理(前置詞除外)
FUNCTION {capitalize.title}
{
't := % 残りの文字列
"" 'result := % 蓄積
#1 'firstword := % 最初の単語フラグ
{ t "" = not } % ループ条件
{
t " " split$ % left right
't := % 残り
'word := % 単語
word empty$
{ }
{
firstword #1 =
{ word capitalize.word 'firstword := #0 'firstword := }
{
word is.preposition
{ word lowercase.word }
{ word capitalize.word }
if$
}
if$
result empty$
{ 'result := }
{ result " " * swap$ * 'result := }
if$
}
if$
}
while$
result
}
FUNCTION {format.title}
{ title empty$
{ "\textcolor{red}{title missing}" }
{ title capitalize.title}
if$
}
----------------------------------------------