aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-04-13 00:11:47 +0200
committerLars Ingebrigtsen2018-04-13 00:14:32 +0200
commit254f5021aa75c161c964bd5f31b957d69814f38f (patch)
treed9af7afae790d83f4367ea149ba569c6c9c3e58f
parent3d6fa0b1e085a987588d5b3a54d91abfee42ceea (diff)
downloademacs-254f5021aa75c161c964bd5f31b957d69814f38f.tar.gz
emacs-254f5021aa75c161c964bd5f31b957d69814f38f.zip
(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.
-rw-r--r--lisp/dom.el24
1 files changed, 15 insertions, 9 deletions
diff --git a/lisp/dom.el b/lisp/dom.el
index 8750d7fa866..6045a68d14c 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -78,15 +78,21 @@ A typical attribute is `href'."
78 78
79(defun dom-texts (node &optional separator) 79(defun dom-texts (node &optional separator)
80 "Return all textual data under NODE concatenated with SEPARATOR in-between." 80 "Return all textual data under NODE concatenated with SEPARATOR in-between."
81 (mapconcat 81 (if (eq (dom-tag node) 'script)
82 'identity 82 ""
83 (mapcar 83 (mapconcat
84 (lambda (elem) 84 'identity
85 (if (stringp elem) 85 (mapcar
86 elem 86 (lambda (elem)
87 (dom-texts elem separator))) 87 (cond
88 (dom-children node)) 88 ((stringp elem)
89 (or separator " "))) 89 elem)
90 ((eq (dom-tag elem) 'script)
91 "")
92 (t
93 (dom-texts elem separator))))
94 (dom-children node))
95 (or separator " "))))
90 96
91(defun dom-child-by-tag (dom tag) 97(defun dom-child-by-tag (dom tag)
92 "Return the first child of DOM that is of type TAG." 98 "Return the first child of DOM that is of type TAG."