Fix bold or underline of underscores (bug#78839)

* lisp/man.el (Man-fontify-manpage): Fix the "_\b_" case.
This commit is contained in:
Manuel Giraud 2025-06-19 16:42:57 +02:00 committed by Eli Zaretskii
parent 4607d3e426
commit 00b8d11ac8

View file

@ -1379,17 +1379,24 @@ Same for the ANSI bold and normal escape sequences."
(put-text-property (1- (point)) (point)
'font-lock-face 'Man-underline))))
(goto-char (point-min))
(while (and (search-forward "_\b" nil t) (not (eobp)))
(delete-char -2)
(put-text-property (point) (1+ (point)) 'font-lock-face 'Man-underline))
(goto-char (point-min))
(while (search-forward "\b_" nil t)
(delete-char -2)
(while (and (re-search-forward "_\b\\([^_]\\)" nil t) (not (eobp)))
(replace-match "\\1")
(put-text-property (1- (point)) (point) 'font-lock-face 'Man-underline))
(goto-char (point-min))
(while (re-search-forward "\\(.\\)\\(\b+\\1\\)+" nil t)
(while (re-search-forward "\\([^_]\\)\b_" nil t)
(replace-match "\\1")
(put-text-property (1- (point)) (point) 'font-lock-face 'Man-underline))
(goto-char (point-min))
(while (re-search-forward "\\([^_]\\)\\(\b+\\1\\)+" nil t)
(replace-match "\\1")
(put-text-property (1- (point)) (point) 'font-lock-face 'Man-overstrike))
;; Special case for "__": is it an underlined underscore or a bold
;; underscore? Look at the face after it to know.
(goto-char (point-min))
(while (search-forward "_\b_" nil t)
(delete-char -2)
(let ((face (get-text-property (point) 'font-lock-face)))
(put-text-property (1- (point)) (point) 'font-lock-face face)))
(goto-char (point-min))
(while (re-search-forward "o\b\\+\\|\\+\bo" nil t)
(replace-match "o")