822 |
(goto-char (point-min)) |
(goto-char (point-min)) |
823 |
;; Fontify ANSI escapes. |
;; Fontify ANSI escapes. |
824 |
(let ((faces nil) |
(let ((faces nil) |
825 |
|
(buffer-undo-list t) |
826 |
(start (point))) |
(start (point))) |
827 |
;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html |
;; http://www.isthe.com/chongo/tech/comp/ansi_escapes.html |
828 |
;; suggests many codes, but we only handle: |
;; suggests many codes, but we only handle: |
854 |
(delete-region (match-beginning 0) (match-end 0)) |
(delete-region (match-beginning 0) (match-end 0)) |
855 |
(setq start (point)))) |
(setq start (point)))) |
856 |
;; Other highlighting. |
;; Other highlighting. |
857 |
(if (< (buffer-size) (position-bytes (point-max))) |
(let ((buffer-undo-list t)) |
858 |
;; Multibyte characters exist. |
(if (< (buffer-size) (position-bytes (point-max))) |
859 |
(progn |
;; Multibyte characters exist. |
860 |
(goto-char (point-min)) |
(progn |
861 |
(while (search-forward "__\b\b" nil t) |
(goto-char (point-min)) |
862 |
(backward-delete-char 4) |
(while (search-forward "__\b\b" nil t) |
863 |
(put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
(backward-delete-char 4) |
864 |
(goto-char (point-min)) |
(put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
865 |
(while (search-forward "\b\b__" nil t) |
(goto-char (point-min)) |
866 |
(backward-delete-char 4) |
(while (search-forward "\b\b__" nil t) |
867 |
(put-text-property (1- (point)) (point) 'face Man-underline-face)))) |
(backward-delete-char 4) |
868 |
(goto-char (point-min)) |
(put-text-property (1- (point)) (point) 'face Man-underline-face)))) |
869 |
(while (search-forward "_\b" nil t) |
(goto-char (point-min)) |
870 |
(backward-delete-char 2) |
(while (search-forward "_\b" nil t) |
871 |
(put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
(backward-delete-char 2) |
872 |
(goto-char (point-min)) |
(put-text-property (point) (1+ (point)) 'face Man-underline-face)) |
873 |
(while (search-forward "\b_" nil t) |
(goto-char (point-min)) |
874 |
(backward-delete-char 2) |
(while (search-forward "\b_" nil t) |
875 |
(put-text-property (1- (point)) (point) 'face Man-underline-face)) |
(backward-delete-char 2) |
876 |
(goto-char (point-min)) |
(put-text-property (1- (point)) (point) 'face Man-underline-face)) |
877 |
(while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) |
(goto-char (point-min)) |
878 |
(replace-match "\\1") |
(while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t) |
879 |
(put-text-property (1- (point)) (point) 'face Man-overstrike-face)) |
(replace-match "\\1") |
880 |
(goto-char (point-min)) |
(put-text-property (1- (point)) (point) 'face Man-overstrike-face)) |
881 |
(while (re-search-forward "o\b\\+\\|\\+\bo" nil t) |
(goto-char (point-min)) |
882 |
(replace-match "o") |
(while (re-search-forward "o\b\\+\\|\\+\bo" nil t) |
883 |
(put-text-property (1- (point)) (point) 'face 'bold)) |
(replace-match "o") |
884 |
(goto-char (point-min)) |
(put-text-property (1- (point)) (point) 'face 'bold)) |
885 |
(while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) |
(goto-char (point-min)) |
886 |
(replace-match "+") |
(while (re-search-forward "[-|]\\(\b[-|]\\)+" nil t) |
887 |
(put-text-property (1- (point)) (point) 'face 'bold)) |
(replace-match "+") |
888 |
(goto-char (point-min)) |
(put-text-property (1- (point)) (point) 'face 'bold)) |
889 |
;; Try to recognize common forms of cross references. |
(goto-char (point-min)) |
890 |
(Man-highlight-references) |
;; Try to recognize common forms of cross references. |
891 |
(Man-softhyphen-to-minus) |
(Man-highlight-references) |
892 |
(goto-char (point-min)) |
(Man-softhyphen-to-minus) |
893 |
(while (re-search-forward Man-heading-regexp nil t) |
(goto-char (point-min)) |
894 |
(put-text-property (match-beginning 0) |
(while (re-search-forward Man-heading-regexp nil t) |
895 |
(match-end 0) |
(put-text-property (match-beginning 0) |
896 |
'face Man-overstrike-face)) |
(match-end 0) |
897 |
|
'face Man-overstrike-face))) |
898 |
(message "%s man page formatted" Man-arguments)) |
(message "%s man page formatted" Man-arguments)) |
899 |
|
|
900 |
(defun Man-highlight-references () |
(defun Man-highlight-references () |