'======================================================================
' 渡辺 真
' 2006/06/04
' 2006/06/10
' 2006/06/11 VBA からAB用に移植
' 2006/09/02 AB用 からTB用に移植
' E-mail: makoto_watanabe@lime.livedoor.com
'=======================================================================
'Option Explicit
Dim InputFile As String
Dim OutputFile As String
Dim InputLine As String
Dim OutputLine As String
Dim InputLineNumber 'As Integer
Dim bodyFlag 'As Integer
Dim ProcessingLineCounter 'As Integer
Dim Figure 'As Integer
Dim KanjiNumber 'As Integer
Dim RubyNumber 'As Integer
Dim BackgroundNumber 'As Integer
Dim BackgroundFlag 'As Integer
Dim RubyFlag 'As Integer
Dim KanjiFlag 'As Integer
Dim StartTime 'As Long
Dim EndTime 'As Long
'Sub RubyTagChange()
' '変換対象のファイル名とパス取得
' InputFile = Application.GetOpenFilename("HTMLファイル,*.html")
' If InputFile = "False" Then End
' OutputFile = Left(InputFile, Len(InputFile) - 5) & "_Ruby" & ".html"
InputFile="c:\temp\mae.html"
OutputFile="c:\temp\ato_Ruby.html"
Print Time$
StartTime=Val(left$(Time$,2))*3600+Val(mid$(Time$,4,2))*60+Val(Right$(Time$,2))
'********************************
'ファイルのオープン。
bodyFlag = 0
ProcessingLineCounter = 0
Open InputFile For Input As #1
Open OutputFile For Output As #2
'*************データの読み込み***********
' While EOF(1) = 0
While not EOF(1)
ProcessingLineCounter = ProcessingLineCounter + 1
Line Input #1, InputLine
OutputLine = InputLine
' If Trim(InputLine) = "
" Then
BackgroundFlag = 1
End If
If RubyFlag = 1 Then
RubyNumber = RubyNumber + 1
ElseIf KanjiFlag = 1 Then
KanjiNumber = KanjiNumber + 1
ElseIf BackgroundFlag = 1 Then
BackgroundNumber = BackgroundNumber + 1
End If
If KanjiFlag = 1 And KMId$(InputLine, Figure, 1) = "》" Then '★★6月5日追加
OutputLine = "" & KMId$(InputLine, Figure + 1, KanjiNumber - 1) & OutputLine
KanjiNumber = 0
KanjiFlag = 0
BackgroundNumber = 0
RubyNumber = 0 '前回のRubyNumberをリセット
BackgroundFlag = 0
RubyFlag = 1
ElseIf KMId$(InputLine, Figure, 1) = "》" Then
OutputLine = "" & KMId$(InputLine, Figure + 1, BackgroundNumber - 1) & OutputLine
BackgroundNumber = 0
RubyNumber = 0 '前回のRubyNumberをリセット
BackgroundFlag = 0
RubyFlag = 1
ElseIf KMId$(InputLine, Figure, 1) = "《" Then
OutputLine = "