[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] shr.el: correct SVG attribute case
From: |
Manuel Giraud |
Subject: |
Re: [PATCH] shr.el: correct SVG attribute case |
Date: |
Sat, 27 Jan 2024 18:18:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Sacha Chua <sacha@sachachua.com> writes:
> I've attached a patch for restoring the correct case of SVG attributes
> parsed with libxml-parse-html-region when displayed with shr, so that
> SVGs can be displayed properly. HTML attributes are case-insensitive and
> converted to lowercase, but SVG attributes are case-sensitive, so things
> like viewBox don't work if they're lowercased. It looks like other
> implementations (ex: https://github.com/w3c/svgwg/issues/161 ) also use
> the workaround of fixing attribute cases for SVGs, so I took the list
> from
> https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
> and fixed those attributes.
>
> Here's a small test to demonstrate the issue:
>
> ;; The following should display a full circle, not a quarter circle
> (with-current-buffer (get-buffer-create "*test*")
> (erase-buffer)
> (insert "<svg width=\"100px\" height=\"100px\" viewBox=\"0 0 200
> 200\"><circle cx=\"100\" cy=\"100\" r=\"100\"/></svg>\n")
> (shr-insert-document (libxml-parse-html-region (point-min) (point-max)))
> (display-buffer (current-buffer)))
Hi,
FWIW, it seems that 'libxml-parse-xml-region' seems to do the right
thing.
--
Manuel Giraud