aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Drozd2019-02-16 16:37:52 -0600
committerEli Zaretskii2019-02-22 09:52:57 +0200
commit8282c34f0f2f4ad2c4956fc595518da64a7bef1f (patch)
tree2432ac4729cb9cbec105e6c41345f3e41b763b6f
parent3432f5545c1a0c8149d489d1df8cf1d037dae2df (diff)
downloademacs-8282c34f0f2f4ad2c4956fc595518da64a7bef1f.tar.gz
emacs-8282c34f0f2f4ad2c4956fc595518da64a7bef1f.zip
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.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/net/shr.el9
-rw-r--r--test/data/shr/ol.html29
-rw-r--r--test/data/shr/ol.txt19
4 files changed, 58 insertions, 1 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 253da499899..30c42fa5302 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -698,6 +698,8 @@ has been executed.
698If set, shr will not render tags with attribute 'aria-hidden="true"'. 698If set, shr will not render tags with attribute 'aria-hidden="true"'.
699This attribute is meant to tell screen readers to ignore a tag. 699This attribute is meant to tell screen readers to ignore a tag.
700 700
701*** 'shr-tag-ol' now respects the ordered list 'start' attribute.
702
701** Htmlfontify 703** Htmlfontify
702 704
703*** The functions 'hfy-color', 'hfy-color-vals' and 705*** The functions 'hfy-color', 'hfy-color-vals' and
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 94d68faf2a8..2f628e1caa2 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1755,7 +1755,14 @@ The preference is a float determined from `shr-prefer-media-type'."
1755 1755
1756(defun shr-tag-ol (dom) 1756(defun shr-tag-ol (dom)
1757 (shr-ensure-paragraph) 1757 (shr-ensure-paragraph)
1758 (let ((shr-list-mode 1)) 1758 (let* ((attrs (dom-attributes dom))
1759 (start-attr (alist-get 'start attrs))
1760 ;; Start at 1 if there is no start attribute
1761 ;; or if start can't be parsed as an integer.
1762 (start-index (condition-case _
1763 (cl-parse-integer start-attr)
1764 (t 1)))
1765 (shr-list-mode start-index))
1759 (shr-generic dom)) 1766 (shr-generic dom))
1760 (shr-ensure-paragraph)) 1767 (shr-ensure-paragraph))
1761 1768
diff --git a/test/data/shr/ol.html b/test/data/shr/ol.html
new file mode 100644
index 00000000000..f9a15f26409
--- /dev/null
+++ b/test/data/shr/ol.html
@@ -0,0 +1,29 @@
1<ol>
2 <li>one</li>
3 <li>two</li>
4 <li>three</li>
5</ol>
6
7<ol start="10">
8 <li>ten</li>
9 <li>eleven</li>
10 <li>twelve</li>
11</ol>
12
13<ol start="0">
14 <li>zero</li>
15 <li>one</li>
16 <li>two</li>
17</ol>
18
19<ol start="-5">
20 <li>minus five</li>
21 <li>minus four</li>
22 <li>minus three</li>
23</ol>
24
25<ol start="notanumber">
26 <li>one</li>
27 <li>two</li>
28 <li>three</li>
29</ol>
diff --git a/test/data/shr/ol.txt b/test/data/shr/ol.txt
new file mode 100644
index 00000000000..0d46e2a8ddb
--- /dev/null
+++ b/test/data/shr/ol.txt
@@ -0,0 +1,19 @@
11 one
22 two
33 three
4
510 ten
611 eleven
712 twelve
8
90 zero
101 one
112 two
12
13-5 minus five
14-4 minus four
15-3 minus three
16
171 one
182 two
193 three