#!/usr/local/bin/perl -- # -*- Perl -*- # # faq2html.pl: # # Nov.20,'95. OSHIRO Naoki . # # $Log:$ # $faq2html_ver="0.2"; $date=&ctime(time); chop $date; # # HTML ヘッダの出力 # print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n\n"; print "\n"; print "
\n";

#
# 前文の処理:行頭に Q1. などが出て来るまでの処理
#
while (<>) {
    $_=&general_filter($_); # HTML 特殊文字の変換
    chop;
#    last if (/^(Q\d+)\./); # 行頭に Q1. などがあったら抜ける
    last if (/^#####/); # 行頭に '#####' があったら抜ける
    print "$_\n";
}
print "
\n"; print "$_\n"; while (<>) { $_=&general_filter($_); # HTML 特殊文字の変換 chop; # last if (/^(Q\d+)\./); # 行頭に Q1. などがあったら抜ける last if (/^\s*$/); # 行頭にもなかったら抜ける print "$_\n"; } # # FAQ 目次部の処理 # #$q_num=$1 if /^(Q\d+)\./; if (/^(\s*(\d+(\.\d+)+\))\s*)/) { $q_num=$2; $faq{$_}++; print "$`$1$'\n"; # FAQ 本体への参照生成 } while (<>) { $_=&general_filter($_); chop; # last if (!/^(Q\d+)\./); # 行頭に Q1. などがなくなったら抜ける last if (/^#####/); # 行頭に '#####' があったら抜ける unless (/^(\s*(\d+(\.\d+)+\))\s*)/) { print "$_\n"; next; } $q_num=$2; last if ($faq{$_}!=0); $faq{$_}++; print "$`$1$'
\n"; # FAQ 本体への参照生成 } # # 目次と本文との間にある文章の処理 # #print "
\n";
#print "
"; #while (<>) { # $_=&general_filter($_); # chop; # last if (/^(Q\d+)\./); # 行頭に Q1. などがあったら抜ける # print "$_\n"; #} # # FAQ 本体の処理 # #$q_num=$1 if (/^(Q\d+)\./); print "
\n"; if (/^\*\*+\s*(\d+(\.\d+)+\))/) { $q_num=$1; print ""; # ラベル生成 print "$_"; print "\n"; } else { print "$_\n"; } while (<>) { $_=&general_filter($_); chop; # if (!/^(Q\d+)/) { # s/((Q\d+)\.)/\1<\/A>/g; # FAQ 参照生成 # print "$_\n"; # next; # } if (!/^\*\*+\s*(\d+(\.\d+)+\))/) { s/(\d+(\.\d+)+\))/\1<\/A>/g; # FAQ 参照生成 print "$_\n"; next; } $q_num=$1; print ""; # ラベル生成 print "$_"; print "\n"; } # # HTML フッタの処理 # print "
\n"; print "
\n\n"; print "\n"; print "\n"; # # HTML での特殊文字を変換(例:& → &, < → <) # sub general_filter { local($_)=@_; s/&/&/g; s//>/g; s/"/"/g; return $_; } # # 時間の取得 # ;# ctime.pl is a simple Perl emulation for the well known ctime(3C) function. ;# ;# Waldemar Kebsch, Federal Republic of Germany, November 1988 ;# kebsch.pad@nixpbe.UUCP ;# ;# modified by OSHIRO Naoki [1995/12/01] sub ctime { package ctime; local($time) = @_; local($[) = 0; local($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst); local(@DoW, @MoY); @DoW = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); @MoY = ('Jan','Feb','Mar','Apr','May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'); # Determine what time zone is in effect. # Use GMT if TZ is defined as null, local time if TZ undefined. # There's no portable way to find the system default timezone. $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : ''; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = ($TZ eq 'GMT') ? gmtime($time) : localtime($time); # Hack to deal with 'PST8PDT' format of TZ # Note that this can't deal with all the esoteric forms, but it # does recognize the most common: [:]STDoff[DST[off][,rule]] if($TZ=~/^([^:\d+\-,]{3,})([+-]?\d{1,2}(:\d{1,2}){0,2})([^\d+\-,]{3,})?/){ $TZ = $isdst ? $4 : $1; } $TZ .= ' ' unless $TZ eq ''; $year += ($year < 70) ? 2000 : 1900; sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n", $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year); }