GNU bug report logs -
#75928
31.0.50; `dom-print' often fails to print an SVG DOM
Previous Next
Reported by: David Ponce <da_vid <at> orange.fr>
Date: Wed, 29 Jan 2025 15:53:02 UTC
Severity: normal
Tags: patch
Found in version 31.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 2025-02-08 10:41, Eli Zaretskii wrote:
>> Date: Wed, 5 Feb 2025 13:01:04 +0100
>> From: David Ponce via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> I attached a new patch that also avoid printing attributes without a
>> value (value is nil in the DOM).
>>
>> I also refreshed the list of HTML boolean attributes from the current
>> standard, and put checking for a boolean attribute in a separate
>> inline function for clarity.
>>
>> The patch also slightly improve the code by computing the indentation
>> column outside of loop and delegating indentation to `indent-line-to'.
>
> Thanks.
>
> Using indent-line-to requires binding indent-tabs-mode to nil, to make
> sure we produce spaces and not TABs, right?
>
> Also, please make sure the dom.el test suite still passes after this
> change, if you haven't already. Bonus points for providing a new test
> for this feature.
Hello Eli,
Thank you very much for your feedback.
Please, find attached a new patch to force indent with spaces and to add
two new tests to dom-tests.el.
Here is the updated change log:
2025-02-08 David Ponce <da_vid <at> orange.fr>
Fix DOM printing when an attribute value is not a string, which is
often the case in SVG DOM. Don't print attributes without a
value. Refresh the list of HTML boolean attributes.
* lisp/dom.el (dom--html-boolean-attribute-p): New function.
(dom-print): Use it. Convert attribute value to string before to
call `url-insert-entities-in-string'. Don't print attribute
without a value. Compute indentation column outside of loop and
call `indent-line-to' to indent line.
* test/lisp/dom-tests.el (dom-tests-print-svg)
(dom-tests-print-html-boolean): New tests.
All tests in dom-tests.el passed for me:
Running 28 tests (2025-02-08 13:45:37+0100, selector `(not (or (tag :unstable) (tag :nativecomp)))')
passed 1/28 dom-test-search (0.000180 sec)
passed 2/28 dom-tests-add-child-before (0.000199 sec)
passed 3/28 dom-tests-append-child (0.000074 sec)
passed 4/28 dom-tests-attr (0.000096 sec)
passed 5/28 dom-tests-attributes (0.000054 sec)
passed 6/28 dom-tests-by-class (0.000074 sec)
passed 7/28 dom-tests-by-id (0.000091 sec)
passed 8/28 dom-tests-by-style (0.000054 sec)
passed 9/28 dom-tests-by-tag (0.000052 sec)
passed 10/28 dom-tests-child-by-tag (0.000047 sec)
passed 11/28 dom-tests-children (0.000066 sec)
passed 12/28 dom-tests-elements (0.000057 sec)
passed 13/28 dom-tests-ensure-node (0.000071 sec)
passed 14/28 dom-tests-non-text-children (0.000057 sec)
passed 15/28 dom-tests-parent (0.000052 sec)
passed 16/28 dom-tests-pp (0.000102 sec)
passed 17/28 dom-tests-previous-sibling (0.000049 sec)
passed 18/28 dom-tests-print (0.009147 sec)
passed 19/28 dom-tests-print-html-boolean (0.000200 sec)
passed 20/28 dom-tests-print-svg (0.000166 sec)
passed 21/28 dom-tests-remove-attribute (0.000083 sec)
passed 22/28 dom-tests-remove-node (0.000088 sec)
passed 23/28 dom-tests-set-attribute (0.000039 sec)
passed 24/28 dom-tests-set-attributes (0.000074 sec)
passed 25/28 dom-tests-strings (0.000077 sec)
passed 26/28 dom-tests-tag (0.000087 sec)
passed 27/28 dom-tests-text (0.000065 sec)
passed 28/28 dom-tests-texts (0.000047 sec)
Ran 28 tests, 28 results as expected, 0 unexpected (2025-02-08 13:45:37+0100, 0.012721 sec)
[dom-patch-V2.patch (text/x-patch, attachment)]
This bug report was last modified 147 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.