(dom-texts): Don't return contents of <script> as text

From: Lars Ingebrigtsen <larsi@gnus.org>

* lisp/dom.el (dom-texts): Don't return contents of <script> as
text, because it isn't and makes reasoning about textual parts
more difficult.
This commit is contained in:
Lars Ingebrigtsen 2018-04-13 00:11:47 +02:00
parent 3d6fa0b1e0
commit 254f5021aa

View file

@ -78,15 +78,21 @@ A typical attribute is `href'."
(defun dom-texts (node &optional separator)
"Return all textual data under NODE concatenated with SEPARATOR in-between."
(mapconcat
'identity
(mapcar
(lambda (elem)
(if (stringp elem)
elem
(dom-texts elem separator)))
(dom-children node))
(or separator " ")))
(if (eq (dom-tag node) 'script)
""
(mapconcat
'identity
(mapcar
(lambda (elem)
(cond
((stringp elem)
elem)
((eq (dom-tag elem) 'script)
"")
(t
(dom-texts elem separator))))
(dom-children node))
(or separator " "))))
(defun dom-child-by-tag (dom tag)
"Return the first child of DOM that is of type TAG."