+(defconst elpher-ansi-regex "\x1b\\[[^m]*m"
+ "Wildly incomplete regexp used to strip out some troublesome ANSI escape sequences.")
+
+(defun elpher-strip-ansi (string)
+ "Strip ANSI escape codes from STRING."
+ (with-temp-buffer
+ (insert string)
+ (goto-char (point-min))
+ (while (re-search-forward elpher-ansi-regex nil t)
+ (delete-region (match-beginning 0) (match-end 0)))
+ (buffer-string)))
+
+
+(defun elpher-process-text-for-display (string)
+ "Perform any desired processing of text prior to display.
+Currently includes buttonifying URLs and optionally stripping ANSI escape codes."
+ (elpher-buttonify-urls (if elpher-strip-ansi-from-text
+ (elpher-strip-ansi string)
+ string)))
+