// proofreading
disabledraw ;
$Del = "{" ;
$Ins = "|" ;
$Rem = "*" ;
$End = "}" ;
call Lib "toXHTML_preprocess" ;
call proofreading ;
call Lib "toXHTML_postprocess" ;
replaceallfast "(lib.mac)", "(proofread.mac)" ;
call toHTML ;
saveas filename2 + ".html" ;
gofiletop ;
endmacro ;
// -- sub --
proofreading:
	gofiletop ;
	insert "\n" ;
	replaceallfast $Del, "<_del " ;
	replaceallfast $Ins, "/><_ins " ;
	replaceallfast $Rem, "/><_rem " ;
	replaceallfast $End, "/>" ;
	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	"",  ""+$Del ;
	replaceallfast "", $End+"" ;
	replaceallfast "", $Ins+"" ;
	replaceallfast "", $Rem+"" ;
	// XML 要素を  に置き換え。
	// NC4.x 対策(泣き):   も追加。
	replaceallfast "<\\f(pr|rem|ins|del)\\f>", "", regular ;
	replaceallfast "(pr|rem|ins|del)>", "", regular ;
	call blockToInline ;
return ;
//
blockToInline:	//  中の "
" を "
 
" に置き換え
	gofiletop ;
	insert "\n" ;
	$$PinSpan = "|
[ |\\t|\\n]*" ;
	gofiletop ;
	searchdown "" ;
				right ;
			cut ;
			insert "
 
" ;
			searchdown $$PinSpan, regular ;
		}
		searchdown "