(defun tr ()
  (interactive)
  (goto-char (point-min))
  (while (search-forward-regexp " *<\\(p\\|br\\)> *<new>" (point-max) t)
    (replace-match "<new>"))

  (goto-char (point-min))
  (while (search-forward-regexp "^\\(<new>.+\\) +\\$" (point-max) t)
    (replace-match "\\1\n")
    (if (looking-at " *<p> *") (replace-match ""))
    (let ((start (point)))
      (if (search-forward-regexp "^<new>" (point-max) t)
	  (progn
	    (forward-line -1)
	    (while (> (point) start)
	      (progn (delete-char -1) (beginning-of-line)))
	  )
  )))
  (goto-char (point-min))
  (while (search-forward-regexp "\\(</?\\)tt>" (point-max) t)
    (replace-match "\\1b>"))
  (goto-char (point-min))
  (while (search-forward-regexp
	  " *\\(</?\\)\\(p\\|li\\|ol\\|ul\\|br\\)> *" (point-max) t)
    (replace-match "\\1\\2>"))
  (goto-char (point-min))
  (while (search-forward-regexp "^\\( +\\|<p>\\|<br>\\)+" (point-max) t)
    (replace-match ""))
)