emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/htmlize 67b8bf3 086/134: Implement form feed replacement w


From: ELPA Syncer
Subject: [nongnu] elpa/htmlize 67b8bf3 086/134: Implement form feed replacement with <hr/> as a temporary overlay with
Date: Sat, 7 Aug 2021 09:17:12 -0400 (EDT)

branch: elpa/htmlize
commit 67b8bf39a80df2847ca2244735986ff42fb71c92
Author: Hrvoje Niksic <hniksic@gmail.com>
Commit: Hrvoje Niksic <hniksic@gmail.com>

    Implement form feed replacement with <hr/> as a temporary overlay with
    the `display' property.
---
 htmlize.el | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/htmlize.el b/htmlize.el
index 4340d1c..8119fbe 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -833,6 +833,13 @@ This is used to protect mailto links without modifying 
their meaning."
 ;; <hniksic@xemacs.org>
 ;; <xalan-dev-sc.10148567319.hacuhiucknfgmpfnjcpg-john=doe.com@xml.apache.org>
 
+(defun htmlize-shadow-form-feeds ()
+  (let ((s "\n<hr />"))
+    (put-text-property 0 (length s) 'htmlize-literal t s)
+    (let ((disp `(display ,s)))
+      (while (re-search-forward "\n\^L" nil t)
+        (htmlize-make-tmp-overlay (match-beginning 0) (match-end 0) disp)))))
+
 (defun htmlize-defang-local-variables ()
   ;; Juri Linkov reports that an HTML-ized "Local variables" can lead
   ;; visiting the HTML to fail with "Local variables list is not
@@ -1609,6 +1616,8 @@ it's called with the same value of KEY.  All other times, 
the cached
                           (buffer-name))))
             (when htmlize-generate-hyperlinks
               (htmlize-create-auto-links))
+            (when htmlize-replace-form-feeds
+              (htmlize-shadow-form-feeds))
 
             ;; Initialize HTMLBUF and insert the HTML prolog.
             (with-current-buffer htmlbuf
@@ -1687,18 +1696,6 @@ it's called with the same value of KEY.  All other 
times, the cached
               (put places 'body-end (point-marker))
               (insert "\n</html>\n")
               (htmlize-defang-local-variables)
-              (when htmlize-replace-form-feeds
-                ;; Change each "\n^L" to "<hr />".
-                (goto-char (point-min))
-                (let ((source
-                       ;; ^L has already been escaped, so search for that.
-                       (htmlize-protect-string "\n\^L"))
-                      (replacement
-                       (if (stringp htmlize-replace-form-feeds)
-                           htmlize-replace-form-feeds
-                         "</pre><hr /><pre>")))
-                  (while (search-forward source nil t)
-                    (replace-match replacement t t))))
               (goto-char (point-min))
               (when htmlize-html-major-mode
                 ;; What sucks about this is that the minor modes, most notably



reply via email to

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