Hi, I'm adding Hacker News in CC. On Sat, May 04, 2024 at 11:20:25AM +0200, a1ex@dismail.de wrote:
Hi Rodrigo,
Sometimes the page text is not entirely wrapped to the browser window, resulting in lines extending off screen, which is a pain.
What do you mean by "resulting in lines extending off screen"? If you mean the Dillo viewport, that is probably caused by some missing CSS feature, which we should fix too, but shouldn't happen with CSS disabled.
Here is an example: https://news.ycombinator.com/item?id=40250573
Viewing the page in Dillo with CSS turned off, some of the text runs off the window and I have to scroll right to see it. With CSS turned on, the text is very small and impossible to read on my monitor (but now the offending lines fit on the window). In Firefox, the text appears correctly and is always wrapped to the window regardless of zoom level.
I see what is going on. By default, Dillo doesn't wrap the content of <pre> elements. But, the following rule in HN CSS should cause it to wrap the text at spaces and newlines:
pre { overflow: auto; padding: 2px; white-space: pre-wrap; overflow-wrap:anywhere; }
But Dillo fails to process the CSS document because it doesn't understand a previous rule:
input[type=\"submit\"] { font-family:Verdana, Geneva, sans-serif; }
The 'input[type=\"submit\"]' selector is causing the CSS parser to ignore the rest of the CSS style sheet. I believe this is a bug in HN CSS, as it should be:
input[type="submit"] { font-family:Verdana, Geneva, sans-serif; }
Which works properly, I attached a reproducer. I have to check what is going on in the parser, by I suspect the first \" causes the parser to enter "string mode", and then the second \" is parsed as a quote inside the string because it is escaped, not as the closing quote. So everything else in the CSS file is treated as the content of the string. This should be fixed on HN side. We should make the CSS parser more robust to these problems. In the meanwhile, you can add this workaround in ~/.dillo/style.css to make <pre> wrapped by default in all pages:
pre { white-space: pre-wrap; }
Best, Rodrigo