今までの作業 |
newtech2.vbs | default.n2s | |
---|---|---|
2004/10/15 | [link]等で空白を%20にエンコードするようにした []内で が最初の1つしか空白に変換されないバグを修正 | |
2004/10/14 | vbs命令を追加 | inlinethums追加 [a:\hogehoge]と[\hogehoge]と[..\hogehoge]形式を追加 |
2004/10/09 | 編集用リンクに「このフォルダのindex.htmlを開く」を追加。 | |
2004/10/07 | #h5と#quoteを#p(div class=p)の中に含めることにした。 | |
2004/10/06 | ファイルの最後で閉じていないシャープ命令を放置する生涯を修正 | #olと#ulのBeforeCloseから#pを外しAutoUpに#pを追加した。 #quoteの内容を<div class="quote">から<blockquote>に変更 |
2004/09/11 | groupで同じ指定を繰り返すとエラーになる障害を訂正 | |
2004/09/08 | ulとolにも縦棒による改行を追加。 | |
2004/08/20 | 試しにCScript.exe専用にした。 Console.Debug追加。default.n2sでdebugに0以外の値を代入すると有効になる。 | "debug=1"を追加。 |
2004/08/19 | MovePathの処理方法を変更。 | #let使用時に暗黙の#pが自動解除されてしまうバグを修正(原因は08/10の変更)。 |
2004/08/18 | [link,〜,hogehoge]形式でURLをhttp://から書いた場合のみ別窓表示にするようにした。 | |
2004/08/10 | #let命令をそれ以降の行から有効にするようにした(今までは全体に有効だった)。 | #inline.table、#inline.close、#ul.freeを追加。 |
2004/08/03 | <pale>追加。 | |
2004/08/02 | easytableで{th}を指定できないバグを修正 | |
2004/07/25 | 各種デバッグ #include命令に第2引数を追加 #include.unchangeを標準命令からマクロ命令に変更 | [link,〜,〜]の仕様を変更(別窓対応) |
今後の案 |
|
vbsファイル |
'テキストファイルをHTMLに変換するプログラムの案 2004/08/21
'変数宣言の省略を禁止
Option Explicit
'変数の宣言
Public FSO,ARG,TS,Init,User 'オブジェクト
Public Reg,Matches,Match,SubMatch '正規表現用オブジェクト
Public TmpStream 'テンポラリストリーム
Public ComList
Public ProcessedFName,BeProcessFName
Public ExtendString,Console
Public CStrOne,CStrTwo
Private This,That,It
Private ErrStr
Private Fo,Fi,Fc
'初期化
CStrOne=Chr(1)
CStrTwo=Chr(2)
'定数の宣言(お約束)
Const ForReading = 1
Const ForWriting = 2
'オブジェクトの宣言
Set ARG = WScript.Arguments
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Init = CreateObject("Scripting.Dictionary")
Set User = CreateObject("Scripting.Dictionary")
Set Reg = New RegExp
Set ExtendString = New ExtendStringObject
Set Console = New ConsoleObject
Reg.IgnoreCase = True '大文字小文字を区別しない
Reg.Global = True '全ての一致を処理
'引数の確認
Select Case ARG.Count
Case 0
Console.Err "引数が指定されていません。"
Case Else
For Each This in ARG
Select Case lcase(Mid(This,InstrRev(This,".")))
Case ".n2c":Push BeProcessFName,This
Case ".n2d":Push BeProcessFName,This
Case ".nt2":Push BeProcessFName,This
Case Else
Console.Err "変換できないファイルが指定されています。"
End Select
Next
End Select
'変換
Do While BeProcessFName<>""
This=Shift(BeProcessFName)
If lcase(FSO.GetBaseName(This))="html" Then
Console.Err "HTMLファイルを変換しようとしています。"+vbcrlf+ _
"ファイル名:"+This
ElseIf Instr(ProcessedFName,This+vbCrLf) Then
Console.Err "同じファイルを変換しようとしています。"+vbcrlf+ _
"ファイル名:"+This
Else
Push ProcessedFName,This
ErrStr=Process(This)
If ErrStr<>"" Then
Console.Err ErrStr
End If
End If
Loop
Console.Confilm "作業が完了しました。"
WScript.Quit
'-------------------------------------------------
'メイン
'-------------------------------------------------
Function Process(ByVal FName)
'ログ
Console.Pass """"+FName+"""の変換を開始"
'初期化
Init.RemoveAll
User.RemoveAll
Init("file.input")=FName
'変数の宣言
Dim SrcB,SrcA,SrcT,This,That
Dim ComNest,ComNestArg
Dim ProcessFolder,SaveFolder
Dim F
Dim ErrFile
Dim i
Dim BeReadSetupFile,ReadingSetupFile
'初期値
ProcessFolder=FSO.GetParentFolderName(FName)
'空ファイルの場合はすぐ降りる
Set F=FSO.GetFile(FName)
If F.Size=0 Then
Console.Pass "空ファイルなので変換せず。"
Exit Function
End If
Set F=Nothing
'下準備
'設定ファイルを読むための下準備
'config.txtは以前との互換性のため残してある。現在はdefault.n2sを推奨。
SrcB=""
BeReadSetupFile=MovePath(FSO.GetParentFolderName(WScript.ScriptFullName),"config.txt" )+vbcrlf+ _
MovePath(FSO.GetParentFolderName(WScript.ScriptFullName),"default.n2s")+vbcrlf+ _
MovePath(FSO.GetParentFolderName(FName) ,"config.txt" )+vbcrlf+ _
MovePath(FSO.GetParentFolderName(FName) ,"default.n2s")+vbcrlf
'設定ファイルを読み込む
Do While BeReadSetupFile<>""
ReadingSetUpFile=Shift(BeReadSetupFile)
SrcB=ReadFile(ReadingSetUpFile)
'設定ファイルの解析
Reg.Pattern="(\s*'.*)" '注釈を取り除く
SrcB=Reg.Replace(SrcB,vbCr)
'設定ファイルの解釈
Do While SrcB<>""
This=Trim(Shift(SrcB))
If This="" Then
ElseIf lcase(Left(This,6))="group:"Then '複数行の処理
That=Mid(This,7)
This=Trim(Shift(SrcB))
Do While This<>"//"
TmpPush This
This=Trim(Shift(SrcB))
Loop
Init(That)=TmpRefresh
ElseIf Instr(This,"=") Then '単独行の処理
That=Left(This,Instr(This,"=")-1)
This=Mid(This,Instr(This,"=")+1)
Init(That)=This
Else
Process="設定ファイルで不正な行を発見しました。"+vbCrLf+ _
"対象:"+ReadingSetupFile+vbCrLf+ _
"内容:"+This
End If
Loop
Loop
'処理
SaveFolder=MovePath(ProcessFolder,Init.Item("SaveFolder"))
'ファイルの日付を比較
If FSO.FileExists(FSO.BuildPath(SaveFolder,FSO.GetBaseName(FName)+".html")) Then
Set F=FSO.GetFile(FName)
This=FileLastUpdate(FName)
That=FileLastUpdate(FSO.GetFile(FSO.BuildPath(SaveFolder,FSO.GetBaseName(FName)+".html")))
If This<That Then Exit Function
End If
'テキストファイルを読み込む
SrcB=""
Push SrcB,ReadFile(FName)
Push SrcB,vbCrLf+"#eof"+vbCrLf
'pass1.明示されていないコマンドを明示する
Do While SrcB<>""
This=Shift(SrcB)
If This="" Then
ElseIf Left(This,1)<>"#"Then
'本当の形をTmpPushに代入しておく
Execute Init.Item("ommit")
That=TmpRefresh
If That<>"" Then
UnShift SrcB,That
This=""
End If
Else
ComList=Split(Mid(This,2),",")
If ComLIst(0)="end"Then
SrcB=""
This=""
ElseIf ComList(0)="vbs"Then
ElseIf ComList(0)="let"Then 'Thisを初期化しない
ElseIf ComList(0)="join"Then
Push BeProcessFName,ComList(1)
This=""
ElseIf ComList(0)="join.folder"Then
Set Fo=FSO.GetFolder(ComList(1))
Set Fc=Fo.Files
For Each That In Fc
If ExtendString.RegTest(That,"\.nt2$|\.n2d$|\.n2c$") Then
If Instr(ProcessedFName,That+vbCrLf)=0 Then
Push BeProcessFName,That
End If
End If
Next
This=""
ElseIf Init.Item("macro."+ComList(0))<>"" Then
That=Init.Item("macro."+ComList(0))
That=SpecialEVal(That)
UnShift SrcB,That
This=""
ElseIf ComList(0)="include"Then
That=This
This=include(ComList(1))
If ComList(2)<>"" Then
That=Mid(That,Instr(That,",")+1)
That=Mid(That,Instr(That,",")+1)
Execute That
End If
UnShift SrcB,This
This=""
ElseIf ComList(0)="close"Then
That=Init.Item(ComList(1)+".TooClose")
If Instr(That,";"+TestPop(ComNest)+";") Then
UnShift SrcB,This
UnShift SrcB,"#close,"+TestPop(ComNest)
This=""
Else
Pop ComNest
End If
Else
That=Init.Item(ComList(0)+".BeforeClose")
If Instr(That,";"+TestPop(ComNest)+";") Then
UnShift SrcB,This
UnShift SrcB,"#close,"+TestPop(ComNest)
This=""
Else
That=Init.Item(ComList(0)+".AutoUp")+","
That=Left(That,Instr(That,",")-1)
If That<>"" And Instr(ComNest,That+vbCrLf)=0 Then
UnShift SrcB,This
UnShift SrcB,"#"+Init.Item(ComList(0)+".AutoUp")
This=""
Else
Push ComNest,ComList(0)
End If
End If
End If
End If
If This<>"" Then Push SrcA,This
Loop
Do While TestPop(ComNest)<>""
' msgbox ComNest
Push SrcA,"#close,"+Pop(ComNest)
Loop
' msgbox right(SrcA,200)
SrcB=SrcA
SrcA=""
ComNest=""
'pass2.htmlファイルに変換する
Do While SrcB<>""
This=Shift(SrcB)
If Left(This,1)="#"Then 'コマンド
ComList=Split(Mid(This,2),",")
If ComList(0)="let"Then
If Left(ComList(1),5)="init." Then
Init.item(Mid(ComList(1),6))=ComList(2)
Else
User.item(ComList(1))=ComList(2)
End If
This=""
ElseIf comList(0)="vbs"then
execute replace(comList(1),"::",vbcrlf)
ElseIf Init.Item(ComList(0)+".Open")<>"" Then
Push ComNest,ComList(0)
Push ComNestArg,This
This=AttrConv(Init.Item(ComList(0)), _
Replace(Init.Item(ComList(0)+".Open"),"@"," "+ _
User.Item(ComList(0)+".temp")+" "+ _
User.Item(ComList(0)+".attr")+" "))
Else
Select Case ComList(0)
Case "close"
If ComList(1)=TestPop(ComNest) Then
User.Item(ComList(1)+".temp")=""
This=Init.Item(ComList(1)+".Close")
Pop ComNest
Pop ComNestArg
Else
Process="#close,"+TestPop(ComNest)+ _
"を置くべきところで"+vbcrlf+ _
"#close,"+ComList(1)+"を置いてしまっています。"
Exit Function
End If
case else
Process="Unknown Command:"+ComList(0)
Exit Function
End Select
End If
Else
If Init.Item(TestPop(comNest)+".Natural")<>"True" Then
This=Replace(This,"&",chr(2))
This=Replace(This,"#","#")
This=Replace(This,chr(9)," ")
This=Replace(This,"<","<")
This=Replace(This,">",">")
This=Replace(This,"\\[","\[")
This=Replace(This,"\\]","\]")
This=Replace(This,"\[","[")
This=Replace(This,"\]","]")
This=Replace(This," "," ")
This=Replace(This,chr(2),"&")
End If
That=Init.Item(TestPop(ComNest)+".Process")
That=Replace(That,"::",vbCrLf)
ComList=Split(TestPop(ComNestArg),",")
ReDim Preserve ComList(15)
If That<>"" Then Execute That
If Init.Item(TestPop(comNest)+".Natural")<>"True" Then
This=SpecialEVal(This)
End If
End If
If Trim(This)<>"" Then Push SrcA,Trim(This)
Loop
UnShift SrcA,SpecialEval(Init.Item("head"))
Push SrcA,SpecialEval(Init.Item("bottom"))
'保存する
If LCase(Mid(FName,InstrRev(FName,".")))<>".n2c"Then
Set TS=FSO.CreateTextFile(FSO.BuildPath(SaveFolder,FSO.GetBaseName(FName)+".html"),True)
TS.Write SrcA
TS.Close
End If
End Function
'---------------------------------------------------------
'Class
'---------------------------------------------------------
Class ConsoleObject
Private LogText
Sub Confilm(ByVal This)
Log This,"Confilm"
MsgBox This
End Sub
Sub Pass(ByVal This)
Log This," "
End Sub
Sub Debug(ByVal This)
If Init("debug")<>"" Then Log This,"Debug "
End Sub
Sub Err(ByVal This)
Log This,"Error "
MsgBox This
WScript.Quit
End Sub
Sub Warning(ByVal This)
Log This,"Waring "
MsgBox This
End Sub
Function Log(ByVal This,ByVal That)
This=CStr(Date)+" "+CStr(Time)+":"+That+":"+This
'LogText=LogText+Replace(This,vbCrLf,"")+VbCrLf
WScript.Echo This'+VbCrLf
End Function
End Class
Class ExtendStringObject
Function Read(ByVal FName)
If FSO.FileExists(FName)=True Then
Set TS = FSO.OpenTextFile(FName,ForReading)
ReadFile=TS.ReadAll
TS.Close
Set TS = Nothing
Else
ReadFile=""
End If
End Function
Function RegTest(ByVal This,ByVal That)
Reg.Pattern=That
RegTest=Reg.Test(This)
End Function
End Class
'---------------------------------------------------------
'下位関数
'---------------------------------------------------------
'Shuft,Unshift,Push,Pop
function Shift(ByRef This)
If Instr(This,vbCrLf) Then
Shift=Left(This,Instr(This,vbCrLf)-1)
This=Mid(This,Instr(This,vbCrLf)+2)
Else
Shift=This
This=""
End if
end function
Sub UnShift(ByRef This,ByVal Src)
This=Src+vbCrLf+This
End Sub
Sub Push(ByRef This,ByVal Src)
This=This+Src+vbCrLf
End Sub
Function Pop(ByRef This)
If Instr(This,vbCrLf)=0 Then
Pop=This
This=""
ElseIf Right(This,4)=vbCrLf+vbCrLf Then
Pop=""
This=Left(This,Len(This)-2)
Else
If Right(This,2)=vbCrLf Then This=Left(This,Len(This)-2)
If Instr(This,vbCrLf)Then
Pop=Mid(This,InstrRev(This,vbCrLf)+2)
This=Left(This,InstrRev(This,vbCrLf)-1)+vbCrLf
Else
Pop=This
This=""
End If
End If
End Function
Function TestShift(ByRef A)
Dim Tmp
Tmp=Shift(A)
UnShift A,Tmp
TestShift=Tmp
End Function
Function TestPop(ByRef A)
Dim Tmp
Tmp=Pop(A)
Push A,Tmp
TestPop=Tmp
End Function
Function WordCount(ByVal Src,ByVal Target)
WordCount=Len(Src)-Len(Replace(Src,Target,""))
End Function
'テンポラリストリーム関係
Sub TmpPush(ByVal A)
TmpStream=TmpStream+A+vbCrLf
End Sub
Sub TmpUnShift(ByVal A)
TmpStream=A+vbCrLf+TmpStream
End Sub
Function TmpRefresh
TmpRefresh=TmpStream
TmpStream=""
End Function
'MaxとMin
Function Max(ByVal A,ByVal B)
If A>B Then
Max=A
Else
Max=B
End If
End Function
Function Min(ByVal A,ByVal B)
If A<B Then
Max=A
Else
Max=B
End If
End Function
Function FileLastUpdate(ByVal FName)
Dim FSO,F
Set FSO =CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(FName)=True Then
Set F =FSO.GetFile(FName)
FileLastUpdate=F.DateLastModified
Set F =Nothing
Set FSO =Nothing
Else
FileLastUpdate=#01/01/1980#
End If
End Function
'ファイル操作関係
Function MovePath(ByVal A,ByVal B)
'下準備
Console.Debug "MovePath関数を開始"
Console.Debug "引数1="""+A+""""
Console.Debug "引数2="""+B+""""
Dim This,These
A=Replace(A,"/","\")
B=Replace(B,"/","\")
A=FSO.GetAbsolutePathName(A)
If Right(B,1)="\" Then B=Left(B,Len(B)-1)
'Bにドライブ名がある場合
If Mid(b,2)=":"Then
If lcase(Left(a,1))<>lcase(Left(b,1))Then
a=mid(b,2)+"\"
End If
b=mid(b,3)
End If
'Bがルートフォルダから始まる場合
If Left(b,1)="\" Then
b=Mid(b,2):a=left(a,2)+"\"
End If
'Bをサブフォルダ名単位で処理
These=Split(b,"\")
For Each This in These
If This="" Then
MsgBox( "パス名に不正な文字列'\\'が使われています。"+vbcrlf+ _
"対象:"+B)
Execute "!"
ElseIf Replace(This,".","")="" Then
This=Mid(This,2)
Do While This<>""
This=Mid(This,2)
If Len(a)=2 Then
MsgBox( "パスを結合した結果ルートフォルダを超えました。"+vbcrlf+ _
"対象1:"+A+vbcrlf+ _
"対象2:"+B)
Else
a=Left(a,InstrRev(a,"\")-1)
End If
Loop
Else
a=a+"\"+This
End If
Next
MovePath=FSO.GetAbsolutePathName(a)
Console.Debug "MovePath関数を終了"
Console.Debug "戻り値="""+A+""""
End Function
Function ReadFile(ByVal FName)
If FSO.FileExists(FName)=True Then
Set TS = FSO.OpenTextFile(FName,ForReading)
ReadFile=TS.ReadAll
TS.Close
Set TS = Nothing
Else
ReadFile=""
End If
End Function
'非汎用命令
Function Include(ByVal FName)
Set TS = FSO.OpenTextFile(FName,ForReading)
Include=TS.ReadAll
TS.Close
End Function
Function SpecialEVal(ByVal This)
call Execute(Init.Item("SpecialEVal"))
SpecialEVal=This
End Function
Function AttrConv(ByVal Title,ByVal This)
call Execute(Init.Item("AttrConv"))
AttrConv=This
End Function
default.n2sファイル |
'2004/08/20
debug=
group:head
<html><head>
<meta http-equiv="adalign" content="right"> <!-- FC2 -->
<link rel="stylesheet" type="text/css" href="../common/default.css">
<title>
[var,title]
</title>
</head>
<body>
<!-- ↓編集用※筆者のPC以外の環境では意味のないリンクです -->
<script type="text/vbscript">
<!--
if Instr("!"+document.cookie,"EDIT=1")>0 then
document.write "<p><a href=""[eval,Init("file.input")]"">ソースの編集</a></p>"
document.write "<p><a target=_blank href=""[eval,Left(Init("file.input"),InstrRev(Init("file.input"),"\"))]"">ソースフォルダを開く</a></p>"
document.write "<p><a target=_blank href=""[eval,Left(Init("file.output"),InstrRev(savefolder,"\"))+"index.html"]"">このフォルダのindex.htmlを開く</a></p>"
End If
-->
</script>
//
group:bottom
<div align="right" style="border:none;margin:1em;padding:0;">
<br>
<br>
<hr>
<a href="javascript:history.back(-1)">前のページに戻る</a><br>
<a href="..">1つ上のフォルダへ</a>
</div>
</body>
</html>
//
group:ommit
If Init.Item(TestPop(comNest)+".Tacitry")<>"False" Then
If Left(This,1)="★"Then
TmpPush "#h2"
TmpPush " "+Mid(This,2)
TmpPush "#close,h2"
ElseIf Left(This,1)="●"Then
TmpPush "#h3"
TmpPush " "+Mid(This,2)
TmpPush "#close,h3"
ElseIf Left(This,1)="◆"Then
TmpPush "#h4"
TmpPush " "+Mid(This,2)
TmpPush "#close,h4"
ElseIf Left(This,1)="▲"Then
TmpPush "#h5"
TmpPush " "+Mid(This,2)
TmpPush "#close,h5"
ElseIf Left(This,1)="・"Then
Do
TmpPush " "+Replace(Mid(This,2),"|","[<br>]")
This=Shift(SrcB)
Loop While Left(This,1)="・"
TmpUnShift "#ul"
TmpPush "#close,ul"
TmpPush This
ElseIf Left(This,1)="."Then
Do
TmpPush " "+Replace(Mid(This,2),"|","[<br>]")
This=Shift(SrcB)
Loop While Left(This,1)="."
TmpUnShift "#ol"
TmpPush "#close,ol"
TmpPush This
ElseIf InStr(This,":")<>0 Then
Dim MaxSplit
MaxSplit=0
Do
MaxSplit=Max(MaxSplit,WordCount(This,":"))
TmpPush This
This=Shift(SrcB)
Loop While Instr(This,":")
UnShift SrcB,This
That=TmpRefresh
Do While That<>""
This=Shift(That)
If Left(This,1)=":"Then This=" "+This
TmpPush Replace(This,":",chr(1))
' TmpPush replace(This+String(MaxSplit-WordCount(This,":"),": "),":",chr(1))
Loop
TmpUnShift "#easytable,"+chr(1)+","+CStr(MaxSplit)
TmpPush "#close,easytable"
That=TmpRefresh
TmpPush That
Else
If Instr(ComNest,"p"+vbCrLf)=0 Then
TmpPush "#p"
TmpPush This
End If
End If
End If
//
group:SpecialEVal
Dim That,BefThis
This=Replace(This,"\[",chr(3))
This=Replace(This,"\]",chr(4))
'
' ReDim ComList(9)
Reg.Pattern="(\[.*?)( )(.*?\])"
Do
BefThis=This
This=Reg.Replace(BefThis,"$1 $3")
Loop While This<>BefThis
BefThis=""
'メインループ
Do While This<>BefThis
BefThis=This
'Num
If Instr(This,"[0]") Then This=Replace(This,"[0]",ComList(0))
If Instr(This,"[1]") Then This=Replace(This,"[1]",ComList(1))
If Instr(This,"[2]") Then This=Replace(This,"[2]",ComList(2))
If Instr(This,"[3]") Then This=Replace(This,"[3]",ComList(3))
If Instr(This,"[4]") Then This=Replace(This,"[4]",ComList(4))
'[img,ファイル名]形式
Reg.Pattern="\[img,([^\[]+?)\]"
This=Reg.Replace(This,"<img src=""$1"">")
'[link,テスト,http://hogehoge]形式 ※別窓を付ける
Reg.Pattern="\[link,([^\[]+?),http://([^\[]+?)\]"
' This=Reg.Replace(This,"<a href=""http://$2"">$1</a>(<a target=_blank href=""http://$2"" style=""font-weight:bold;"">別窓</a>)")
'[link,テスト,hogehoge]形式 ※別窓を付けない
Reg.Pattern="\[link,([^\[]+?),([^\[]+?)\]"
This=Reg.Replace(This,"<a "+replace("href=""$2"">$1</a>"," ","%20"))
'[http://hogehoge]形式
Reg.Pattern="\[(http://[^\[]+?)\]"
This=Reg.Replace(This,"<a "+replace("href=""$1"" target=""_blank"">$1</a>"," ","%20"))
'[a:\hogehoge]形式
Reg.Pattern="\[([a-zA-Z]:\\[^\[]+?)\]"
This=Reg.Replace(This,"<a "+replace("href=""$1"" target=""_blank"">$1</a>"," ","%20"))
'[..\hogehoge]形式
Reg.Pattern="\[(\.[^\[]+?)\]"
This=Reg.Replace(This,"<a "+replace("href=""$1"" target=""_blank"">$1</a>"," ","%20"))
'[\hogehoge]形式
Reg.Pattern="\[(\\[^\[]+?)\]"
This=Reg.Replace(This,"<a "+replace("href=""$1"" target=""_blank"">$1</a>"," ","%20"))
'Thums
Reg.Pattern="\[thums,([^\[]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
For Each SubMatch In Match.SubMatches
This=Replace(This,"[thums,"+SubMatch+"]",MakeThums(SubMatch,FName,false))
Next
Next
'inlineThums
Reg.Pattern="\[inlinethums,([^\[]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
For Each SubMatch In Match.SubMatches
This=Replace(This,"[inlinethums,"+SubMatch+"]",MakeThums(SubMatch,FName,true))
Next
Next
'Attr
Reg.Pattern="\[page,([^\[]+?,[^\[]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
For Each SubMatch In Match.SubMatches
That=SubMatch
User.Item(Left(That,Instr(That,",")-1) + _
".attr")= Mid(That,Instr(That,",")+1)
This=Replace(This,Match.Value,That)
Next
Next
'TempAttr 形式→[temp,<var>,<value>]
Reg.Pattern="\[temp,([^\[]+?,[^\[]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
For Each SubMatch In Match.SubMatches
That=SubMatch
User.Item(Left(That,Instr(That,",")-1) + _
".temp")= Mid(That,Instr(That,",")+1)
Next
Next
Reg.Pattern="(.*?)("+Replace(Replace(Reg.Pattern,"(",""),")","")+")(.*?)"
This=Reg.Replace(This,"$1$3")
'タグ処理
Reg.Pattern="\[(\<[^\[]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
For Each SubMatch In Match.SubMatches
That=SubMatch
That=Replace(That,"<","<")
That=Replace(That,">",">")
This=Replace(This,Match.Value,That)
Next
Next
'User.Item(x)
Reg.Pattern="\[var,([^\[<]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
This=Replace(This,Match.Value, User.Item(Match.SubMatches(0)),1,1)
Next
'EVal
Reg.Pattern="\[eval,([^\[<]+?)\]"
Set Matches=Reg.Execute(This)
For Each Match In Matches
This=Replace(This,Match.Value, EVal(Match.SubMatches(0)),1,1)
Next
loop
This=Replace(This,chr(3),"[")
This=Replace(This,chr(4),"]")
This=Replace(This,"<gray>","<span class=pale>")
This=Replace(This,"</gray>","</span>")
This=Replace(This,"<pale>","<span class=pale>")
This=Replace(This,"</pale>","</span>")
function MakeThums(GName,FName,inlineFlag)
console.Pass GName+"のサムネイルを作成中..."
Dim d,FoG,FoT,newWidth,newHeight,ThumsFolder
Dim FoO,jcode
FoG=MovePath(FName,GName)
FoT=FSO.BuildPath(Init("thums.folder"),FSO.GetFileName(FoG))
FoT=MovePath(FSO.GetParentFolderName(FoG), FoT)
FoO=Replace(Replace(Replace(Replace(Fog,"\","_"),":","_"),".","_"),"/","_")
If Init("thums.height")<>0 Then newHeight=Init("thums.height")
If Init("thums.width")<>0 Then newWidth =Init("thums.width")
If FileLastUpdate(FoG)>FileLastUpDate(FoT)Then
Set d = CreateObject("Doodle2.MyCanvas")
Call d.NewCanvas(1,1)
Call d.LoadFromFile(FoG)
If newHeight=0 and newWidth<>0 Then
newHeight=d.Height*(newWidth/d.Width)
ElseIf newHeight<>0 and newWidth=0 Then
newWidth=d.Width*(newHeight/d.Height)
End if
d.Stretch newWidth,newHeight
Call d.SaveToFile(FoT)
End If
If newHeight=0 and NewWidth=0 Then
newHeight=d.Height/4
newWidth=d.Width/4
End If
If inlineFlag=True Then
jcode="if(document.all."
jcode=jcode+FoO
jcode=jcode+".height=="
jcode=jcode+cstr(newHeight)
jcode=jcode+"){"
jcode=jcode+"document.all."+FoO
jcode=jcode+".style.width="+chr(39)
jcode=jcode+"700px"
jcode=jcode+chr(39)+";"
' jcode=jcode+"if(document.all."+FoO+".width>700){"
' jcode=jcode+"document.all."+FoO
' jcode=jcode+".style.width="+chr(39)
' jcode=jcode+"700px"
' jcode=jcode+chr(39)+";}"
jcode=jcode+"document.all."+FoO
jcode=jcode+".style.height="+chr(39)
jcode=jcode+"auto"
jcode=jcode+chr(39)+";"
jcode=jcode+"document.all."+FoO
jcode=jcode+".src="+chr(39)
jcode=jcode+Replace(FoG,"\","/")
jcode=jcode+chr(39)+";"
jcode=jcode+"}else{"
jcode=jcode+"document.all."+FoO
jcode=jcode+".style.width="+chr(39)
jcode=jcode+"auto"
jcode=jcode+chr(39)+";"
jcode=jcode+"document.all."+FoO
jcode=jcode+".style.height="+chr(39)
jcode=jcode+CStr(newHeight)+"px"
jcode=jcode+chr(39)+";"
jcode=jcode+"document.all."+FoO
jcode=jcode+".src="+chr(39)
jcode=jcode+Replace(FoT,"\","/")
jcode=jcode+chr(39)+";"
jcode=jcode+"}"
MakeThums="<img src="""+FoT+""" id="""+FoO+""" border=2 onclick=""JavaScript:"+jcode+""" style=height:"+newHeight+"px; alt="""+FoG+""">"
Else
MakeThums="<a href="""+FoG+"""><img src="""+FoT+"""></a>"
End If
End Function
//
group:AttrConv
Select Case Title
Case "easytable"
End Select
//
'--------------------------------------------
html.Open=<!-- -->
html.Close=<!-- -->
html.Process=:
html.Natural=True
html.Tacitry=False
natural.Open=<!-- -->
natural.Close=
natural.BeforeClose=
natural.Tacitry=False
natural.Natural=True
group:natural.Process
This=Replace(This,chr(1),""):
This=Replace(This,"&","&"):
This=Replace(This,chr(9)," "):
This=Replace(This," "," "):
This=Replace(This,"#","#"):
This=Replace(This,"<","<"):
This=Replace(This,">",">"):
This=Replace(This,"[","["):
This=Replace(This,"\","\"):
This=Replace(This,"]","]"):
This=This+"<br>"
//
comment.Open=<!--
comment.Close=-->
comment.Process=This=""
comment.Tacitry=False
p.Open=<div class=p @ >
p.Close=</div>
p.Process=This=This+"<br>"
center.Open=<center>
center.Close=</center>
code.Open=<p class="border" @ ><code>
code.Close=</code></p>
code.Process=This=This+"<br>"
code.BeforeClose=;p;
code.Tacitry=False
quote.Open=<!-- <div class="border" @ > --><blockquote>
quote.Close=<!-- </div> --></blockquote>
quote.Process=This=This+"<br>"
quote.AutoUp=p
quote.Tacitry=False
h1.Open=<h1 @ >
h1.Close=</h1>
h1.Process=:
h1.Tacitry=False
h1.BeforeClose=;h1;h2;h3;h4;h5;h6;p;ol;ul;
h2.Open=<h2 @ >
h2.Close=</h2>
h2.Process=:
h2.Tacitry=False
h2.BeforeClose=;h1;h2;h3;h4;h5;h6;p;ol;ul;
h3.Open=<h3 @ >
h3.Close=</h3>
h3.Process=:
h3.Tacitry=False
h3.BeforeClose=;h1;h2;h3;h4;h5;h6;p;ol;ul;
'ちょっと強引…
h4.Open=<table border=0><tr><td><h4 @ >
h4.Close=</h4></tr></td></table>
h4.Process=:
h4.Tacitry=False
h4.BeforeClose=;h1;h2;h3;h4;h5;h6;p;ol;ul;
'ちょっと強引…
h5.Open=<table border=0><tr><td><h5 @ >
h5.Close=</h5></tr></td></table>
h5.Process=:
h5.Tacitry=False
h5.BeforeClose=;h1;h2;h3;h4;h5;h6;ol;ul;
h5.AutoUp=p
autop.Open=<!-- -->
autop.Close=
autop.AutoUp=p
autop.Process=:
autop.Tacitry=False
easytable.Open=<table class="easytable" @ >
easytable.Close=</table>
easytable.AutoUp=p
easytable.Tacitry=False
group:easytable.Process
' This=This+String(ComList(2)-wordcount(This,ComList(1)),ComList(1))
Do While Right(This,1)=ComList(1) 'And This<>""
This=Left(This,Len(This)-1)
Loop
Do While Instr("@!",Left(This,1))
User.Item("easytable.temp")=User.Item("easytable.temp")+Left(This,1)
This=Mid(This,2)
Loop
This="<tr><td>"+This+"</td></tr>"
This=Replace(This,ComList(1),"</td><td>")
This=Replace(This,"<td></td>","<td> </td>")
This=Replace(This,"\|","|")
This=Replace(This,"|","<br>")
Reg.Pattern="<td>\{(.+?)\}(.+?)</td>"
This=Reg.Replace(This,"<td $1 >$2</td>")
Reg.Pattern="<td([^>]*?) (.*?)>"
This=Reg.Replace(This,"<td $1 $2>")
Reg.Pattern="(<td .*?)x=(\d+?)(>| .*?>)"
This=Reg.Replace(This,"$1 colspan=$2 $3")
Reg.Pattern="(<td .*?)y=(\d+?)(>| .*?>)"
This=Reg.Replace(This,"$1 rowspan=$2 $3")
If Instr(User.Item("easytable.temp"),"@")Then
This=Replace(This,"<td" ,"<th valign=middle align=left",1,1)
This=Replace(This,"</td>","</th>",1,1)
End If
If Instr(User.Item("easytable.temp"),"!")Then
This=Replace(This,"<td" ,"<th valign=middle" )
This=Replace(This,"</td>","</th>")
User.Item("easytable.temp")= _
Replace(User.Item("easytable.temp"),"!","")
End If
Reg.Pattern="<td (.*?)th(>|.*?>)"
This=Reg.Replace(This,"<th $1 $2")
//
'ちょっと強引…
ol.Open=<table border=0><tr><td><ol @ >
ol.Close=</ol></td></tr></table>
ol.Process=This="<li>"+This+"</li>"
ol.Tacitry=False
ol.BeforeClose=;h1;h2;h3;h4;h5;h6;ol;ul;
ol.AutoUp=p
ul.Open=<table border=0><tr><td><ul @ >
ul.Close=</ul></td></tr></table>
ul.Process=This="<li>"+This+"</li>"
ul.Tacitry=False
ul.BeforeClose=;h1;h2;h3;h4;h5;h6;ol;ul;
ul.AutoUp=p
divbox.Open=<div class="divbox" @ >
divbox.Close=</div>
divbox.Process=:
divbox.Tacitry=True
divbox.BeforeClose=;p;
divbox.TooClose=;p;
divbox.AutoUp=
eof.Open=<!-- -->
eof.Process=:
'--------------------------------------
group:macro.right
#html
<div class="borde:none;margin:0em;padding:0em;" align="right">[1]</div>
#close,html
//
group:macro.toptitle
#let,title,[1]
#h1
[1]
#close,h1
#html
<div align="right" style="border:none;margin:0.5em 1em 2em 1em;padding:0;">
<a href="..">1つ上のフォルダへ</a><br>
<a href="javascript:history.back(-1)">前のページに戻る</a>
</div>
#close,html
//
group:macro.rem
#comment
#close,comment
//
group:macro.link.open
#autop
#html
<table class=easytable>
#close,html
#close,autop
//
group:macro.link.close
#html
</table>
#close,html
//
group:macro.link
#html
<tr>
<td><a href="[3]" target="_blank">●</a></td>
<td align=center>
<a href="[3]">
<span align=center valign=middle style = "width:198px;height:38px;
border:2px solid;border-color:#eef #000 #000 #eef; margin:0;
padding:10px;cursor: pointer;background:#def;" >
[1]
</span></a>
</td>
<td><b>[1]</b><br>[2]</td>
</tr>
#close,html
//
group:macro.banner
#html
<tr>
<td><a href="[3]" target="_blank">●</a></td>
<td align=center><a href="[3]"><img src="[4]" alt="[1]" border=0></a></td>
<td><b>[1]</b><br>[2]</td>
</tr>
#close,html
//
group:macro.include.unchange
#natural
#include,[1],This=chr(1)+Replace(This,vbCrLf,vbCrLf+chr(1))
#close,natural
//
group:macro.box
#html
<p align=center valign=middle style = "width:25em;height:5em;
border:2px solid;border-color:#000 #eee #eee #000;
padding:10px;background:#eee;margin:1em 2em;top:3em;">
※将来ここに「[1]」を載せる予定
</p>
#close,html
//
group:macro.inline.table
#let,easytable.temp,style="display:inline;vertical-align:text-top;" valign=top
//
group:macro.inline.close
#html
<br>
#close,html
//
group:macro.quote2
#html
<blockquote>
[1]
</blockquote>
#close,html
//
macro.ul.free=#let,ul.temp,style=border:none;background:transparent;margin-top:0;margin-bottom:0;
macro.name=[<a name=[1]></a>]