Package: emacs;
Reported by: Rahguzar <rahguzar <at> zohomail.eu>
Date: Sun, 22 Oct 2023 08:12:02 UTC
Severity: wishlist
Found in version 29.1
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66676 in the body.
You can then email your comments to 66676 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sun, 22 Oct 2023 08:12:02 GMT) Full text and rfc822 format available.Rahguzar <rahguzar <at> zohomail.eu>
:bug-gnu-emacs <at> gnu.org
.
(Sun, 22 Oct 2023 08:12:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: bug-gnu-emacs <at> gnu.org Subject: 29.1; Should some aspects of shr rendering be configurable Date: Sun, 22 Oct 2023 09:29:53 +0200
The background of this email is that I recently spent some time trying to make reading mathematics articles on Wikipedia using eww more pleasant for myself. The current results of that effort are located at https://codeberg.org/rahguzar/eww-hacks/src/branch/main/eww-hacks.el To see the difference open e.g. https://en.wikipedia.org/wiki/Cyclotomic_polynomial without and without that file loaded. So I wanted to ask if some of the changes to shr might be useful to have in Emacs itself. The changes ordered from most likely to be useful to least likely (in my opinion) are as follows: 1) Using `visual-line-mode` for line wrapping. I think this is more natural for html and makes resizing windows work more nicely. 2) Not introducing line-breaks for every image. Wikipedia uses small inline images quite extensively for mathematical notation and shr breaks line at each of them which makes the text quite hard to read. This line breaking is scattered at three different places: a) shr-tag-image which inserts a newline before every image. b) shr-insert which inserts newline after the image by checking if the point is after an image. c) shr-put-image which inserts a newline after an image if the image is large enough. This scattered insertion of newlines makes it quite difficult to advice shr to not add these newlines. I think c) is good behavior but a) and b) are not. However to preserve backward compatibility not doing a) and b) should be done conditioned on a new variable. 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. 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. Finally one point related to eww directly. I am using a package on melpa that provides outline support for eww but it does it by insert special characters at the beginning of headings and then setting `outline-regexp` to find them. Since Emacs 29 introduces `outline-search-function` I think it makes sense to set one for eww that searches for headings using text-properties and this doesn't require any extra marks in the buffer. I also have a couple of questions of how to hack on eww to make it a bit better for my personal use: 1) I think reading Wikipedia math articles is quite pleasant now except for proofs (there are a couple of those in the article linked above). They are coded as an html table and I think to make width calculations work shr doesn't render images and just drops them after the table. However this makes the proof unreadable. Since in this cases the table has only cell, is there an easy way to treat that cases specially and not try to render it as a table? (I have no experience with html rednering). 2) Is there an easy way to make eww not reload the page after clicking on a link that points to a location on the same page? Thanks, Rahguzar In GNU Emacs 29.1 (build 1, x86_64-suse-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2023-10-08 built on i02-ch2a System Description: openSUSE Tumbleweed Configured using: 'configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-pgtk --with-native-compilation=aot --with-cairo --with-libotf --with-jpeg --with-tiff --with-gif --with-png --with-rsvg --with-xft --with-xml2 --with-dbus --with-sound --with-json --with-mailutils --with-gnutls --with-tree-sitter --enable-locallisppath=/usr/share/emacs/29.1/site-lisp:/usr/share/emacs/site-lisp 'CFLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto' LDFLAGS=-Wl,-O2' Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER XIM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: mu4e:main Minor modes in effect: pdf-occur-global-minor-mode: t global-evil-surround-mode: t evil-surround-mode: t eros-mode: t recentf-mode: t save-place-mode: t global-so-long-mode: t which-key-mode: t savehist-mode: t better-jumper-mode: t better-jumper-local-mode: t global-company-mode: t company-mode: t vertico-mode: t nerd-icons-completion-mode: t marginalia-mode: t evil-goggles-mode: t evil-escape-mode: t evil-snipe-override-mode: t evil-snipe-mode: t gcmh-mode: t winner-mode: t smartparens-global-mode: t ws-butler-global-mode: t undo-fu-session-global-mode: t undo-fu-mode: t satchel-mode: t mu4e-search-minor-mode: t global-hl-line-mode: t hl-line-mode: t mu4e-update-minor-mode: t mu4e-context-minor-mode: t dirvish-override-dired-mode: t server-mode: t pixel-scroll-precision-mode: t repeat-mode: t evil-mode: t evil-local-mode: t +popup-mode: t +modeline-global-mode: t +modeline-mode: t global-ligature-mode: t ligature-mode: t override-global-mode: t general-override-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t window-divider-mode: t buffer-read-only: t size-indication-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t abbrev-mode: t Load-path shadows: /home/azeem/.emacs.d/.local/straight/build-29.1/emacsql/emacsql-sqlite-builtin hides /home/azeem/.emacs.d/.local/straight/build-29.1/emacsql-sqlite-builtin/emacsql-sqlite-builtin /home/azeem/.emacs.d/.local/straight/build-29.1/citar-embark/citar-embark hides /home/azeem/.emacs.d/.local/straight/build-29.1/citar/citar-embark /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-view hides /usr/share/emacs/site-lisp/mu4e/mu4e-view /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-search hides /usr/share/emacs/site-lisp/mu4e/mu4e-search /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-org hides /usr/share/emacs/site-lisp/mu4e/mu4e-org /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-contacts hides /usr/share/emacs/site-lisp/mu4e/mu4e-contacts /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-config hides /usr/share/emacs/site-lisp/mu4e/mu4e-config /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e hides /usr/share/emacs/site-lisp/mu4e/mu4e /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-window hides /usr/share/emacs/site-lisp/mu4e/mu4e-window /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-vars hides /usr/share/emacs/site-lisp/mu4e/mu4e-vars /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-update hides /usr/share/emacs/site-lisp/mu4e/mu4e-update /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-speedbar hides /usr/share/emacs/site-lisp/mu4e/mu4e-speedbar /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-server hides /usr/share/emacs/site-lisp/mu4e/mu4e-server /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-query-items hides /usr/share/emacs/site-lisp/mu4e/mu4e-query-items /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-obsolete hides /usr/share/emacs/site-lisp/mu4e/mu4e-obsolete /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-notification hides /usr/share/emacs/site-lisp/mu4e/mu4e-notification /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-modeline hides /usr/share/emacs/site-lisp/mu4e/mu4e-modeline /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-message hides /usr/share/emacs/site-lisp/mu4e/mu4e-message /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-mark hides /usr/share/emacs/site-lisp/mu4e/mu4e-mark /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-main hides /usr/share/emacs/site-lisp/mu4e/mu4e-main /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-lists hides /usr/share/emacs/site-lisp/mu4e/mu4e-lists /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-icalendar hides /usr/share/emacs/site-lisp/mu4e/mu4e-icalendar /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-helpers hides /usr/share/emacs/site-lisp/mu4e/mu4e-helpers /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-headers hides /usr/share/emacs/site-lisp/mu4e/mu4e-headers /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-folders hides /usr/share/emacs/site-lisp/mu4e/mu4e-folders /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-draft hides /usr/share/emacs/site-lisp/mu4e/mu4e-draft /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-contrib hides /usr/share/emacs/site-lisp/mu4e/mu4e-contrib /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-context hides /usr/share/emacs/site-lisp/mu4e/mu4e-context /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-compose hides /usr/share/emacs/site-lisp/mu4e/mu4e-compose /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-bookmarks hides /usr/share/emacs/site-lisp/mu4e/mu4e-bookmarks /home/azeem/.emacs.d/.local/straight/build-29.1/mu4e/mu4e-actions hides /usr/share/emacs/site-lisp/mu4e/mu4e-actions Features: (macrostep-c cmacexp evil-collection-macrostep macrostep cc-mode-expansions smartparens-c cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine org-eldoc cdlatex toc-org evil-org org-indent ol-bibtex shadow emacsbug vertico-directory time inspirehep-pdf companion-mode inspirehep url-queue evil-collection-reftex reftex-toc reftex-cite reftex-ref reftex-parse reftex reftex-loaddefs reftex-vars pdf-annot facemenu pdf-outline pdf-links pdf-roll pdf-loader pdf-occur evil-collection-tablist tablist tablist-filter semantic/wisent/comp semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util semantic semantic/tag semantic/lex semantic/fw mode-local cedet pdf-isearch pdf-misc evil-collection-pdf pdf-history pdf-tools evil-collection-package-menu doom-packages package url-handlers pdf-view pdf-cache pdf-info tq pdf-util pdf-macs image-mode exif char-fold guess-language flyspell link-hint ffap goto-addr avy company-ispell company-yasnippet company-dabbrev delsel adaptive-wrap jit-spell ispell face-remap evil-collection-proced proced gnus-icalendar org-capture icalendar diary-lib diary-loaddefs smerge-mode diff gnus-async gnus-bcklg gnus-ml evil-collection-indent use-package-lint consult-imenu evil-collection-consult consult evil-collection-vc-git vc-git evil-collection-diff-mode diff-mode vc-dispatcher files-x evil-collection-xref xref find-dired jka-compr auto-minor-mode disp-table whitespace bicycle hideshow evil-embrace evil-surround embrace expand-region text-mode-expansions the-org-mode-expansions org-element org-persist xdg org-id org-refile avl-tree generator er-basic-expansions expand-region-core expand-region-custom eros highlight-quoted rainbow-delimiters highlight-numbers parent-mode display-line-numbers hl-todo evil-collection-elisp-mode elisp-mode recentf tree-widget saveplace evil-collection-so-long so-long evil-collection-helpful helpful cc-langs cc-vars cc-defs evil-collection-imenu imenu trace evil-collection-edebug edebug evil-collection-debug debug backtrace info-look evil-collection-info info f f-shortdoc help-fns radix-tree evil-collection-elisp-refs elisp-refs s sort gnus-cite smiley shr-color mm-archive mail-extr textsec uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check qp nndraft nnmh nnfolder cursor-sensor vertico-repeat epa-file network-stream nsm gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg nntp gnus-cache hide-mode-line evil-collection-help descr-text evil-collection-which-key which-key savehist better-jumper company-capf company evil-collection-vertico vertico orderless nerd-icons-completion marginalia compat evil-goggles pulse color evil-easymotion evil-escape evil-snipe autorevert filenotify gcmh winner smartparens-config smartparens-text smartparens loadhist dash ws-butler undo-fu-session undo-fu satchel ibuf-ext evil-collection-ibuffer ibuffer ibuffer-loaddefs desktop frameset evil-collection-mu4e mu4e mu4e-org evil-collection-org smartparens-org org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint org-pcomplete pcomplete org-list org-footnote org-faces org-entities noutline outline ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys oc-natbib oc-csl bibtex oc-biblatex oc org-loaddefs find-func org-version org-compat org-macs mu4e-notification notifications mu4e-main mu4e-view gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time iso8601 gnus-spec gnus-int gnus-range gnus-win evil-collection-gnus gnus nnheader range evil-collection-calendar cal-menu calendar cal-loaddefs mu4e-headers mu4e-compose mu4e-draft mu4e-actions smtpmail mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message shr pixel-fill kinsoku url-file svg xml dom browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util url-parse auth-source json map url-vars flow-fill mule-util hl-line mu4e-contacts mu4e-update mu4e-folders mu4e-context mu4e-query-items mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window evil-collection-bookmark bookmark ido message sendmail mailcap yank-media puny dirvish transient format-spec eieio eieio-core evil-collection-dired dired dired-loaddefs rfc822 mml mml-sec password-cache evil-collection-epa epa epg rfc6068 epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader mu4e-obsolete server dtrt-indent ef-spring-theme ef-themes pixel-scroll cua-base repeat midnight html2text let-alist evil-collection-flymake flymake-proc flymake project evil-collection-compile evil-collection-custom cus-edit cus-load wid-edit evil-collection-comint evil-collection annalist compile text-property-search comint ansi-osc ansi-color ibuf-macs evil evil-integration evil-maps evil-commands reveal evil-jumps evil-command-window evil-types evil-search evil-macros evil-repeat evil-states evil-core byte-opt advice evil-common thingatpt rect evil-vars ring nerd-icons nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon nerd-icons-data-powerline nerd-icons-data-octicon nerd-icons-data-pomicon nerd-icons-data-ipsicon ligature derived edmacro kmacro use-package-bind-key bind-key comp comp-cstr warnings icons rx doom-editor doom-projects doom-ui easy-mmode doom-keybinds pp cl-extra help-mode use-package-core bytecomp byte-compile general tex-site doom-start doom-modules cl-seq doom doom-lib cl-macs cl-loaddefs cl-lib pcase gv harfbuzz jansson dynamic-modules subr-x rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 1300349 189182) (symbols 48 66318 75) (strings 32 312986 21752) (string-bytes 1 9875702) (vectors 16 148300) (vector-slots 8 3659358 277788) (floats 8 1572 1454) (intervals 56 83807 1891) (buffers 984 46))
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sun, 22 Oct 2023 09:54:01 GMT) Full text and rfc822 format available.Message #8 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Rahguzar <rahguzar <at> zohomail.eu> Cc: 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sun, 22 Oct 2023 12:52:51 +0300
> Date: Sun, 22 Oct 2023 09:29:53 +0200 > From: Rahguzar via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> > > > 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. > 2) Not introducing line-breaks for every image. Wikipedia uses small > inline images quite extensively for mathematical notation and shr breaks > line at each of them which makes the text quite hard to read. This line > breaking is scattered at three different places: 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. > 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.
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sun, 22 Oct 2023 10:43:01 GMT) Full text and rfc822 format available.Message #11 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Eli Zaretskii <eliz <at> gnu.org> Cc: 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sun, 22 Oct 2023 12:26:53 +0200
Hi Eli, Eli Zaretskii <eliz <at> gnu.org> 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
Stefan Kangas <stefankangas <at> gmail.com>
to control <at> debbugs.gnu.org
.
(Sun, 22 Oct 2023 19:42:01 GMT) Full text and rfc822 format available.bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Wed, 25 Oct 2023 16:32:02 GMT) Full text and rfc822 format available.Message #16 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Rahguzar <rahguzar <at> zohomail.eu> Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Wed, 25 Oct 2023 18:18:06 +0200
[Message part 1 (text/plain, inline)]
Dear Emacs developers, Please find attached 5 patches: 1) The first introduces and uses the options Eli agreed with. These include options to not fill text, configurable raise properties for super and subscripts and :ascent property for images. The default values for these new options do not alter the current behavior. 2) The second introduces an option to allow displaying some images inline. The default value again preserves the existing behavior. 3) The third patch added an outline-search function and outline-level to shr.el. These can be set by modes such as eww to provide outline support. 4) The fourth patch adds these to provide outline support to eww. It has enables visual-line-mode if shr is configured not to use visual-line-mode. 5) The fifth patch corrects some misbehavior that I observed but I am not sure it is the right thing so please feel free to disregard it. Before inserting a subscript it checks if the subscript in on a newline and in that case removes the newline. The newlines seem to be coming from <br> tags which seems to be there to provide vertical alignment of subscript and superscript if both are present. Thanks, Rahguzar
[0001-Make-some-aspects-of-shr-rendering-customizable.patch (text/x-patch, attachment)]
[0002-Allow-displaying-images-inline.patch (text/x-patch, attachment)]
[0003-Outline-support-for-shr-rendered-documents.patch (text/x-patch, attachment)]
[0004-Optionally-turn-on-visual-line-mode-outline-support.patch (text/x-patch, attachment)]
[0005-Don-t-insert-subscript-on-a-newline.patch (text/x-patch, attachment)]
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 04 Nov 2023 08:12:02 GMT) Full text and rfc822 format available.Message #19 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Lars Ingebrigtsen <larsi <at> gnus.org> Cc: rahguzar <at> zohomail.eu, 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 04 Nov 2023 10:10:14 +0200
Lars, anybody else? Any comments to these changes? > From: Rahguzar <rahguzar <at> zohomail.eu> > Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org > Date: Wed, 25 Oct 2023 18:18:06 +0200 > > Dear Emacs developers, > > Please find attached 5 patches: > > 1) The first introduces and uses the options Eli agreed with. These > include options to not fill text, configurable raise properties for > super and subscripts and :ascent property for images. The default values > for these new options do not alter the current behavior. > > 2) The second introduces an option to allow displaying some images > inline. The default value again preserves the existing behavior. > > 3) The third patch added an outline-search function and outline-level to > shr.el. These can be set by modes such as eww to provide outline > support. > > 4) The fourth patch adds these to provide outline support to eww. It has > enables visual-line-mode if shr is configured not to use > visual-line-mode. > > 5) The fifth patch corrects some misbehavior that I observed but I am > not sure it is the right thing so please feel free to disregard it. > Before inserting a subscript it checks if the subscript in on a newline > and in that case removes the newline. The newlines seem to be coming > from <br> tags which seems to be there to provide vertical alignment of > subscript and superscript if both are present. > > Thanks, > Rahguzar > > > > >From a46810e54ba2590cae88cde09445bfc34a5ac77b Mon Sep 17 00:00:00 2001 > From: Rahguzar <rahguzar <at> zohomail.eu> > Date: Mon, 23 Oct 2023 21:23:53 +0200 > Subject: [PATCH 1/5] Make some aspects of shr rendering customizable > > * lisp/net/shr.el > (shr-fill-text): New custom variable > (shr-sup-raise-factor): New custom variable > (shr-sub-raise-factor): New custom variable > (shr-image-ascent): New custom variable > (shr-fill-lines): Only fill if shr-fill-text is non nil > (shr-put-image): Use shr-image-ascent as value of :ascent > (shr-rescale-image): Use shr-image-ascent > (shr-make-placeholder-image): Use shr-image-ascent > (shr-tag-sup): use shr-sup-raise-factor > (shr-tag-sub): use shr-sub-raise-factor > --- > lisp/net/shr.el | 42 +++++++++++++++++++++++++++++++++--------- > 1 file changed, 33 insertions(+), 9 deletions(-) > > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index 645e1cc51e5..185f2c0422d 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -163,6 +163,30 @@ shr-offer-extend-specpdl > :version "28.1" > :type 'boolean) > > +(defcustom shr-fill-text t > + "Non-nil means to fill the text according to the width of the window. > +If nil text is not filled and `visual-line-mode' can be used to reflow text." > + :version "30.1" > + :type 'boolean) > + > + > +(defcustom shr-sup-raise-factor 0.2 > + "The value of raise property for superscripts. > +Should be a number between 0 and 1." > + :version "30.1" > + :type 'float) > + > +(defcustom shr-sub-raise-factor -0.2 > + "The value of raise property for subscripts. > +Should be a number between 0 and -1." > + :version "30.1" > + :type 'float) > + > +(defcustom shr-image-ascent 100 > + "The value to be used for :ascent property when inserting images." > + :version "30.1" > + :type 'integer) > + > (defvar shr-content-function nil > "If bound, this should be a function that will return the content. > This is used for cid: URLs, and the function is called with the > @@ -741,7 +765,7 @@ shr-insert > (or shr-current-font 'shr-text))))))))) > > (defun shr-fill-lines (start end) > - (if (<= shr-internal-width 0) > + (if (or (not shr-fill-text) (<= shr-internal-width 0)) > nil > (save-restriction > (narrow-to-region start end) > @@ -1063,11 +1087,11 @@ shr-put-image > (start (point)) > (image (cond > ((eq size 'original) > - (create-image data nil t :ascent 100 > + (create-image data nil t :ascent shr-image-ascent > :format content-type)) > ((eq content-type 'image/svg+xml) > (when (image-type-available-p 'svg) > - (create-image data 'svg t :ascent 100))) > + (create-image data 'svg t :ascent shr-image-ascent))) > ((eq size 'full) > (ignore-errors > (shr-rescale-image data content-type > @@ -1114,7 +1138,7 @@ shr-rescale-image > MAX-WIDTH/MAX-HEIGHT. If not given, use the current window > width/height instead." > (if (not (get-buffer-window (current-buffer) t)) > - (create-image data nil t :ascent 100) > + (create-image data nil t :ascent shr-image-ascent) > (let* ((edges (window-inside-pixel-edges > (get-buffer-window (current-buffer)))) > (max-width (truncate (* shr-max-image-proportion > @@ -1135,13 +1159,13 @@ shr-rescale-image > (< (* height scaling) max-height)) > (create-image > data (shr--image-type) t > - :ascent 100 > + :ascent shr-image-ascent > :width width > :height height > :format content-type) > (create-image > data (shr--image-type) t > - :ascent 100 > + :ascent shr-image-ascent > :max-width max-width > :max-height max-height > :format content-type))))) > @@ -1381,13 +1405,13 @@ shr-tag-svg > (defun shr-tag-sup (dom) > (let ((start (point))) > (shr-generic dom) > - (put-text-property start (point) 'display '(raise 0.2)) > + (put-text-property start (point) 'display `(raise ,shr-sup-raise-factor)) > (add-face-text-property start (point) 'shr-sup))) > > (defun shr-tag-sub (dom) > (let ((start (point))) > (shr-generic dom) > - (put-text-property start (point) 'display '(raise -0.2)) > + (put-text-property start (point) 'display `(raise ,shr-sub-raise-factor)) > (add-face-text-property start (point) 'shr-sup))) > > (defun shr-tag-p (dom) > @@ -1840,7 +1864,7 @@ shr-make-placeholder-image > (svg-rectangle svg 0 0 width height :gradient "background" > :stroke-width 2 :stroke-color "black") > (let ((image (svg-image svg :scale 1))) > - (setf (image-property image :ascent) 100) > + (setf (image-property image :ascent) shr-image-ascent) > image))) > > (defun shr-tag-pre (dom) > -- > 2.42.0 > > > >From adbee20c0e8e486de06ea4de9d6e69394a2fef66 Mon Sep 17 00:00:00 2001 > From: Rahguzar <rahguzar <at> zohomail.eu> > Date: Tue, 24 Oct 2023 20:30:23 +0200 > Subject: [PATCH 2/5] Allow displaying images inline > > * lisp/net/shr.el > (shr-max-inline-image-size): New custom variable > (shr-insert): Use the variable to determine whether to > insert newline before an image > (shr--inline-image-p): New function > (shr-put-image): Use variable and function > (shr-tag-img): Use variable > --- > lisp/net/shr.el | 65 +++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 52 insertions(+), 13 deletions(-) > > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index 185f2c0422d..adce66311f1 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -187,6 +187,24 @@ shr-image-ascent > :version "30.1" > :type 'integer) > > +(defcustom shr-max-inline-image-size nil > + "If non-nil determines when the images can be displayed inline. > +If nil images are never displayed inline. > + > +It non-nil it should be cons (WIDTH . HEIGHT). > + > +WIDTH can be an integer which is interpreted as number of pixels. If the width > +of an image exceeds this amount, the image is displayed on a separate line. > +WIDTH can also be floating point number, in which case the image is displayed > +inline if it occupies less than this fraction of window width. > + > +HEIGHT can be also be an integer or a floating point number. If it is an > +integer and the pixel height of an image exceeds it, the image image is > +displyed on a separate line. If it is an floating point, the limit is > +interpreted as multiples of the height of default font." > + :version "30.1" > + :type '(choice (const nil) (cons number number))) > + > (defvar shr-content-function nil > "If bound, this should be a function that will return the content. > This is used for cid: URLs, and the function is called with the > @@ -721,7 +739,8 @@ shr--translate-insertion-chars > (replace-match " " t t))) > > (defun shr-insert (text) > - (when (and (not (bolp)) > + (when (and (not shr-max-inline-image-size) > + (not (bolp)) > (get-text-property (1- (point)) 'image-url)) > (insert "\n")) > (cond > @@ -1073,6 +1092,19 @@ shr-image-from-data > (declare-function image-size "image.c" (spec &optional pixels frame)) > (declare-function image-animate "image" (image &optional index limit position)) > > +(defun shr--inline-image-p (image) > + "Return non-nil if IMAGE should be displayed inline." > + (when shr-max-inline-image-size > + (let ((size (image-size image t)) > + (max-width (car shr-max-inline-image-size)) > + (max-height (cdr shr-max-inline-image-size))) > + (unless (integerp max-width) > + (setq max-width (* max-width (window-width nil t)))) > + (unless (integerp max-height) > + (setq max-width (* max-width (frame-char-height)))) > + (and (< (car size) max-width) > + (< (cdr size) max-width))))) > + > (defun shr-put-image (spec alt &optional flags) > "Insert image SPEC with a string ALT. Return image. > SPEC is either an image data blob, or a list where the first > @@ -1103,19 +1135,25 @@ shr-put-image > (plist-get flags :width) > (plist-get flags :height))))))) > (when image > + ;; The trailing confuse can confuse shr-insert into not > + ;; putting any space after inline images. > + (setq alt (string-trim alt)) > ;; When inserting big-ish pictures, put them at the > ;; beginning of the line. > - (when (and (> (current-column) 0) > - (> (car (image-size image t)) 400)) > - (insert "\n")) > - (let ((image-pos (point))) > - (if (eq size 'original) > - (insert-sliced-image image (or alt "*") nil 20 1) > - (insert-image image (or alt "*"))) > - (put-text-property start (point) 'image-size size) > - (when (and shr-image-animate > - (cdr (image-multi-frame-p image))) > - (image-animate image nil 60 image-pos)))) > + (let ((inline (shr--inline-image-p image))) > + (when (and (> (current-column) 0) > + (not inline)) > + (insert "\n")) > + (let ((image-pos (point))) > + (if (eq size 'original) > + (insert-sliced-image image (or alt "*") nil 20 1) > + (insert-image image (or alt "*"))) > + (put-text-property start (point) 'image-size size) > + (when (and (not inline) shr-max-inline-image-size) > + (insert "\n")) > + (when (and shr-image-animate > + (cdr (image-multi-frame-p image))) > + (image-animate image nil 60 image-pos))))) > image) > (insert (or alt "")))) > > @@ -1676,7 +1714,8 @@ shr-tag-img > (and dom > (or (> (length (dom-attr dom 'src)) 0) > (> (length (dom-attr dom 'srcset)) 0)))) > - (when (> (current-column) 0) > + (when (and (not shr-max-inline-image-size) > + (> (current-column) 0)) > (insert "\n")) > (let ((alt (dom-attr dom 'alt)) > (width (shr-string-number (dom-attr dom 'width))) > -- > 2.42.0 > > > >From 86bb59a9eafbe646689cdd4d593a9477082a2883 Mon Sep 17 00:00:00 2001 > From: Rahguzar <rahguzar <at> zohomail.eu> > Date: Tue, 24 Oct 2023 22:07:51 +0200 > Subject: [PATCH 3/5] Outline support for shr rendered documents > > * lisp/net/shr.el > (shr-heading): Propertize heading with level > (shr-outline-search): outline-search-function that finds > headings using text property search > (shr-outline-level): outline level for shr-outline-search > --- > lisp/net/shr.el | 41 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 40 insertions(+), 1 deletion(-) > > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index adce66311f1..38a79107f68 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -1272,7 +1272,11 @@ shr-image-displayer > > (defun shr-heading (dom &rest types) > (shr-ensure-paragraph) > - (apply #'shr-fontize-dom dom types) > + (let ((start (point)) > + (level (string-to-number > + (string-remove-prefix "shr-h" (symbol-name (car types)))))) > + (apply #'shr-fontize-dom dom types) > + (put-text-property start (pos-eol) 'outline-level level)) > (shr-ensure-paragraph)) > > (defun shr-urlify (start url &optional title) > @@ -2063,6 +2067,41 @@ shr-tag-bdi > (shr-generic dom) > (insert ?\N{POP DIRECTIONAL ISOLATE})) > > +;;; Outline Support > +(defun shr-outline-search (&optional bound move backward looking-at) > + "A function that can be used as `outline-search-function' for rendered html. > +See `outline-search-function' for BOUND, MOVE, BACKWARD and LOOKING-AT." > + (if looking-at > + (get-text-property (point) 'outline-level) > + (let ((heading-found nil) > + (bound (or bound > + (if backward (point-min) (point-max))))) > + (save-excursion > + (when (and (not (bolp)) > + (get-text-property (point) 'outline-level)) > + (forward-line (if backward -1 1))) > + (if backward > + (unless (get-text-property (point) 'outline-level) > + (goto-char (or (previous-single-property-change > + (point) 'outline-level nil bound) > + bound))) > + (goto-char (or (text-property-not-all (point) bound 'outline-level nil) > + bound))) > + (goto-char (pos-bol)) > + (when (get-text-property (point) 'outline-level) > + (setq heading-found (point)))) > + (if heading-found > + (progn > + (set-match-data (list heading-found heading-found)) > + (goto-char heading-found)) > + (when move > + (goto-char bound) > + nil))))) > + > +(defun shr-outline-level () > + "Function to be used as `outline-level' with `shr-outline-search'." > + (get-text-property (point) 'outline-level)) > + > ;;; Table rendering algorithm. > > ;; Table rendering is the only complicated thing here. We do this by > -- > 2.42.0 > > > >From 4de3b0766550f5e308010a885397a72a26d40dee Mon Sep 17 00:00:00 2001 > From: Rahguzar <rahguzar <at> zohomail.eu> > Date: Tue, 24 Oct 2023 23:35:44 +0200 > Subject: [PATCH 4/5] Optionally turn on visual-line-mode + outline support > > * lisp/net/eww.el > (eww-render): Turn on visual-line-mode in absence of filling > (eww-mode): set outline-regexp and outline-level > --- > lisp/net/eww.el | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lisp/net/eww.el b/lisp/net/eww.el > index e43ef2bfe8b..3224c382d53 100644 > --- a/lisp/net/eww.el > +++ b/lisp/net/eww.el > @@ -657,6 +657,8 @@ eww-render > (setq eww-history-position 0) > (and last-coding-system-used > (set-buffer-file-coding-system last-coding-system-used)) > + (unless shr-fill-text > + (visual-line-mode)) > (run-hooks 'eww-after-render-hook) > ;; Enable undo again so that undo works in text input > ;; boxes. > @@ -1217,6 +1219,8 @@ eww-mode > (setq-local shr-url-transformer #'eww--transform-url) > ;; Also rescale images when rescaling the text. > (add-hook 'text-scale-mode-hook #'eww--rescale-images nil t) > + (setq-local outline-search-function 'shr-outline-search > + outline-level 'shr-outline-level) > (setq buffer-read-only t)) > > (defvar text-scale-mode) > -- > 2.42.0 > > > > >From 4ef6bfccf2db22374ed43aaa6feebc2a3af60d64 Mon Sep 17 00:00:00 2001 > From: Rahguzar <rahguzar <at> zohomail.eu> > Date: Wed, 25 Oct 2023 15:20:29 +0200 > Subject: [PATCH 5/5] Don't insert subscript on a newline > > * lisp/net/shr.el (shr-tag-sub): see above > --- > lisp/net/shr.el | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index 38a79107f68..3e022df236c 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -1451,6 +1451,13 @@ shr-tag-sup > (add-face-text-property start (point) 'shr-sup))) > > (defun shr-tag-sub (dom) > + ;; Why would a subscript be at the beginning of a line? It does > + ;; happen sometimes because of a <br> tag and the intent seems to be > + ;; alignment of subscript and superscript but I don't think that is > + ;; possible in Emacs. So we remove the newline in that case. > + (when (bolp) > + (forward-char -1) > + (delete-char 1)) > (let ((start (point))) > (shr-generic dom) > (put-text-property start (point) 'display `(raise ,shr-sub-raise-factor)) > -- > 2.42.0 >
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 04 Nov 2023 09:16:02 GMT) Full text and rfc822 format available.Message #22 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Eli Zaretskii <eliz <at> gnu.org> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 04 Nov 2023 10:06:54 +0100
Please note that there is bug in `shr--inline-image-p` defined in one of the patches. Fixing it amounts too: (unless (integerp max-width) (setq max-width (* max-width (window-width nil t)))) (unless (integerp max-height) - (setq max-width (* max-width (frame-char-height)))) + (setq max-height (* max-height (frame-char-height)))) (and (< (car size) max-width) - (< (cdr size) max-width))))) + (< (cdr size) max-height))))) I will add it to the next revision of the patch along with any other changes due to feedback. Thanks, Rahguzar
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 04 Nov 2023 12:07:01 GMT) Full text and rfc822 format available.Message #25 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> To: Eli Zaretskii <eliz <at> gnu.org> Cc: rahguzar <at> zohomail.eu, Lars Ingebrigtsen <larsi <at> gnus.org>, 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 04 Nov 2023 13:05:25 +0100
Eli Zaretskii <eliz <at> gnu.org> writes: > Lars, anybody else? Any comments to these changes? As an occasional user of shr (mainly when viewing HTML parts in Gnus) who frequently messes with window width and face height, I'm very much interested in better visual-line-mode integration. Also intrigued by outline-mode support. So closely following this thread, and enthusiastically thanking Rahguzar for tackling this 👏 Don't know if I have anything insightful to say re. the patches. Idly wondering if '(null shr-fill-text) ⇒ (visual-line-mode)' is the right control flow; e.g. maybe (a) shr-fill-text could be set to 'visual as a more explicit hint for major modes, or (b) major modes should grow new user options: e.g. eww-wrap-method ∈ {fill, visual}; 'visual would tell modes to set shr-fill-text to nil & enable visual-line-mode. There are already plenty of user knobs at the shr level though, so maybe no need to overthink this.
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 18 Nov 2023 09:00:02 GMT) Full text and rfc822 format available.Message #28 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> Cc: rahguzar <at> zohomail.eu, larsi <at> gnus.org, 66676 <at> debbugs.gnu.org Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 18 Nov 2023 10:59:23 +0200
> From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> > Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, rahguzar <at> zohomail.eu, > 66676 <at> debbugs.gnu.org > Date: Sat, 04 Nov 2023 13:05:25 +0100 > > Eli Zaretskii <eliz <at> gnu.org> writes: > > > Lars, anybody else? Any comments to these changes? > > As an occasional user of shr (mainly when viewing HTML parts in Gnus) > who frequently messes with window width and face height, I'm very much > interested in better visual-line-mode integration. Also intrigued by > outline-mode support. So closely following this thread, and > enthusiastically thanking Rahguzar for tackling this 👏 > > Don't know if I have anything insightful to say re. the patches. Idly > wondering if '(null shr-fill-text) ⇒ (visual-line-mode)' is the right > control flow; e.g. maybe > > (a) shr-fill-text could be set to 'visual as a more explicit hint for > major modes, or > > (b) major modes should grow new user options: e.g. eww-wrap-method ∈ > {fill, visual}; 'visual would tell modes to set shr-fill-text to nil & > enable visual-line-mode. > > There are already plenty of user knobs at the shr level though, so maybe > no need to overthink this. Thanks. Rahguzar, any followup to these comments? Please also see my minor comments below: > * lisp/net/shr.el > (shr-fill-text): New custom variable > (shr-sup-raise-factor): New custom variable > (shr-sub-raise-factor): New custom variable > (shr-image-ascent): New custom variable > (shr-fill-lines): Only fill if shr-fill-text is non nil > (shr-put-image): Use shr-image-ascent as value of :ascent > (shr-rescale-image): Use shr-image-ascent > (shr-make-placeholder-image): Use shr-image-ascent > (shr-tag-sup): use shr-sup-raise-factor > (shr-tag-sub): use shr-sub-raise-factor This doesn't follow our conventions: . identical entries should be grouped if possible (see below) . descriptions of changes should be complete sentences: start with a capital letter and end with a period . symbols should be quoted 'like this' In this case, here's how to format the above descriptions: * lisp/net/shr.el (shr-fill-text, shr-sup-raise-factor) (shr-sub-raise-factor, shr-image-ascent): New custom variables. (shr-fill-lines): Only fill if 'shr-fill-text' is non-nil. (shr-put-image): Use 'shr-image-ascent' as value of :ascent. (shr-rescale-image, shr-make-placeholder-image): Use 'shr-image-ascent'. (shr-tag-sup, shr-tag-sub): Use 'shr-sub-raise-factor'. Similar changes are needed in your other log messages. > +(defcustom shr-fill-text t > + "Non-nil means to fill the text according to the width of the window. > +If nil text is not filled and `visual-line-mode' can be used to reflow text." ^ ^ Two commas missing there. > +(defcustom shr-sup-raise-factor 0.2 > + "The value of raise property for superscripts. > +Should be a number between 0 and 1." This is better: Should be a non-negative float number between 0 and 1. > +(defcustom shr-sub-raise-factor -0.2 > + "The value of raise property for subscripts. > +Should be a number between 0 and -1." Likewise here (but "non-positive" instead of "non-negative"). > +(defcustom shr-max-inline-image-size nil > + "If non-nil determines when the images can be displayed inline. > +If nil images are never displayed inline. Commas missing after "nil" in both sentences. > +HEIGHT can be also be an integer or a floating point number. If it is an > +integer and the pixel height of an image exceeds it, the image image is > +displyed on a separate line. If it is an floating point, the limit is ^^^^^^^^^^^^^^^^^ "a floating point number" > +interpreted as multiples of the height of default font." ^^^^^^^^^^^^ "as a multiple" > @@ -1103,19 +1135,25 @@ shr-put-image > (plist-get flags :width) > (plist-get flags :height))))))) > (when image > + ;; The trailing confuse can confuse shr-insert into not > + ;; putting any space after inline images. "The trailing confuse can confuse" sounds strange, and is probably a typo of sorts. What did you mean to say there? > * lisp/net/shr.el (shr-tag-sub): see above This is not a proper change description. Either repeat the heading or include the file and function in the heading line (if they fit; they don't fit in this case, I think). > + ;; possible in Emacs. So we remove the newline in that case. ^^ Our convention is to leave 2 spaces between sentences, not one. Thanks.
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 18 Nov 2023 13:16:02 GMT) Full text and rfc822 format available.Message #31 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org> Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 18 Nov 2023 14:08:01 +0100
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes: > Eli Zaretskii <eliz <at> gnu.org> writes: > >> Lars, anybody else? Any comments to these changes? > > As an occasional user of shr (mainly when viewing HTML parts in Gnus) > who frequently messes with window width and face height, I'm very much > interested in better visual-line-mode integration. Also intrigued by > outline-mode support. So closely following this thread, and > enthusiastically thanking Rahguzar for tackling this 👏 > > Don't know if I have anything insightful to say re. the patches. Idly > wondering if '(null shr-fill-text) ⇒ (visual-line-mode)' is the right > control flow; e.g. maybe > > (a) shr-fill-text could be set to 'visual as a more explicit hint for > major modes, or > > (b) major modes should grow new user options: e.g. eww-wrap-method ∈ > {fill, visual}; 'visual would tell modes to set shr-fill-text to nil & > enable visual-line-mode. > > There are already plenty of user knobs at the shr level though, so maybe > no need to overthink this. I don't quite see the need of a user option to turn on a minor mode. It seems better to take the value of `shr-fill-text` as a hint and turn on the `visual-line-mode` as I have done. I don't think anyone want to see html rendered without some kind of reflowing. And if they do, they can turn off the mode in `eww-after-render-hook`. Otherwise, we can also not do anything and let the users add `visual-line-mode` to `eww-after-render-hook`. To me hooks rather than dedicated user options are the correct way to manage minor modes. Rahguzar
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sat, 18 Nov 2023 18:11:02 GMT) Full text and rfc822 format available.Message #34 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> To: Rahguzar <rahguzar <at> zohomail.eu> Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org> Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 18 Nov 2023 19:09:57 +0100
Rahguzar <rahguzar <at> zohomail.eu> writes: > Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes: > >> Don't know if I have anything insightful to say re. the patches. Idly >> wondering if '(null shr-fill-text) ⇒ (visual-line-mode)' is the right >> control flow; e.g. maybe >> >> (a) shr-fill-text could be set to 'visual as a more explicit hint for >> major modes, or >> >> (b) major modes should grow new user options: e.g. eww-wrap-method ∈ >> {fill, visual}; 'visual would tell modes to set shr-fill-text to nil & >> enable visual-line-mode. >> >> There are already plenty of user knobs at the shr level though, so maybe >> no need to overthink this. > > I don't quite see the need of a user option to turn on a minor mode. It > seems better to take the value of `shr-fill-text` as a hint and turn on > the `visual-line-mode` as I have done. I don't think anyone want to see > html rendered without some kind of reflowing. And if they do, they can > turn off the mode in `eww-after-render-hook`. Otherwise, we can also not > do anything and let the users add `visual-line-mode` to > `eww-after-render-hook`. To me hooks rather than dedicated user options > are the correct way to manage minor modes. Gotcha. Not sure why I have such a knee-jerk response to automating visual-line-mode activation. OT1H part of me likes your idea of not doing anything and letting users add visual-line-mode to eww-after-render-hook: it's explicit, it's less work for folks who would prefer to keep it off; OTOH, can't quite picture anyone actually preferring that. I guess by default, truncate-lines being nil, they would get some sort of "reflowing"… Tentative bottomline: it's fine as-is really 👍 The knobs are all there; I don't have an alternative that I strongly believe in.
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sun, 19 Nov 2023 11:17:02 GMT) Full text and rfc822 format available.Message #37 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com> Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org> Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sun, 19 Nov 2023 12:12:08 +0100
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes: > Gotcha. Not sure why I have such a knee-jerk response to automating > visual-line-mode activation. > > OT1H part of me likes your idea of not doing anything and letting users > add visual-line-mode to eww-after-render-hook: it's explicit, it's less > work for folks who would prefer to keep it off; Turning on a minor mode from a hook is easier than turning it off so that is one reason for preferring to not activate them. I think in this case I think people want to not fill text and also not turn on visual-line-mode should be rare enough that we should do it. But I don't have very strong opinion on this. > OTOH, can't quite picture anyone actually preferring that. I guess by > default, truncate-lines being nil, they would get some sort of > "reflowing"… > > Tentative bottomline: it's fine as-is really 👍 The knobs are all there; > I don't have an alternative that I strongly believe in. Rahguzar
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Sun, 19 Nov 2023 12:14:02 GMT) Full text and rfc822 format available.Message #40 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Eli Zaretskii <eliz <at> gnu.org> Cc: larsi <at> gnus.org, 66676 <at> debbugs.gnu.org, Kévin Le Gouguec <kevin.legouguec <at> gmail.com> Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sun, 19 Nov 2023 13:07:26 +0100
[Message part 1 (text/plain, inline)]
Hi Eli, Eli Zaretskii <eliz <at> gnu.org> writes: > Thanks. Rahguzar, any followup to these comments? I replied to the comments. Please let me know what is the preferred way of preferred way of proceeding in that case. > Please also see my minor comments below: > >> * lisp/net/shr.el >> (shr-fill-text): New custom variable >> (shr-sup-raise-factor): New custom variable >> (shr-sub-raise-factor): New custom variable >> (shr-image-ascent): New custom variable >> (shr-fill-lines): Only fill if shr-fill-text is non nil >> (shr-put-image): Use shr-image-ascent as value of :ascent >> (shr-rescale-image): Use shr-image-ascent >> (shr-make-placeholder-image): Use shr-image-ascent >> (shr-tag-sup): use shr-sup-raise-factor >> (shr-tag-sub): use shr-sub-raise-factor > > This doesn't follow our conventions: > > . identical entries should be grouped if possible (see below) > . descriptions of changes should be complete sentences: start with a > capital letter and end with a period > . symbols should be quoted 'like this' > > In this case, here's how to format the above descriptions: > > * lisp/net/shr.el (shr-fill-text, shr-sup-raise-factor) > (shr-sub-raise-factor, shr-image-ascent): New custom variables. > (shr-fill-lines): Only fill if 'shr-fill-text' is non-nil. > (shr-put-image): Use 'shr-image-ascent' as value of :ascent. > (shr-rescale-image, shr-make-placeholder-image): Use > 'shr-image-ascent'. > (shr-tag-sup, shr-tag-sub): Use 'shr-sub-raise-factor'. > > Similar changes are needed in your other log messages. Thanks! I have reworded all log messages. Hopefully they confirm to the standards better now. >> +(defcustom shr-fill-text t >> + "Non-nil means to fill the text according to the width of the window. >> +If nil text is not filled and `visual-line-mode' can be used to reflow text." > ^ ^ > Two commas missing there. Fixed. >> +(defcustom shr-sup-raise-factor 0.2 >> + "The value of raise property for superscripts. >> +Should be a number between 0 and 1." > > This is better: > > Should be a non-negative float number between 0 and 1. Fixed. >> +(defcustom shr-sub-raise-factor -0.2 >> + "The value of raise property for subscripts. >> +Should be a number between 0 and -1." > > Likewise here (but "non-positive" instead of "non-negative"). > >> +(defcustom shr-max-inline-image-size nil >> + "If non-nil determines when the images can be displayed inline. >> +If nil images are never displayed inline. > > Commas missing after "nil" in both sentences. > >> +HEIGHT can be also be an integer or a floating point number. If it is an >> +integer and the pixel height of an image exceeds it, the image image is >> +displyed on a separate line. If it is an floating point, the limit is > ^^^^^^^^^^^^^^^^^ > "a floating point number" Fixed. >> +interpreted as multiples of the height of default font." > ^^^^^^^^^^^^ > "as a multiple" > >> @@ -1103,19 +1135,25 @@ shr-put-image >> (plist-get flags :width) >> (plist-get flags :height))))))) >> (when image >> + ;; The trailing confuse can confuse shr-insert into not >> + ;; putting any space after inline images. > > "The trailing confuse can confuse" sounds strange, and is probably a > typo of sorts. What did you mean to say there? I meant 'trailing space'. Fixed now. Sorry for the typos and thanks for catching them. >> * lisp/net/shr.el (shr-tag-sub): see above > > This is not a proper change description. Either repeat the heading or > include the file and function in the heading line (if they fit; they > don't fit in this case, I think). > >> + ;; possible in Emacs. So we remove the newline in that case. > ^^ > Our convention is to leave 2 spaces between sentences, not one. Fixed. > Thanks. I have attached the updated patches. Thank you, Rahguzar
[0001-Make-some-aspects-of-shr-rendering-customizable.patch (text/x-patch, attachment)]
[0002-Allow-displaying-images-inline.patch (text/x-patch, attachment)]
[0003-Outline-support-for-shr-rendered-documents.patch (text/x-patch, attachment)]
[0004-Optionally-turn-on-visual-line-mode-outline-support.patch (text/x-patch, attachment)]
[0005-Don-t-insert-subscript-on-a-newline.patch (text/x-patch, attachment)]
bug-gnu-emacs <at> gnu.org
:bug#66676
; Package emacs
.
(Wed, 22 Nov 2023 20:22:02 GMT) Full text and rfc822 format available.Message #43 received at 66676 <at> debbugs.gnu.org (full text, mbox):
From: Rahguzar <rahguzar <at> zohomail.eu> To: Rahguzar <rahguzar <at> zohomail.eu> Cc: Eli Zaretskii <eliz <at> gnu.org>, 66676 <at> debbugs.gnu.org, larsi <at> gnus.org, Kévin Le Gouguec <kevin.legouguec <at> gmail.com> Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Wed, 22 Nov 2023 21:14:13 +0100
[Message part 1 (text/plain, inline)]
Hi Eli, Please disregard the patches in my last email. A last minute change introduced an pretty bad error into them. Basically I had noticed that the first time a page is fetched the spacing between inline images is not write. So I tried some changes and I don't know how but they seemed to work so I sent them. However they caused an error when starting a new Emacs session. I have not found the correct fix and done it in such a way that if the option for maximum size of inline images is not set the old code path is followed, so existing behavior will not be changed by default. I have used this fix for couple of days and it works as expected. I have attached updated set of patches with this email. Thank you, Rahguzar Rahguzar <rahguzar <at> zohomail.eu> writes: > Hi Eli, > > Eli Zaretskii <eliz <at> gnu.org> writes: > >> Thanks. Rahguzar, any followup to these comments? > > I replied to the comments. Please let me know what is the preferred way > of preferred way of proceeding in that case. > >> Please also see my minor comments below: >> >>> * lisp/net/shr.el >>> (shr-fill-text): New custom variable >>> (shr-sup-raise-factor): New custom variable >>> (shr-sub-raise-factor): New custom variable >>> (shr-image-ascent): New custom variable >>> (shr-fill-lines): Only fill if shr-fill-text is non nil >>> (shr-put-image): Use shr-image-ascent as value of :ascent >>> (shr-rescale-image): Use shr-image-ascent >>> (shr-make-placeholder-image): Use shr-image-ascent >>> (shr-tag-sup): use shr-sup-raise-factor >>> (shr-tag-sub): use shr-sub-raise-factor >> >> This doesn't follow our conventions: >> >> . identical entries should be grouped if possible (see below) >> . descriptions of changes should be complete sentences: start with a >> capital letter and end with a period >> . symbols should be quoted 'like this' >> >> In this case, here's how to format the above descriptions: >> >> * lisp/net/shr.el (shr-fill-text, shr-sup-raise-factor) >> (shr-sub-raise-factor, shr-image-ascent): New custom variables. >> (shr-fill-lines): Only fill if 'shr-fill-text' is non-nil. >> (shr-put-image): Use 'shr-image-ascent' as value of :ascent. >> (shr-rescale-image, shr-make-placeholder-image): Use >> 'shr-image-ascent'. >> (shr-tag-sup, shr-tag-sub): Use 'shr-sub-raise-factor'. >> >> Similar changes are needed in your other log messages. > > Thanks! I have reworded all log messages. Hopefully they confirm to the > standards better now. > >>> +(defcustom shr-fill-text t >>> + "Non-nil means to fill the text according to the width of the window. >>> +If nil text is not filled and `visual-line-mode' can be used to reflow text." >> ^ ^ >> Two commas missing there. > > Fixed. > >>> +(defcustom shr-sup-raise-factor 0.2 >>> + "The value of raise property for superscripts. >>> +Should be a number between 0 and 1." >> >> This is better: >> >> Should be a non-negative float number between 0 and 1. > > Fixed. > >>> +(defcustom shr-sub-raise-factor -0.2 >>> + "The value of raise property for subscripts. >>> +Should be a number between 0 and -1." >> >> Likewise here (but "non-positive" instead of "non-negative"). >> >>> +(defcustom shr-max-inline-image-size nil >>> + "If non-nil determines when the images can be displayed inline. >>> +If nil images are never displayed inline. >> >> Commas missing after "nil" in both sentences. >> >>> +HEIGHT can be also be an integer or a floating point number. If it is an >>> +integer and the pixel height of an image exceeds it, the image image is >>> +displyed on a separate line. If it is an floating point, the limit is >> ^^^^^^^^^^^^^^^^^ >> "a floating point number" > > Fixed. > >>> +interpreted as multiples of the height of default font." >> ^^^^^^^^^^^^ >> "as a multiple" >> >>> @@ -1103,19 +1135,25 @@ shr-put-image >>> (plist-get flags :width) >>> (plist-get flags :height))))))) >>> (when image >>> + ;; The trailing confuse can confuse shr-insert into not >>> + ;; putting any space after inline images. >> >> "The trailing confuse can confuse" sounds strange, and is probably a >> typo of sorts. What did you mean to say there? > > I meant 'trailing space'. Fixed now. > > Sorry for the typos and thanks for catching them. > >>> * lisp/net/shr.el (shr-tag-sub): see above >> >> This is not a proper change description. Either repeat the heading or >> include the file and function in the heading line (if they fit; they >> don't fit in this case, I think). >> >>> + ;; possible in Emacs. So we remove the newline in that case. >> ^^ >> Our convention is to leave 2 spaces between sentences, not one. > > Fixed. > >> Thanks. > > I have attached the updated patches. > > Thank you, > Rahguzar > > [2. text/x-patch; 0001-Make-some-aspects-of-shr-rendering-customizable.patch]... > > [3. text/x-patch; 0002-Allow-displaying-images-inline.patch]... > > [4. text/x-patch; 0003-Outline-support-for-shr-rendered-documents.patch]... > > [5. text/x-patch; 0004-Optionally-turn-on-visual-line-mode-outline-support.patch]... > > [6. text/x-patch; 0005-Don-t-insert-subscript-on-a-newline.patch]...
[0001-Make-some-aspects-of-shr-rendering-customizable.patch (text/x-patch, attachment)]
[0002-Allow-displaying-images-inline.patch (text/x-patch, attachment)]
[0003-Outline-support-for-shr-rendered-documents.patch (text/x-patch, attachment)]
[0004-Optionally-turn-on-visual-line-mode-outline-support.patch (text/x-patch, attachment)]
[0005-Don-t-insert-subscript-on-a-newline.patch (text/x-patch, attachment)]
Eli Zaretskii <eliz <at> gnu.org>
:Rahguzar <rahguzar <at> zohomail.eu>
:Message #48 received at 66676-done <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Rahguzar <rahguzar <at> zohomail.eu> Cc: larsi <at> gnus.org, 66676-done <at> debbugs.gnu.org, kevin.legouguec <at> gmail.com Subject: Re: bug#66676: 29.1; Should some aspects of shr rendering be configurable Date: Sat, 25 Nov 2023 13:01:20 +0200
> From: Rahguzar <rahguzar <at> zohomail.eu> > Cc: Eli Zaretskii <eliz <at> gnu.org>, Kévin Le Gouguec > <kevin.legouguec <at> gmail.com>, larsi <at> gnus.org, 66676 <at> debbugs.gnu.org > Date: Wed, 22 Nov 2023 21:14:13 +0100 > > I have attached updated set of patches with this email. Thanks, installed on master, and closing the bug.
Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Sat, 23 Dec 2023 12:24:14 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.