(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:
parent
3d6fa0b1e0
commit
254f5021aa
1 changed files with 15 additions and 9 deletions
24
lisp/dom.el
24
lisp/dom.el
|
|
@ -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."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue