; Removes empty delimiter-pairs from buffer even when they are ; nested. Returns the number of empties deleted. remove_empty: 0 -> x mark { r toend ; start at the beginning of the file while( !isend ) { f to isopen ; find an open delimiter if (c isclose) ; if followed by a close {++x f del r del r c } ; inc count and delete both } } x int TypeStyleChar ; holds the open tag to search for ; Q4 holds the open string ; Q7 holds the close string ; Converts one delimiter-pair to HTML tags html_one: int skip 0 -> skip if ( current != TypeStyleChar ) { return 1 } ; wrong delim? set themark ; so we can return at end of function del ; remove the delimiter insert Q4 ; insert open string f while( !isend ) { ; search forward to end-delim or para current case { '^J' { insert Q7 ; close string break ; break loop (not case) }, '^N' if( skip > 0 ) { --skip ; skip close nested inside our pair c } else { del insert Q7 ; close string break ; break loop (not case) }, $ if( isopen ) { ++skip ; skip delim nested inside our pair } c } } to themark ; Converts all delimiter-pairs to HTML tags by calling html_one html_all: r toend ; start at beginning f while( TypeStyleChar csearch ) html_one ; replace one pair at a time HiliteChar : set themark 1->select c draw 0->select ; If a line is centered with springs ^W this will ask if you want ; to center the line and then put in
ing tags. spring2html: '^F' -> int SearchChar Q4 "
" Q7 "
" r toend while( SearchChar csearch ) { HiliteChar ask "\nCenter this line?" ? { draw r del insert Q4 while( !isend ) { current case { SearchChar { del insert Q7 break }, '^J' { insert Q7 break }, $ f c } } } } ; This trims any trailing white space before paragraph marks trimwhite: mark { r toend while( f '^J' csearch ) { r erase to !iswhite f c } } ; Converts new paragraphs to

tags par2html: r toend while( f '^J' csearch ) { ; search to para mark f c if( isend ) break; ; don't mark empty para at end if( !inruler ) { if( ispara ) { f to !ispara ; in a string of para marks r c ; put the tag in before the last one insert "

" f c } else { insert "

" '^J' insert } } } ; Wraps lines by inserting hard returns at the right ruler margin ; then removes all of the sprint rulers. sprint2ascii: r toend while( !isend ) { draw toeol '^J' -> current } r toend f to ( inruler ) while( inruler ) { deleteline to inruler } ; Replaces " with balanced quote pairs `` and '' -- based on an @tct() change_quotes: 1->GlobalReplace 2->SearchOpt r toend Q2 " \"" Q3 " ``" DoReplace r toend Q2 "\" " Q3 "'' " DoReplace ; *** This is the macro you actually call after the file has been compiled. ; Alt-U M E html html: while ( remove_empty ) 0 spring2html '^E' -> TypeStyleChar Q4 "" Q7 "" html_all '^B' -> TypeStyleChar Q4 "" Q7 "" html_all '^U' -> TypeStyleChar Q4 "" Q7 "" html_all '^W' -> TypeStyleChar html_all '^X' -> TypeStyleChar Q4 "" Q7 "" html_all '^S' -> TypeStyleChar Q4 "" Q7 "" html_all '^Q' -> TypeStyleChar Q4 "" Q7 "" html_all change_quotes trimwhite par2html sprint2ascii set fname fchange "%.HTM" Save ; For the future for removing tags ;unhtml: ; SearchOpt | 2 -> SearchOpt ; SearchOpt ^ 2 -> SearchOpt