[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/htmlize a0b55cb 112/134: Introduced option for styling <pr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/htmlize a0b55cb 112/134: Introduced option for styling <pre>, "screenshot" function. |
Date: |
Sat, 7 Aug 2021 09:17:18 -0400 (EDT) |
branch: elpa/htmlize
commit a0b55cba65a225df8d9e17a3ac448ce9e8ec962d
Author: Tamas K. Papp <tkpapp@gmail.com>
Commit: Hrvoje Nikšić <hniksic@gmail.com>
Introduced option for styling <pre>, "screenshot" function.
This makes inline-css and font decoration for <pre> optional, and
disabled by default, preserving the original behavior before this PR.
A new function htmlize-region-save-screenshot turns this on and saves
the resulting HTML in the kill ring (which is most convenient for
pasting into blog posts etc). This should allow a best approximation
for capturing "screenshots" of a region in HTML.
---
htmlize.el | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/htmlize.el b/htmlize.el
index 8abf183..71bf0fb 100644
--- a/htmlize.el
+++ b/htmlize.el
@@ -314,6 +314,13 @@ Set this to nil if you prefer the default (fundamental)
mode."
(function :tag "User-defined major mode"))
:group 'htmlize)
+(defcustom htmlize-pre-style nil
+ "When non-nil, `<pre>' tags will be decorated with style
+information in `font' and `inline-css' modes. This allows a
+consistent background for captures of regions."
+ :type 'boolean
+ :group 'htmlize)
+
(defvar htmlize-before-hook nil
"Hook run before htmlizing a buffer.
The hook functions are run in the source buffer (not the resulting HTML
@@ -1557,9 +1564,11 @@ it's called with the same value of KEY. All other
times, the cached
" ")))
(defun htmlize-inline-css-pre-tag (face-map)
- (format "<pre style=\"%s\">"
- (mapconcat #'identity (htmlize-css-specs (gethash 'default face-map))
- " ")))
+ (if htmlize-pre-style
+ (format "<pre style=\"%s\">"
+ (mapconcat #'identity (htmlize-css-specs (gethash 'default
face-map))
+ " "))
+ (format "<pre>")))
(defun htmlize-inline-css-text-markup (fstruct-list buffer)
(let* ((merged (htmlize-merge-faces fstruct-list))
@@ -1586,10 +1595,12 @@ it's called with the same value of KEY. All other
times, the cached
(htmlize-fstruct-background fstruct))))
(defun htmlize-font-pre-tag (face-map)
- (let ((fstruct (gethash 'default face-map)))
- (format "<pre text=\"%s\" bgcolor=\"%s\">"
- (htmlize-fstruct-foreground fstruct)
- (htmlize-fstruct-background fstruct))))
+ (if htmlize-pre-style
+ (let ((fstruct (gethash 'default face-map)))
+ (format "<pre text=\"%s\" bgcolor=\"%s\">"
+ (htmlize-fstruct-foreground fstruct)
+ (htmlize-fstruct-background fstruct)))
+ (format "<pre>")))
(defun htmlize-font-text-markup (fstruct-list buffer)
;; In `font' mode, we use the traditional HTML means of altering
@@ -1836,6 +1847,16 @@ the text to another HTML buffer."
(plist-get htmlize-buffer-places 'content-end)))
(kill-buffer htmlbuf))))
+(defun htmlize-region-save-screenshot (beg end)
+ "Save the htmlized (see `htmlize-region-for-paste') region in
+the kill ring. Uses `inline-css', with style information in
+`<pre>' tags, so that the rendering of the marked up text
+approximates the buffer as closely as possible."
+ (interactive "r")
+ (let ((htmlize-pre-style t))
+ (kill-new (htmlize-region-for-paste beg end)))
+ (deactivate-mark))
+
(defun htmlize-make-file-name (file)
"Make an HTML file name from FILE.
- [nongnu] elpa/htmlize a6f9f07 066/134: Decide at each macroexpansion whether to use `lexical-let' or `let'., (continued)
- [nongnu] elpa/htmlize a6f9f07 066/134: Decide at each macroexpansion whether to use `lexical-let' or `let'., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 58775c8 064/134: Improve introductory text., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize db4b76e 076/134: New file: NEWS, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 87d4a43 080/134: Recognize tmp overlays with an overlay property., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 67b8bf3 086/134: Implement form feed replacement with <hr/> as a temporary overlay with, ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 9e4c0bc 089/134: Faces that come first take precedence over those that come later., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 5d9be53 093/134: Bumped version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize ece5b5f 095/134: Bumped version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 974c169 098/134: Set `lexical-binding' to `t' in the first line of the file., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 8593a5e 111/134: Put style information in <pre> tags., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize a0b55cb 112/134: Introduced option for styling <pre>, "screenshot" function.,
ELPA Syncer <=
- [nongnu] elpa/htmlize 133ac35 115/134: Remove XEmacs support., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 75c21c7 116/134: Use `font-lock-ensure' where available. (#14), ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 315a8f2 121/134: htmlize-sorted-overlays-at: correctly initialize OVERLAYS. (#18), ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize e01bb6f 123/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize d6dc274 125/134: Remove unused function., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize b9789ba 126/134: Don't warn on the use of font-lock-fontify-buffer in older Emacsen., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 682edbf 130/134: Mention the orgmode mirror., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 4920510 134/134: Fix more cl symbols., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 7b63aa0 131/134: Bump version., ELPA Syncer, 2021/08/07
- [nongnu] elpa/htmlize 567d55c 124/134: Don't convert ^L to <hr/> in invisible text., ELPA Syncer, 2021/08/07