Subject: 28.0.50; shr displays inline images on new line

From: Matt Huszagh <[email-masked]>
Date: Sun, 10 Oct 2021 10:50:52 -0700

shr appears to display all images on their own line, irrespective of
whether they are intended to be inline. An example of this can be seen
at https://en.wikipedia.org/wiki/Chain_rule:

(eww "https://en.wikipedia.org/wiki/Chain_rule")

For example, the equation showing h as the composition of f and g is
displayed on its own line, but should be displayed in line with the
surrounding text (as confirmed by viewing the page in a GUI-based
browser such as Firefox).

I took a quick look at the shr source code but couldn't determine why
this was actually happening. In particular, I couldn't find anything
in the shr-put-image function that might cause this. Using the above
example, the text that is overlayed with the image is

"{\\displaystyle h=f\\circ g}"

The insert-image function documentation indicates that the image
should be displayed at the location of that text. I additionally
tested this by downloading the SVG image file and using some simple
elisp code:

cd /tmp
wget https://wikimedia.org/api/rest_v1/media/math/render/svg/a14345f3938c66b1fde08e18d8b301a59c5775a5

(let ((data (with-temp-buffer
              (insert-file-contents "/tmp/img/a14345f3938c66b1fde08e18d8b301a59c5775a5")
              (buffer-string))))
  (with-current-buffer (get-buffer-create "*test*")
    (insert "some text ")
    (insert-image (create-image data 'svg t :ascent 100) "{\\displaystyle h=f\\circ g}")))

The image displays inline as expected.

Why is shr displaying the image on its own line? How can I remedy
this?

Thanks!
Matt

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
Repository revision: 662f91a795c0b5480b1733a99ef478c94d6f1426
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Ubuntu-Server 20.04.1 2021.08.24 customized using Cubic on 2021-08-24 19:22

Configured using:
 'configure
 --prefix=/nix/store/2qsaw18gfmfic2g1rhjpj03g5an325dn-emacs-gcc-20210722.0
 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
 --with-cairo --with-xwidgets --with-native-compilation 'CFLAGS=-O3
 -march=native -momit-leaf-frame-pointer''

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: /nix/store/r841j70wgcbsk5rps4xq9xvg1gsjljhf-emacs-packages-deps/share/emacs/site-lisp:
  value of $EMACSNATIVELOADPATH: /nix/store/r841j70wgcbsk5rps4xq9xvg1gsjljhf-emacs-packages-deps/share/emacs/native-lisp::
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: eww

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired dired-loaddefs rfc822 mml
mml-sec epa derived epg epg-config mm-decode mm-bodies mm-encode
mailabbrev gmm-utils mailheader sendmail vc-git diff-mode easy-mmode
vc-dispatcher pp parse-time iso8601 jka-compr cl-extra help-mode gnutls
network-stream url-http mail-parse rfc2231 url-gw nsm rmc url-cache
url-auth format-spec eww xdg url-queue thingatpt shr kinsoku svg xml dom
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util url-parse url-vars mailcap puny mm-url
gnus nnheader gnus-util rmail rmail-loaddefs auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json map rfc2047
rfc2045 ietf-drums text-property-search time-date subr-x seq byte-opt gv
bytecomp byte-compile cconv mail-utils wid-edit mm-util mail-prsvr
cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-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 cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice button loaddefs faces
cus-face macroexp files window text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote threads xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 234829 10481)
 (symbols 48 10417 0)
 (strings 32 58196 2316)
 (string-bytes 1 2743688)
 (vectors 16 20394)
 (vector-slots 8 466525 17485)
 (floats 8 171 482)
 (intervals 56 9147 11)
 (buffers 992 12))