]> code.delx.au - gnu-emacs/blobdiff - lisp/net/shr.el
Fix links in tables in shr
[gnu-emacs] / lisp / net / shr.el
index 868af3837a908f2d54532fbc710a8aab4ff1ec22..ec30d7e18560a140af0acdaa2e531b9783264a61 100644 (file)
@@ -152,7 +152,6 @@ cid: URL as the argument.")
 (defvar shr-ignore-cache nil)
 (defvar shr-external-rendering-functions nil)
 (defvar shr-target-id nil)
-(defvar shr-inhibit-decoration nil)
 (defvar shr-table-separator-length 1)
 (defvar shr-table-separator-pixel-width 0)
 (defvar shr-table-id nil)
@@ -178,7 +177,7 @@ cid: URL as the argument.")
 
 ;; Public functions and commands.
 (declare-function libxml-parse-html-region "xml.c"
-                 (start end &optional base-url))
+                 (start end &optional base-url discard-comments))
 
 (defun shr-render-buffer (buffer)
   "Display the HTML rendering of the current buffer."
@@ -495,7 +494,15 @@ size, and full-buffer size."
     (insert "\n"))
   (cond
    ((eq shr-folding-mode 'none)
-    (insert text))
+    (let ((start (point)))
+      (insert text)
+      (save-restriction
+       (narrow-to-region start (point))
+       ;; Remove soft hyphens.
+       (goto-char (point-min))
+       (while (search-forward "­" nil t)
+         (replace-match "" t t))
+       (goto-char (point-max)))))
    (t
     (let ((font-start (point)))
       (when (and (string-match "\\`[ \t\n\r ]" text)
@@ -701,6 +708,9 @@ size, and full-buffer size."
          shr-base))
   (when (zerop (length url))
     (setq url nil))
+  ;; Strip leading whitespace
+  (and url (string-match "\\`\\s-+" url)
+       (setq url (substring url (match-end 0))))
   (cond ((or (not url)
             (not base)
             (string-match "\\`[a-z]*:" url))
@@ -772,16 +782,15 @@ size, and full-buffer size."
 ;; blank text at the start of the line, and the newline at the end, to
 ;; avoid ugliness.
 (defun shr-add-font (start end type)
-  (unless shr-inhibit-decoration
-    (save-excursion
-      (goto-char start)
-      (while (< (point) end)
-       (when (bolp)
-         (skip-chars-forward " "))
-       (add-face-text-property (point) (min (line-end-position) end) type t)
-       (if (< (line-end-position) end)
-           (forward-line 1)
-         (goto-char end))))))
+  (save-excursion
+    (goto-char start)
+    (while (< (point) end)
+      (when (bolp)
+        (skip-chars-forward " "))
+      (add-face-text-property (point) (min (line-end-position) end) type t)
+      (if (< (line-end-position) end)
+          (forward-line 1)
+        (goto-char end)))))
 
 (defun shr-mouse-browse-url (ev)
   "Browse the URL under the mouse cursor."
@@ -1030,8 +1039,7 @@ ones, in case fg and bg are nil."
                (shr-color-visible bg fg)))))))
 
 (defun shr-colorize-region (start end fg &optional bg)
-  (when (and (not shr-inhibit-decoration)
-            (or fg bg))
+  (when (or fg bg)
     (let ((new-colors (shr-color-check fg bg)))
       (when new-colors
        (when fg
@@ -1201,8 +1209,7 @@ ones, in case fg and bg are nil."
        (shr-ensure-newline)
        (insert " "))
       (put-text-property start (1+ start) 'shr-target-id shr-target-id))
-    (when (and url
-              (not shr-inhibit-decoration))
+    (when url
       (shr-urlify (or shr-start start) (shr-expand-url url) title))))
 
 (defun shr-tag-object (dom)
@@ -1794,7 +1801,6 @@ The preference is a float determined from `shr-prefer-media-type'."
 
 (defun shr-make-table-1 (dom widths &optional fill)
   (let ((trs nil)
-       (shr-inhibit-decoration (not fill))
        (rowspans (make-vector (length widths) 0))
        (colspan-remaining 0)
        colspan-width colspan-count