]> git.eshelyaron.com Git - emacs.git/commitdiff
(dom-texts): Don't return contents of <script> as text
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 12 Apr 2018 22:11:47 +0000 (00:11 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 12 Apr 2018 22:14:32 +0000 (00:14 +0200)
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.

lisp/dom.el

index 8750d7fa86639ee635ebdc176739af60e5f92d1a..6045a68d14c2ef11ff8585f8eca89e30b385baba 100644 (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."