" .inul := \fcode(\fleft(\m(tmp),1)) # And remember } } } else if match "\m(tmp)" "{[1-9],[1-9][0-9]}.\32*" { # Ordered list? .number = 1 if not \m(inol) { putout "
" .inol = 1 } } } else if \m(inul) { # Line does not start with space. putout "
" # If in unordered list close it. putout "

" putout .inul := 0 } else if \m(inol) { putout "" # If in ordered list close it. putout "

" putout .inol := 0 } if \m(bullet) { # This line has bullet .out :=

• \s(tmp[3]) } else if \m(number) { # This line has a number .\%9 := \findex(.\32,\m(tmp)) .out :=
• \s(tmp[\%9+2]) } else if \m(inul) { # Continuation line of list item .out := \m(tmp) } else if \m(inol) { # Ditto .out := \m(tmp) } else if ( > \flen(\m(tmp)) 8 && == 0 \fverify(-,\m(tmp)) ) { # Rule .out = "
" } putout "\m(out)" } def dump { # For debugging echo DUMP \%1: echo PREV=[\m(prev)] echo LINE=[\m(line)] echo NEXT=[\m(next)] echo n=\%n } # Begin actions putout {} putout "" while not def line { # Get first nonblank line getline if fail break } getline # Get line after first nonblank line if not def \%2 { # No Title given if ( def prev && not def line ) { # If top line followed by blank line .\%2 := \m(prev) # use it as the title getline # and read another line } else { # Otherwise .\%2 = "Untitled" # use "Untitled" putback # and put this line back } } else { # Title given on command line putback # Save this line for next time } # Write rest of prolog... putout "\%2" putout {} putout "" putout {} putout "

### \%2

" putout .first = 1 # Start loop with first = 1 while true { # Loop for each line in file. if not \m(first) { # Get next line if not first trip. getline if fail break } .first = 0 if ( > \%n 1 && not \flen(\m(line)) ) { # Blank line if ( == \m(state) 2 ) continue # Ignore extra ones if ( \m(inul) || \m(inol) ) { # Watch out for end of list if not eq "\fleft(\m(next),1)" "\32" continue } putout # Emit paragraph separator. putout "

" putout .state = 2 # State becomes "between paragraphs" continue } else if ( eq "\fleft(\m(line),1)" "\32" ) { # Line is indented .\%8 := \fcode(\m(prev)) # Check previous and next lines if not def \%8 .\%8 = 32 .\%9 := \fcode(\m(next)) if not def \%9 .\%9 = 32 if ( > \%8 32 && > \%9 32 ) { # Previous and next line not indented putout # So this is a new paragraph putout "

" # but not separated by blank lines. putout } } .state = 1 # State become "in paragraph" if \%n putline # If we have a line write it out } if > \%n 0 { # Last lookahead line (if any) putline putout putout "

" } putout "

" # Write out the epilog putout "
" putout "\m(oname): \v(date) \v(time)" putout "
" putout "" fclose \%i # And close the files fclose \%o exit