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

proofread.txt

// proofreading

disabledraw ;

$Del = "{" ;
$Ins = "|" ;
$Rem = "*" ;
$End = "}" ;

call Lib "toXHTML_preprocess" ;
call proofreading ;
call Lib "toXHTML_postprocess" ;
replaceallfast "(t2x.mac)", "(proofread.mac)" ;
call toHTML ;
saveas filename2 + ".html" ;

gofiletop ;
endmacro ;

// -- sub --

proofreading:
gofiletop ;
insert "\n" ;

replaceallfast $Del, "<pr><_del " ;
replaceallfast $Ins, "/><_ins " ;
replaceallfast $Rem, "/><_rem " ;
replaceallfast $End, "/></pr>" ;

replaceallfast "<_(del|ins|rem)[ |\\t|\\n]+/>", "", regular ; // 空タグ削除

// 入れ子無しで一行に収まっている場合
replaceallfast "<_\\f(del|ins|rem)\\f \\f[^>]+\\f/>", "<\\1>\\3</\\1>", regular ;

// 複数行に分かれている/入れ子になっている場合
call replaceTmpTags ;

//

gofiletop ;
deleteline ;
return ;

replaceTmpTags:
##nest = 0 ;
$$tag[##nest] = "" ;

$$tags = "<_(del|ins|rem)|/>" ;

gofiletop ;
searchdown $$tags, regular ;
while (result) {
escape ;

if (code == '/') {
insert "<" ;
right ;
insert $$tag[##nest] ;
##nest = ##nest-1 ;
}else{
##nest = ##nest+1 ;
right ; delete ;
if (code == 'd') {$$tag[##nest] = "del" ;}
if (code == 'i') {$$tag[##nest] = "ins" ;}
if (code == 'r') {$$tag[##nest] = "rem" ;}
replacedown " ", ">" ;
}

searchdown $$tags, regular ;
}
return ;

//

toHTML:
replaceallfast "<pr>", "<pr>"+$Del ;
replaceallfast "</pr>", $End+"</pr>" ;
replaceallfast "<ins>", $Ins+"<ins>" ;
replaceallfast "<rem>", $Rem+"<rem>" ;

// XML 要素を <span> に置き換え。
// NC4.x 対策(泣き): <ins> <del> も追加。

replaceallfast "<\\f(pr|rem|ins|del)\\f>", "<span class=\"\\1\">", regular ;
replaceallfast "</(pr|rem|ins|del)>", "</span>", regular ;

call blockToInline ;
return ;

//

blockToInline: // <span> 中の "</p><p>" を "<br /> <br />" に置き換え
gofiletop ;
insert "\n" ;

$$PinSpan = "</span[ |\\t|\\n]*>|</p[ |\\t|\\n]*>[ |\\t|\\n]*<p[ |\\t|\\n]*>" ;

gofiletop ;
searchdown "<span" ;
while (result) {
searchdown $$PinSpan, regular ;
while (result) {
escape ; right ; right ;
if (code == 's') {
break ;
}

left ; left ;
beginsel ;
searchdown "<p" ;
searchdown ">" ;
right ;
cut ;

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

searchdown $$PinSpan, regular ;
}
searchdown "<span" ;
}

gofiletop ;
deleteline ;
return ;

//

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 ;


戻る
トップページへ戻る