-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtmlize.html
61 lines (60 loc) · 4.61 KB
/
htmlize.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="alternate"
type="application/rss+xml"
href="https://ragone.io/rss.xml"
title="RSS feed for https://ragone.io/"/>
<title>htmlize.el</title>
<meta name="author" content="ragone" />
<link href= "static/style.css" rel="stylesheet" type="text/css" />
<link href= "static/htmlize.css" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1,width=device-width,minimum-scale=1"></head>
<body>
<div id="preamble" class="status">
<header>
<a href="index.html"><code>Alex Ragone</code></a>
<nav>
<a title="Projects" href="tag-projects.html">Projects</a>
<a title="LinkedIn" href="https://www.linkedin.com/in/alex-ragone" target="_blank" rel="noopener">LinkedIn</a>
<a title="Github" href="https://github.com/ragone" target="_blank" rel="noopener">Github</a>
</nav>
</header></div>
<div id="content">
<div class="headline"> <h1 class="post-title"><a href="htmlize.html">htmlize.el</a></h1>
<div class="taglist">:<a href="tag-emacs.html">emacs</a>:<a href="tag-snippets.html">snippets</a>:</div></div><div class="post-date"><2019-05-23 Thu></div><p>
Quickly copy an image of a htmlized buffer or region to the clipboard.
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">(<span class="org-keyword">defun</span> <span class="org-function-name">ragone-htmlize</span> (<span class="org-parinfer-pretty-parensXdim-paren">)</span>
<span class="org-doc">"Convert the htmlized region to an image and copy to clipboard."</span>
(<span class="org-keyword">interactive</span><span class="org-parinfer-pretty-parensXdim-paren">)</span>
(<span class="org-keyword">let</span> ((<span class="org-variable-name">htmlize-pre-style</span> t<span class="org-parinfer-pretty-parensXdim-paren">)</span>
(region-background (<span class="org-function-name">face-attribute</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">region</span> <span class="org-builtin">:background</span><span class="org-parinfer-pretty-parensXdim-paren">))</span>
(start (<span class="org-keyword">if</span> (<span class="org-function-name">region-active-p</span><span class="org-parinfer-pretty-parensXdim-paren">)</span>
(<span class="org-constant">region-beginning</span>) (<span class="org-constant">point-min</span><span class="org-parinfer-pretty-parensXdim-paren">)))</span>
(end (<span class="org-keyword">if</span> (<span class="org-function-name">region-active-p</span><span class="org-parinfer-pretty-parensXdim-paren">)</span>
(<span class="org-constant">region-end</span>) (<span class="org-constant">point-max</span><span class="org-parinfer-pretty-parensXdim-paren">))))</span>
(<span class="org-function-name">set-face-background</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">region</span> <span class="org-string">"unspecified"</span><span class="org-parinfer-pretty-parensXdim-paren">)</span>
(<span class="org-keyword">unwind-protect</span>
(<span class="org-function-name">ragone-htmlize-to-clipboard</span>
(<span class="org-function-name">htmlize-region-for-paste</span> start end<span class="org-parinfer-pretty-parensXdim-paren">))</span>
(<span class="org-function-name">set-face-background</span> <span class="org-highlight-quoted-quote">'</span><span class="org-highlight-quoted-symbol">region</span> region-background<span class="org-parinfer-pretty-parensXdim-paren">))))</span>
(<span class="org-keyword">defun</span> <span class="org-function-name">ragone-htmlize-to-clipboard</span> (html<span class="org-parinfer-pretty-parensXdim-paren">)</span>
<span class="org-doc">"Copy HTML to clipboard."</span>
(<span class="org-keyword">with-temp-buffer</span>
(<span class="org-constant">insert</span> html<span class="org-parinfer-pretty-parensXdim-paren">)</span>
(<span class="org-function-name">call-shell-region</span>
(<span class="org-constant">point-min</span>) (<span class="org-constant">point-max</span><span class="org-parinfer-pretty-parensXdim-paren">)</span>
<span class="org-string">"wkhtmltoimage -f png - - | xclip -i -selection clipboard -t image/png"</span><span class="org-parinfer-pretty-parensXdim-paren">)))</span>
</pre>
</div>
</div>
<div id="postamble" class="status"><div id="archive">
<a href="archive.html">archive</a>
<a href="tags.html">tags</a>
</div></div>
</body>
</html>