[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/htmlize 0a73b2b 043/134: Change `insert-text' method to `t
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/htmlize 0a73b2b 043/134: Change `insert-text' method to `text-markup', so that the text can be |
Date: |
Sat, 7 Aug 2021 09:17:03 -0400 (EDT) |
branch: elpa/htmlize
commit 0a73b2ba70ab7776950540ab359852a9cdaee87e
Author: Hrvoje Niksic <hniksic@gmail.com>
Commit: Hrvoje Niksic <hniksic@gmail.com>
Change `insert-text' method to `text-markup', so that the text can be
separately inserted.
---
htmlize.el | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/htmlize.el b/htmlize.el
index a85bcc0..588e500 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -1258,18 +1258,21 @@ it's called with the same value of KEY. All other
times, the cached
(insert htmlize-hyperlink-style
" -->\n </style>\n"))
-(defun htmlize-css-insert-text (text fstruct-list buffer)
- ;; Insert TEXT colored with FACES into BUFFER. In CSS mode, this is
- ;; easy: just nest the text in one <span class=...> tag for each
- ;; face in FSTRUCT-LIST.
+(defun htmlize-css-text-markup (fstruct-list buffer)
+ ;; Open the markup needed to insert text colored with FACES into
+ ;; BUFFER. Return the function that closes the markup.
+
+ ;; In CSS mode, this is easy: just nest the text in one <span
+ ;; class=...> tag for each face in FSTRUCT-LIST.
(dolist (fstruct fstruct-list)
(princ "<span class=\"" buffer)
(princ (htmlize-fstruct-css-name fstruct) buffer)
(princ "\">" buffer))
- (princ text buffer)
- (dolist (fstruct fstruct-list)
- (ignore fstruct) ; shut up the byte-compiler
- (princ "</span>" buffer)))
+ (lexical-let ((fstruct-list fstruct-list) (buffer buffer))
+ (lambda ()
+ (dolist (fstruct fstruct-list)
+ (ignore fstruct) ; shut up the byte-compiler
+ (princ "</span>" buffer)))))
;; `inline-css' output support.
@@ -1278,7 +1281,7 @@ it's called with the same value of KEY. All other times,
the cached
(mapconcat #'identity (htmlize-css-specs (gethash 'default face-map))
" ")))
-(defun htmlize-inline-css-insert-text (text fstruct-list buffer)
+(defun htmlize-inline-css-text-markup (fstruct-list buffer)
(let* ((merged (htmlize-merge-faces fstruct-list))
(style (htmlize-memoize
merged
@@ -1289,9 +1292,10 @@ it's called with the same value of KEY. All other
times, the cached
(princ "<span style=\"" buffer)
(princ style buffer)
(princ "\">" buffer))
- (princ text buffer)
- (when style
- (princ "</span>" buffer))))
+ (lexical-let ((style style) (buffer buffer))
+ (lambda ()
+ (when style
+ (princ "</span>" buffer))))))
;;; `font' tag based output support.
@@ -1301,7 +1305,7 @@ it's called with the same value of KEY. All other times,
the cached
(htmlize-fstruct-foreground fstruct)
(htmlize-fstruct-background fstruct))))
-(defun htmlize-font-insert-text (text fstruct-list buffer)
+(defun htmlize-font-insert-text (fstruct-list buffer)
;; In `font' mode, we use the traditional HTML means of altering
;; presentation: <font> tag for colors, <b> for bold, <u> for
;; underline, and <strike> for strike-through.
@@ -1322,9 +1326,12 @@ it's called with the same value of KEY. All other
times, the cached
(and (htmlize-fstruct-boldp merged) "</b>")
(and (htmlize-fstruct-foreground merged)
"</font>"))))))
(princ (car markup) buffer)
- (princ text buffer)
- (princ (cdr markup) buffer)))
+ (lexical-let ((markup markup) (buffer buffer))
+ (lambda ()
+ (princ (cdr markup) buffer)))))
+;; XXX kill htmlbuf if an error occurs
+
(defun htmlize-buffer-1 ()
;; Internal function; don't call it from outside this file. Htmlize
;; current buffer, writing the resulting HTML to a new buffer, and
@@ -1377,11 +1384,11 @@ it's called with the same value of KEY. All other
times, the cached
"\n ")
(put places 'content-start (point-marker))
(insert "<pre>\n"))
- (let ((insert-text-method
+ (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 'insert-text))
+ (htmlize-method-function 'text-markup))
;; Declare variables used in loop body outside the loop
;; because it's faster to establish `let' bindings only
;; once.
@@ -1409,7 +1416,9 @@ it's called with the same value of KEY. All other times,
the cached
(when (> (length text) 0)
;; Insert the text, along with the necessary markup to
;; represent faces in FSTRUCT-LIST.
- (funcall insert-text-method text fstruct-list htmlbuf))
+ (let ((close (funcall text-markup fstruct-list htmlbuf)))
+ (princ text htmlbuf)
+ (funcall close)))
(goto-char next-change)))
;; Insert the epilog and post-process the buffer.
- [nongnu] elpa/htmlize 5dbea0b 079/134: Convert the auto-link-creation machinery to use the `htmlize-link' property., (continued)
- [nongnu] elpa/htmlize 5dbea0b 079/134: Convert the auto-link-creation machinery to use the `htmlize-link' property., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize bad6391 082/134: Look for PROP., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 380ba4b 084/134: Bumped version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 5b29cde 090/134: Update NEWS., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 7eb326a 099/134: Fix package header format, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 4570d0a 103/134: Add README., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 8f46e10 105/134: Use htmlpreview., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 78318a2 114/134: Support face-remapping-alist. (#13), ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 9b49540 133/134: Replace cl with cl-lib, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize a040bdd 127/134: Don't try to call color-instance-rgb-components., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 0a73b2b 043/134: Change `insert-text' method to `text-markup', so that the text can be,
ELPA Syncer <=
- [nongnu] elpa/htmlize ec862a1 049/134: Get rid of byte-compiler warnings., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 3308bf9 052/134: Preserve the `display' property during untabification., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 62020d5 054/134: Fix erroneous comment., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize ef8b865 055/134: Add some docs., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 148ac7d 061/134: Consistently eliminate unnecessary string creation in (apply #'concat ...)., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 3faeac8 069/134: Explicitly mark sort as stable., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize af69752 062/134: Consistently handle the multitude of ways to specify the `face' property., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 0ba773b 067/134: Specify some `rgb.txt' locations that actually exist!, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 6baf891 070/134: Implement customizable image transformation, htmlize-force-inline-images, and image alt text., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize ba5ddf3 073/134: Enable edebug stepping into htmlize-lexlet., ELPA Syncer, 2021/08/07