Subject: bug#66676: 29.1; Should some aspects of shr rendering be configurable

From: Rahguzar <[email-masked]>
Date: Sun, 22 Oct 2023 12:26:53 +0200

Hi Eli,

Eli Zaretskii <[email-masked]> writes:

>> 1) Using `visual-line-mode` for line wrapping. I think this is more
>> natural for html and makes resizing windows work more nicely.
>
> AFAIR, there were good reasons for the decision to fill text in shr.
> So this could be an optional feature, but not the default.
>

I was thinking of an optional feature too. I am not at all confident
that visual-line-mode will be good enough for tables for example.

> shr breaks lines on images because Emacs is incapable of displaying an
> image without making the line of surrounding text high enough to allow
> the image to be displayed.

I agree with this too, but the images I was thinking of are typically
around the same height as the surrounding text and I think these
newlines should be the responsibility of `shr-put-image-function`. The
default value `shr-put-image` already checks if image is more than 400
pixel wide and in that case inserts it into a new line. So I propose
adding a new `shr-max-inline-image-size` variable which a cons of
`WIDTH` and `HEIGHT` and images are inserted into a new line only if one
of its dimensions is bigger than the ones specified in
shr-max-inline-image-size.

>> 3) shr uses 0.2 and -0.2 as value of raise property for superscripts and
>> subscripts. I think it makes sense to make these values customizable.
>> For me 0.2 for superscripts was too low and 0.4 worked much better.
>
> No objection to making this customizable.
>
>> 4) shr uses 100 as the value of :ascent when creating an image. For me
>> this makes the inline images appear off centered. I fiddled with it a
>> bit and found 60 to be a good value for me. I wonder if it makes sense
>> to makes the value of :ascent to be customizable? My instinct is no
>> since I think the correct value can probably be computed from image
>> height and the average height of default face.
>
> I think it could be customizable even if it's computed from the image.

I will start with just making it customizable then since that is simpler
and send a patch adding the customizations listed above somewhat soon.

Thanks,
Rahguzar