-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.xml
88 lines (79 loc) · 8.37 KB
/
index.xml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Klaus Alexander Seistrup</title>
<link>https://kseistrup.github.io/</link>
<description>Recent content on Klaus Alexander Seistrup</description>
<generator>Hugo -- gohugo.io</generator>
<language>en</language>
<copyright>© 2015 Klaus Alexander Seistrup</copyright>
<lastBuildDate>Fri, 07 Aug 2015 19:41:35 +0200</lastBuildDate>
<atom:link href="https://kseistrup.github.io/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Syntax highlighting</title>
<link>https://kseistrup.github.io/post/test-syntax-highlighting/</link>
<pubDate>Fri, 07 Aug 2015 19:41:35 +0200</pubDate>
<guid>https://kseistrup.github.io/post/test-syntax-highlighting/</guid>
<description><p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis
præsentium voluptatum deleniti atque corrupti quos dolores et quas molestias
excepturi sint occæcati cupiditate non provident, similique sunt in culpa
qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et
harum quidem rerum facilis est et expedita distinctio. Nam libero tempore,
cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod
maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor
repellendus.</p>
<p>Let&rsquo;s see if syntax highlighting works:</p>
<p><div class="highlight" style="background: #ffffff"><pre style="line-height: 125%"><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 1 </span><span style="color: #008800; font-weight: bold">def</span> <span style="color: #0066BB; font-weight: bold">src</span>(obj):
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 2 </span> <span style="color: #DD4422">&quot;&quot;&quot;Read the source of an object in the interpreter.&quot;&quot;&quot;</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 3 </span> <span style="color: #008800; font-weight: bold">def</span> <span style="color: #0066BB; font-weight: bold">highlight</span>(source):
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 4 </span> <span style="color: #008800; font-weight: bold">try</span>:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 5 </span> <span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">pygments</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 6 </span> <span style="color: #008800; font-weight: bold">from</span> <span style="color: #0e84b5; font-weight: bold">pygments.lexers</span> <span style="color: #008800; font-weight: bold">import</span> get_lexer_by_name
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 7 </span> <span style="color: #008800; font-weight: bold">from</span> <span style="color: #0e84b5; font-weight: bold">pygments.formatters.terminal</span> <span style="color: #008800; font-weight: bold">import</span> TerminalFormatter
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 8 </span> <span style="color: #008800; font-weight: bold">except</span> <span style="color: #FF0000; font-weight: bold">ImportError</span>:
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 9 </span> <span style="color: #008800; font-weight: bold">return</span> source
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">10 </span> <span style="color: #008800; font-weight: bold">return</span> pygments<span style="color: #333333">.</span>highlight(
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">11 </span> source,
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">12 </span> get_lexer_by_name(<span style="background-color: #fff0f0">&#39;python&#39;</span>),
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">13 </span> TerminalFormatter()
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">14 </span> )
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">15 </span> <span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">inspect</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">16 </span> <span style="color: #008800; font-weight: bold">import</span> <span style="color: #0e84b5; font-weight: bold">subprocess</span>
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">17 </span> source <span style="color: #333333">=</span> inspect<span style="color: #333333">.</span>getsource(obj)
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">18 </span> pager <span style="color: #333333">=</span> subprocess<span style="color: #333333">.</span>Popen((<span style="background-color: #fff0f0">&#39;less&#39;</span>, <span style="background-color: #fff0f0">&#39;-R&#39;</span>), stdin<span style="color: #333333">=</span>subprocess<span style="color: #333333">.</span>PIPE)
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">19 </span> pager<span style="color: #333333">.</span>communicate(highlight(source)<span style="color: #333333">.</span>encode(<span style="background-color: #fff0f0">&#39;utf-8&#39;</span>))
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">20 </span> pager<span style="color: #333333">.</span>wait()
</pre></div>
</p>
<p>😋</p>
</description>
</item>
<item>
<title>Lorem ipsum</title>
<link>https://kseistrup.github.io/ipsum/</link>
<pubDate>Tue, 04 Aug 2015 21:16:44 +0200</pubDate>
<guid>https://kseistrup.github.io/ipsum/</guid>
<description><p>Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium
doloremque laudantium, totam rem aperiam eaque ipsa, quæ ab illo inventore
veritatis et quasi architecto beatæ vitæ dicta sunt, explicabo. Nemo enim
ipsam voluptatem, quia voluptas sit, aspernatur aut odit aut fugit, sed quia
consequuntur magni dolores eos, qui ratione voluptatem sequi nesciunt, neque
porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur,
adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore
et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis
nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid
ex ea commodi consequatur? Quis autem vel eum iure reprehenderit, qui in ea
voluptate velit esse, quam nihil molestiæ consequatur, vel illum, qui
dolorem eum fugiat, quo voluptas nulla pariatur?</p>
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis
præsentium voluptatum deleniti atque corrupti quos dolores et quas molestias
excepturi sint occæcati cupiditate non provident, similique sunt in culpa
qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et
harum quidem rerum facilis est et expedita distinctio. Nam libero tempore,
cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod
maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor
repellendus.</p>
</description>
</item>
</channel>
</rss>