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

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

[nongnu] elpa/htmlize 3dfd7c9 044/134: Insert multiple runs having the s


From: ELPA Syncer
Subject: [nongnu] elpa/htmlize 3dfd7c9 044/134: Insert multiple runs having the same fstruct-list with the same HTML markup.
Date: Sat, 7 Aug 2021 09:17:03 -0400 (EDT)

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

    Insert multiple runs having the same fstruct-list with the same HTML markup.
---
 htmlize.el | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/htmlize.el b/htmlize.el
index 588e500..05e5cb1 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -1385,14 +1385,16 @@ it's called with the same value of KEY.  All other 
times, the cached
        (put places 'content-start (point-marker))
        (insert "<pre>\n"))
       (let ((text-markup
-            ;; Get the inserter method, so we can funcall it inside
-            ;; the loop.  Not calling `htmlize-method' in the loop
-            ;; body yields a measurable speed increase.
-            (htmlize-method-function 'text-markup))
-           ;; Declare variables used in loop body outside the loop
-           ;; because it's faster to establish `let' bindings only
-           ;; once.
-           next-change text face-list fstruct-list trailing-ellipsis)
+             ;; Get the inserter method, so we can funcall it inside
+             ;; the loop.  Not calling `htmlize-method' in the loop
+             ;; body yields a measurable speed increase.
+             (htmlize-method-function 'text-markup))
+            ;; Declare variables used in loop body outside the loop
+            ;; because it's faster to establish `let' bindings only
+            ;; once.
+            next-change text face-list trailing-ellipsis
+            fstruct-list last-fstruct-list
+            (close-markup (lambda ())))
        ;; This loop traverses and reads the source buffer, appending
        ;; the resulting HTML to HTMLBUF.  This method is fast
        ;; because: 1) it doesn't require examining the text
@@ -1414,12 +1416,19 @@ it's called with the same value of KEY.  All other 
times, the cached
          ;; Don't bother writing anything if there's no text (this
          ;; happens in invisible regions).
          (when (> (length text) 0)
+
            ;; Insert the text, along with the necessary markup to
            ;; represent faces in FSTRUCT-LIST.
-            (let ((close (funcall text-markup fstruct-list htmlbuf)))
-              (princ text htmlbuf)
-              (funcall close)))
-         (goto-char next-change)))
+
+            (when (not (equalp fstruct-list last-fstruct-list))
+              (funcall close-markup)
+              (setq last-fstruct-list fstruct-list
+                    close-markup (funcall text-markup fstruct-list htmlbuf)))
+            (princ text htmlbuf)
+            )
+         (goto-char next-change))
+
+        (funcall close-markup))
 
       ;; Insert the epilog and post-process the buffer.
       (with-current-buffer htmlbuf



reply via email to

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