#!/bin/sh
: ; exec klone $0 "$@"
; The above line finds the klone executable in the $PATH

(setq troff-command (regcomp "^[.]"))
(setq no-caret (regcomp "^(.*)[\\][\\^](.*)$"))
(setq no-font (regcomp "^(.*)[\\]f[A-Z](.*)$"))
(setq lines (list))

(catch 'EOF
  (while t
    (setq line (read-line))
    (if
      (regexec troff-command line)
      ()

      (= "" line)
      (progn
	(dolist (l lines)
	  (write-line l)
	)
	(setq lines (list))
      )

      (progn
	(while (regexec no-caret line)
	  (setq line (regsub no-caret "\\1\\2"))
	)
	(while (regexec no-font line)
	  (setq line (regsub no-font "\\1\\2"))
	)	
	(put lines -1 line)
      )
))))
