Subject: bug#69516: 30.0.50; fontify newline and end of headlines in shr

From: Eli Zaretskii <[email-masked]>
Date: Sun, 03 Mar 2024 08:56:16 +0200

severity 69516 wishlist
thanks

> From: StrawberryTea <[email-masked]>
> Date: Sat, 02 Mar 2024 17:31:07 -0600
> 
> Hello Emacs developers,
> 
> As you know, I love extending my headline backgrounds to the end of the
> window. However, shr.el does not do this, understandably because shr.el
> was written before the :extend keyword was added.
> 
> The following patch hacks around this:
> 
> modified   lisp/net/shr.el
> @@ -990,16 +990,21 @@ shr-fontize-dom
> ;; Add face to the region, but avoid putting the font properties on
> ;; blank text at the start of the line, and the newline at the end, to
> ;; avoid ugliness.
>  (defun shr-add-font (start end type)
> +    (when (memq type '(shr-h1 shr-h2 shr-h3 shr-h4 shr-h5 shr-h6))
> +      (insert "\n")
> +      (setq end (1+ end)))
>    (save-excursion
>      (goto-char start)
>      (while (< (point) end)
>        (when (bolp)
>          (skip-chars-forward " "))
> -      (add-face-text-property (point) (min (line-end-position) end) type t)
> +      (add-face-text-property (point) end type t)
>        (if (< (line-end-position) end)
>            (forward-line 1)
>          (goto-char end)))))
> 
> But this is a hack, and I would like to see a proper fix in Emacs.

Thanks.  Patches for this are welcome, but I think this should be an
optional feature, given that we have lived without it for such a long
time.