Commit 8282c34f authored by Nicholas Drozd's avatar Nicholas Drozd Committed by Eli Zaretskii

Handle HTML 'ol' start attribute in shr.el

* lisp/net/shr.el (shr-tag-ol): Don't automatically assume
1-indexing for all ordered lists, use <ol> if given.

* etc/NEWS: Announce change in shr behavior.

* test/data/shr/ol.html:
* test/data/shr/ol.txt: New test data files.
parent 3432f554
......@@ -698,6 +698,8 @@ has been executed.
If set, shr will not render tags with attribute 'aria-hidden="true"'.
This attribute is meant to tell screen readers to ignore a tag.
*** 'shr-tag-ol' now respects the ordered list 'start' attribute.
** Htmlfontify
*** The functions 'hfy-color', 'hfy-color-vals' and
......
......@@ -1755,7 +1755,14 @@ The preference is a float determined from `shr-prefer-media-type'."
(defun shr-tag-ol (dom)
(shr-ensure-paragraph)
(let ((shr-list-mode 1))
(let* ((attrs (dom-attributes dom))
(start-attr (alist-get 'start attrs))
;; Start at 1 if there is no start attribute
;; or if start can't be parsed as an integer.
(start-index (condition-case _
(cl-parse-integer start-attr)
(t 1)))
(shr-list-mode start-index))
(shr-generic dom))
(shr-ensure-paragraph))
......
<ol>
<li>one</li>
<li>two</li>
<li>three</li>
</ol>
<ol start="10">
<li>ten</li>
<li>eleven</li>
<li>twelve</li>
</ol>
<ol start="0">
<li>zero</li>
<li>one</li>
<li>two</li>
</ol>
<ol start="-5">
<li>minus five</li>
<li>minus four</li>
<li>minus three</li>
</ol>
<ol start="notanumber">
<li>one</li>
<li>two</li>
<li>three</li>
</ol>
1 one
2 two
3 three
10 ten
11 eleven
12 twelve
0 zero
1 one
2 two
-5 minus five
-4 minus four
-3 minus three
1 one
2 two
3 three
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment