emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master b13d6f2: Don't collect strings existing out of <tr>


From: Katsumi Yamaoka
Subject: [Emacs-diffs] master b13d6f2: Don't collect strings existing out of <tr>...</tr>
Date: Mon, 21 Nov 2016 08:21:48 +0000 (UTC)

branch: master
commit b13d6f2c397419688374f95c99a55d077312ca94
Author: Katsumi Yamaoka <address@hidden>
Commit: Katsumi Yamaoka <address@hidden>

    Don't collect strings existing out of <tr>...</tr>
    
    * lisp/net/shr.el (shr-collect-extra-strings-in-table):
    Don't collect strings existing out of <tr>...</tr> to avoid
    duplication with what `shr-tag-table' renders.
---
 lisp/net/shr.el |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index f1b0087..75e5580 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1899,20 +1899,21 @@ The preference is a float determined from 
`shr-prefer-media-type'."
     (when (zerop shr-table-depth)
       (save-excursion
        (shr-expand-alignments start (point)))
-      (save-restriction
-       (narrow-to-region (point) (point))
-       (insert (mapconcat #'identity
-                          (shr-collect-extra-strings-in-table dom)
-                          "\n"))
-       (shr-fill-lines (point-min) (point-max))))))
+      (let ((strings (shr-collect-extra-strings-in-table dom)))
+       (when strings
+         (save-restriction
+           (narrow-to-region (point) (point))
+           (insert (mapconcat #'identity strings "\n"))
+           (shr-fill-lines (point-min) (point-max))))))))
 
 (defun shr-collect-extra-strings-in-table (dom &optional flags)
   "Return extra strings in DOM of which the root is a table clause.
 Render <img>s and <object>s, and strings and child <table>s of which
-the parent is not <td> or <th> as well.  FLAGS is a cons of two
-boolean flags that control whether to collect or render objects."
-  ;; As for strings and child <table>s, it runs recursively and
-  ;; collects or renders those objects if the cdr of FLAGS is nil.
+the parent <td> or <th> is lacking.  FLAGS is a cons of two boolean
+flags that control whether to collect or render objects."
+  ;; This function runs recursively and collects strings if the cdr of
+  ;; FLAGS is nil and the car is not nil, and it renders also child
+  ;; <table>s if the cdr is nil.  Note: FLAGS may be nil, not a cons.
   ;; FLAGS becomes (t . nil) if a <tr> clause is found in the children
   ;; of DOM, and becomes (t . t) if a <td> or a <th> clause is found
   ;; and the car is t then.  When a <table> clause is found, FLAGS
@@ -1921,7 +1922,7 @@ boolean flags that control whether to collect or render 
objects."
   (cl-loop for child in (dom-children dom) with recurse with tag
           do (setq recurse nil)
           if (stringp child)
-            unless (cdr flags)
+            unless (or (not (car flags)) (cdr flags))
               when (string-match "\\(?:[^\t\n\r ]+[\t\n\r ]+\\)*[^\t\n\r ]+"
                                  child)
                 collect (match-string 0 child)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]