Notice : 内容無保証。禁無断転載。リンク不自由。

lib.txt

disabledraw ;
call insertLastModifiedDateTime ;
endmacro;

//

lib:
return ;

//

HTMLtoXHTML:
gofiletop ;
insert "\n" ;

call toSmallLetterTag ;
call addEndTag ;
call toStandardTag ;
call addNoIndent ;

gofiletop ;
deleteline ;
return ;

toSmallLetterTag:
$$tagStart = "<[^!?]" ;
##tagEnd = '>' ;

gofiletop ;
searchdown $$tagStart, regular ;
while (result) {
escape ; right ;
while (code != ##tagEnd) {
if (code == '"') {
searchdown "\"" ;
escape ;
}

if (('A' <= code) && (code <= 'Z')) {
overwrite char(code -'A' + 'a') ;
}else{
right ;
}
}

searchdown $$tagStart, regular ;
}
return ;

addEndTag:
$$tags = "<(br|hr|img|link|meta)[^a-z]" ;

gofiletop ;
searchdown $$tags, regular ;
while (result) {
searchdown ">", regular ;
escape ; left ;
if (code != '/') {
right ; insert " /" ;
}

searchdown $$tags, regular ;
}
return ;

toStandardTag:
gofiletop ;
$$tags = "<c[^a-z]" ;

searchdown $$tags, regular ;
while (result) {
escape ; right ;
insert "span class=\"" ;
searchdown "[^a-z]", regular ;
escape ;
insert "\">" ;
left ;
replacedown "/>", "</span>" ;
searchdown $$tags, regular ;
}
return ;

addNoIndent:
gofiletop ;

replaceallfast "<div\\f[ |\\t|\\n]*\\f>", "<div class=\"noindent\"\\1>", regular
return ;

//

toXHTML_preprocess:
call convEscChars ;
call delBlankLines ;
return ;

toXHTML_postprocess:
call makeBody_p ;
call insertHeader ;
call insertFooter ;

replaceallfast "<PorPRE>", "<p>", regular ;
replaceallfast "</PorPRE>", "</p>", regular ;
return ;

toXHTML:
call convEscChars ;
call delBlankLines ;
call makeBody_br ;
call insertHeader ;
call insertFooter ;

replaceallfast "<PorPRE>", "<p>", regular ;
replaceallfast "</PorPRE>", "</p>", regular ;
return ;

toPRE_XHTML:
call insertHeader ;
call insertFooter ;

replaceallfast "<PorPRE>", "<pre>", regular ;
replaceallfast "</PorPRE>", "</pre>", regular ;
return ;

//

//

convEscChars:
replaceallfast "&", "&amp;", regular ;
replaceallfast "\"","&quot;",regular ;
replaceallfast "<", "&lt;", regular ;
replaceallfast ">", "&gt;", regular ;
return ;

//

delBlankLines: // 2行以上続いている空行を1行に。
gofiletop ;
insert "\n\n" ;

gofileend ;
insert "\n" ;

replaceallfast "\\n\\n[\\n]+", "\\n\\n", regular ;
while (result) {
replaceallfast "\\n\\n[\\n]+", "\\n\\n", regular ;
}

gofileend ;
up ;
deleteline ;

gofiletop ;
deleteline ;
deleteline ;
return ;

//

makeBody_p:
replaceallfast "\\n\\n", "</p><c /><p>", regular ; // 空行をパラグラフの終了&開始に。
replaceallfast "\\n", "<br\\n/>", regular ; // 元の行端を保存。(工夫の余地あり)
replaceallfast "><c /><", "\\n><", regular ; // ソースを見やすくするためにパラグラフの区切りで改行
return ;

makeBody_br:
replaceallfast "\\n\\n", "<br /><c /><br />", regular ; // 空行を改行2つに。(1)
replaceallfast "\\n", "<br\\n/>", regular ; // 元の行端を保存。(工夫の余地あり)
replaceallfast " /><c /><br ", "\\n/> <br\\n", regular ;// 空行を改行2つに。(2)
return ;

//

insertHeader:
call datetime ;
$$datetime = $$return ;

gofiletop ;

insert "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>\n" ;
insert "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n\n" ;

insert "<html\n" ;
insert " xmlns=\"http://www.w3.org/1999/xhtml\"\n" ;
insert " xml:lang=\"ja\" lang=\"ja\" dir=\"ltr\"\n" ;
insert ">\n\n" ;

insert "<head>\n" ;
insert " <title xml:lang=\"en\" lang=\"en\">" + basename2 + "</title>\n" ;
insert " <!-- base target=\"_top\" -->\n\n" ;

insert " <meta name=\"robots\" content=\"noindex,nofollow\" />\n" ;
insert " <meta name=\"author\" content=\"Sagara Takuya (t2x.mac)\" />\n" ;
insert " <meta name=\"copyright\" content=\"&copy; " + $$datetime + " Sagara Takuya\" />\n\n" ;

insert " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\" />\n" ;
insert " <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n" ;
insert " <meta http-equiv=\"Last-Modified\" content=\"" + $$datetime + "\" />\n\n" ;

insert " <link rel=\"stylesheet\" type=\"text/css\" href=\"../ra.css\" /><!-- 環境依存 -->\n" ;
insert " <style type=\"text/css\">p {text-indent:0em;color:#000;/*white-space:pre;*/}</style>\n" ;
insert " <link rev=\"made\" title=\"Sagara Takuya\" href=\"mailto:sagara@green.an.egg.or.jp\" />\n" ;
insert "</head>\n\n" ;

insert "<body>\n\n" ;

insert "<div id=\"notice\"><b><a href=\"../index.html#top\">Notice</a></b> : 内容無保証。禁無断転載。リンク不自由。</div>\n\n" ;

insert "<hr />\n\n" ;

insert "<div id=\"header\"></div>\n\n" ;

insert "<div id=\"top\"><a name=\"top\"></a></div>\n\n" ;

insert "<h2>" + basename + "</h2>\n\n" ;

insert "<div class=\"pre\"><PorPRE>" ;
return ;

//

insertFooter:
gofileend ;
insert "</PorPRE></div>\n\n" ;

insert "<hr />\n\n" ;

insert "<div><!-- 環境依存ブロック --><c\n" ;
insert " /><a href=\"index.html#top\">戻る</a><br\n" ;
insert " /><a href=\"../index.html#top\">トップページへ戻る</a><c\n" ;
insert "/></div>\n\n" ;

insert "</body>\n\n" ;

insert "</html>\n" ;
return ;

//

insertLastModifiedDateTime:
call datetime ;
$$datetime = $$return ;

gofiletop ;

searchdown "<meta http-equiv=\"Last-Modified\"", regular ;
if (result) {
searchdown "content" ;
wordright ;
deleteafter ;
insert $$datetime + "\" />" ;

searchdown "today?" ;
if (result) {
wordright ;
deleteword ;

insert $$datetime ;
searchup "today?" ;
wordright ;
deleteword ;
delete ; right ; right ;
delete ; right ; right ;
delete ; right ; right ;
delete ; right ; right ;
deleteword ; deleteword ; deleteword ; deleteword ; deleteword ; deleteword ;
}

return ;
}

searchdown "<meta http-equiv=\"Content-Style-Type\"", regular ;
if (result) {
down ;
insert " <meta http-equiv=\"Last-Modified\" content=\"" + $$datetime + "\" />\n" ;
return ;
}

searchdown "<head", regular ;
if (result) {
down ;
insert " <meta http-equiv=\"Last-Modified\" content=\"" + $$datetime + "\" />\n\n" ;
}
return ;

// [ISO8601][DATETIME] : YYYY-MM-DDThh:mm:ssTZD

datetime:
$$TZD = $$1 ;
if ($$TZD == "") {
$$TZD = "+09:00" ; // 日本標準時をデフォルトとする
}

$$datetime = year + "-" + month + "-" + day + "T" + time + $$TZD ;
return $$datetime ;

//

Lib:
$$target = filename2 ;
$$lib = macrodir + "\\lib.mac" ;

if (findhidemaru($$lib) == -1) {
openfile $$lib ;
}

setactivehidemaru findhidemaru($$lib) ;
gofiletop ;
down ;
deleteline ;
insert "call " + $$1 + " ;\n" ;
save ;

setactivehidemaru findhidemaru($$target) ;
closehidemaru findhidemaru($$lib) ;

execmacro "lib.mac" ;
disabledraw ;
return ;


戻る
トップページへ戻る