|
9 | 9 | <title>Tufte Pandoc CSS</title> |
10 | 10 | <style type="text/css">code{white-space: pre;}</style> |
11 | 11 | <style type="text/css"> |
12 | | -a.sourceLine { display: inline-block; line-height: 1.25; } |
13 | | -a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } |
14 | | -a.sourceLine:empty { height: 1.2em; position: absolute; } |
15 | | -.sourceCode { overflow: visible; } |
16 | | -code.sourceCode { white-space: pre; position: relative; } |
| 12 | +pre > code.sourceCode { white-space: pre; position: relative; } |
| 13 | +pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } |
| 14 | +pre > code.sourceCode > span:empty { height: 1.2em; } |
| 15 | +code.sourceCode > span { color: inherit; text-decoration: inherit; } |
17 | 16 | div.sourceCode { margin: 1em 0; } |
18 | 17 | pre.sourceCode { margin: 0; } |
19 | 18 | @media screen { |
20 | 19 | div.sourceCode { overflow: auto; } |
21 | 20 | } |
22 | 21 | @media print { |
23 | | -code.sourceCode { white-space: pre-wrap; } |
24 | | -a.sourceLine { text-indent: -1em; padding-left: 1em; } |
| 22 | +pre > code.sourceCode { white-space: pre-wrap; } |
| 23 | +pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } |
25 | 24 | } |
26 | | -pre.numberSource a.sourceLine |
27 | | - { position: relative; } |
28 | | -pre.numberSource a.sourceLine:empty |
29 | | - { position: absolute; } |
30 | | -pre.numberSource a.sourceLine::before |
31 | | - { content: attr(data-line-number); |
32 | | - position: absolute; left: -5em; text-align: right; vertical-align: baseline; |
33 | | - border: none; pointer-events: all; |
| 25 | +pre.numberSource code |
| 26 | + { counter-reset: source-line 0; } |
| 27 | +pre.numberSource code > span |
| 28 | + { position: relative; left: -4em; counter-increment: source-line; } |
| 29 | +pre.numberSource code > span > a:first-child::before |
| 30 | + { content: counter(source-line); |
| 31 | + position: relative; left: -1em; text-align: right; vertical-align: baseline; |
| 32 | + border: none; display: inline-block; |
34 | 33 | -webkit-touch-callout: none; -webkit-user-select: none; |
35 | 34 | -khtml-user-select: none; -moz-user-select: none; |
36 | 35 | -ms-user-select: none; user-select: none; |
|
39 | 38 | } |
40 | 39 | pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } |
41 | 40 | div.sourceCode |
42 | | - { } |
| 41 | + { } |
43 | 42 | @media screen { |
44 | | -a.sourceLine::before { text-decoration: underline; } |
| 43 | +pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } |
45 | 44 | } |
46 | 45 | code span.al { color: #ff0000; font-weight: bold; } /* Alert */ |
47 | 46 | code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ |
@@ -107,48 +106,48 @@ <h2>Sidenotes in Markdown</h2> |
107 | 106 | <p>The biggest barrier that this project overcomes is that Pandoc Markdown doesn’t support side notes nor margin notes by default. This project adds that functionality.<span><label for="sn-1" class="margin-toggle sidenote-number"></label><input type="checkbox" id="sn-1" class="margin-toggle"/><span class="sidenote">In particular, a separate library called <a href="https://github.com/jez/pandoc-sidenote"><code>pandoc-sidenote</code></a> handles the transformation of footnotes into sidenotes.<br /> |
108 | 107 | <br /> |
109 | 108 | </span></span> Here’s how you can use them:</p> |
110 | | -<div class="sourceCode" id="cb1"><pre class="sourceCode markdown"><code class="sourceCode markdown"><a class="sourceLine" id="cb1-1" data-line-number="1">... In print, Tufte has used the proprietary Monotype</a> |
111 | | -<a class="sourceLine" id="cb1-2" data-line-number="2">Bembo<span class="ot">[^note]</span> font. ...</a> |
112 | | -<a class="sourceLine" id="cb1-3" data-line-number="3"></a> |
113 | | -<a class="sourceLine" id="cb1-4" data-line-number="4"><span class="ot">[^note]</span>:</a> |
114 | | -<a class="sourceLine" id="cb1-5" data-line-number="5"> See Tufte's comment in the Tufte book fonts thread.</a></code></pre></div> |
| 109 | +<div class="sourceCode" id="cb1"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>... In print, Tufte has used the proprietary Monotype</span> |
| 110 | +<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>Bembo<span class="ot">[^note]</span> font. ...</span> |
| 111 | +<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span> |
| 112 | +<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="ot">[^note]</span>:</span> |
| 113 | +<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> See Tufte's comment in the Tufte book fonts thread.</span></code></pre></div> |
115 | 114 | <p>By default, if you use the normal Pandoc syntax for creating footnotes, they’ll become Tufte CSS-style side notes. To get margin notes (i.e., side notes without numbers), just include <code>{-}</code> at the beginning of the note:</p> |
116 | 115 | <figure class="fullwidth"> |
117 | | -<div class="sourceCode" id="cb2"><pre class="sourceCode markdown"><code class="sourceCode markdown"><a class="sourceLine" id="cb2-1" data-line-number="1">... If you want a sidenote without footnote-style numberings, then you want a</a> |
118 | | -<a class="sourceLine" id="cb2-2" data-line-number="2">margin note.<span class="ot">[^mn]</span> On large screens, ...</a> |
119 | | -<a class="sourceLine" id="cb2-3" data-line-number="3"></a> |
120 | | -<a class="sourceLine" id="cb2-4" data-line-number="4"><span class="ot">[^mn]</span>:</a> |
121 | | -<a class="sourceLine" id="cb2-5" data-line-number="5"> {-} This is a margin note. Notice there isn't a number preceding the note.</a></code></pre></div> |
| 116 | +<div class="sourceCode" id="cb2"><pre class="sourceCode markdown"><code class="sourceCode markdown"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>... If you want a sidenote without footnote-style numberings, then you want a</span> |
| 117 | +<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>margin note.<span class="ot">[^mn]</span> On large screens, ...</span> |
| 118 | +<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span> |
| 119 | +<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="ot">[^mn]</span>:</span> |
| 120 | +<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> {-} This is a margin note. Notice there isn't a number preceding the note.</span></code></pre></div> |
122 | 121 | </figure> |
123 | 122 | </section> |
124 | 123 | <section id="syntax-highlighted-codeblocks" class="level2"> |
125 | 124 | <h2>Syntax-Highlighted Codeblocks</h2> |
126 | 125 | <p>Pandoc Markdown is excellent for styling code blocks. Indeed, you’ve already seen their effect in this document. You can use any of the methods for creating syntax highlighted code blocks Pandoc permits. For example:</p> |
127 | | -<div class="sourceCode" id="cb3"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb3-1" data-line-number="1"><span class="co"># Compute elements of the mandelbrot set</span></a> |
128 | | -<a class="sourceLine" id="cb3-2" data-line-number="2"><span class="kw">def</span> mandelbrot(a):</a> |
129 | | -<a class="sourceLine" id="cb3-3" data-line-number="3"> <span class="cf">return</span> <span class="bu">reduce</span>(<span class="kw">lambda</span> z, _: z <span class="op">*</span> z <span class="op">+</span> a, <span class="bu">range</span>(<span class="dv">50</span>), <span class="dv">0</span>)</a> |
130 | | -<a class="sourceLine" id="cb3-4" data-line-number="4"></a> |
131 | | -<a class="sourceLine" id="cb3-5" data-line-number="5"><span class="kw">def</span> step(start, step, iterations):</a> |
132 | | -<a class="sourceLine" id="cb3-6" data-line-number="6"> <span class="cf">return</span> (start <span class="op">+</span> (i <span class="op">*</span> step) <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(iterations))</a> |
133 | | -<a class="sourceLine" id="cb3-7" data-line-number="7"></a> |
134 | | -<a class="sourceLine" id="cb3-8" data-line-number="8">rows <span class="op">=</span> ((<span class="st">"*"</span> <span class="cf">if</span> <span class="bu">abs</span>(mandelbrot(<span class="bu">complex</span>(x, y))) <span class="op"><</span> <span class="dv">2</span> <span class="cf">else</span> <span class="st">" "</span></a> |
135 | | -<a class="sourceLine" id="cb3-9" data-line-number="9"> <span class="cf">for</span> x <span class="kw">in</span> step(<span class="op">-</span><span class="fl">2.0</span>, <span class="fl">.0315</span>, <span class="dv">80</span>))</a> |
136 | | -<a class="sourceLine" id="cb3-10" data-line-number="10"> <span class="cf">for</span> y <span class="kw">in</span> step(<span class="dv">1</span>, <span class="fl">-.05</span>, <span class="dv">41</span>))</a></code></pre></div> |
| 126 | +<div class="sourceCode" id="cb3"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Compute elements of the mandelbrot set</span></span> |
| 127 | +<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> mandelbrot(a):</span> |
| 128 | +<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="bu">reduce</span>(<span class="kw">lambda</span> z, _: z <span class="op">*</span> z <span class="op">+</span> a, <span class="bu">range</span>(<span class="dv">50</span>), <span class="dv">0</span>)</span> |
| 129 | +<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a></span> |
| 130 | +<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> step(start, step, iterations):</span> |
| 131 | +<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> (start <span class="op">+</span> (i <span class="op">*</span> step) <span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(iterations))</span> |
| 132 | +<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a></span> |
| 133 | +<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>rows <span class="op">=</span> ((<span class="st">"*"</span> <span class="cf">if</span> <span class="bu">abs</span>(mandelbrot(<span class="bu">complex</span>(x, y))) <span class="op"><</span> <span class="dv">2</span> <span class="cf">else</span> <span class="st">" "</span></span> |
| 134 | +<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> x <span class="kw">in</span> step(<span class="op">-</span><span class="fl">2.0</span>, <span class="fl">.0315</span>, <span class="dv">80</span>))</span> |
| 135 | +<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="cf">for</span> y <span class="kw">in</span> step(<span class="dv">1</span>, <span class="op">-</span><span class="fl">.05</span>, <span class="dv">41</span>))</span></code></pre></div> |
137 | 136 | <p>In this document, you’re also seeing the effect of the Solarized color scheme. You can use any of the color schemes Pandoc ships with by default, or this one.</p> |
138 | 137 | <p>Another feature Pandoc allows that Tufte Pandoc CSS supports is generating line numbers to accompany a code sample:</p> |
139 | | -<div class="sourceCode" id="cb4"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><a class="sourceLine" id="cb4-1" data-line-number="1">merge [] ys <span class="fu">=</span> ys</a> |
140 | | -<a class="sourceLine" id="cb4-2" data-line-number="2">merge xs [] <span class="fu">=</span> xs</a> |
141 | | -<a class="sourceLine" id="cb4-3" data-line-number="3">merge xs<span class="fu">@</span>(x<span class="fu">:</span>xt) ys<span class="fu">@</span>(y<span class="fu">:</span>yt) <span class="fu">|</span> x <span class="fu"><=</span> y <span class="fu">=</span> x <span class="fu">:</span> merge xt ys</a> |
142 | | -<a class="sourceLine" id="cb4-4" data-line-number="4"> <span class="fu">|</span> otherwise <span class="fu">=</span> y <span class="fu">:</span> merge xs yt</a> |
143 | | -<a class="sourceLine" id="cb4-5" data-line-number="5"></a> |
144 | | -<a class="sourceLine" id="cb4-6" data-line-number="6">split (x<span class="fu">:</span>y<span class="fu">:</span>zs) <span class="fu">=</span> <span class="kw">let</span> (xs,ys) <span class="fu">=</span> split zs <span class="kw">in</span> (x<span class="fu">:</span>xs,y<span class="fu">:</span>ys)</a> |
145 | | -<a class="sourceLine" id="cb4-7" data-line-number="7">split [x] <span class="fu">=</span> ([x],[])</a> |
146 | | -<a class="sourceLine" id="cb4-8" data-line-number="8">split [] <span class="fu">=</span> ([],[])</a> |
147 | | -<a class="sourceLine" id="cb4-9" data-line-number="9"></a> |
148 | | -<a class="sourceLine" id="cb4-10" data-line-number="10">mergeSort [] <span class="fu">=</span> []</a> |
149 | | -<a class="sourceLine" id="cb4-11" data-line-number="11">mergeSort [x] <span class="fu">=</span> [x]</a> |
150 | | -<a class="sourceLine" id="cb4-12" data-line-number="12">mergeSort xs <span class="fu">=</span> <span class="kw">let</span> (as,bs) <span class="fu">=</span> split xs</a> |
151 | | -<a class="sourceLine" id="cb4-13" data-line-number="13"> <span class="kw">in</span> merge (mergeSort as) (mergeSort bs)</a></code></pre></div> |
| 138 | +<div class="sourceCode" id="cb4"><pre class="sourceCode numberSource haskell numberLines"><code class="sourceCode haskell"><span id="cb4-1"><a href="#cb4-1"></a>merge [] ys <span class="ot">=</span> ys</span> |
| 139 | +<span id="cb4-2"><a href="#cb4-2"></a>merge xs [] <span class="ot">=</span> xs</span> |
| 140 | +<span id="cb4-3"><a href="#cb4-3"></a>merge xs<span class="op">@</span>(x<span class="op">:</span>xt) ys<span class="op">@</span>(y<span class="op">:</span>yt) <span class="op">|</span> x <span class="op"><=</span> y <span class="ot">=</span> x <span class="op">:</span> merge xt ys</span> |
| 141 | +<span id="cb4-4"><a href="#cb4-4"></a> <span class="op">|</span> <span class="fu">otherwise</span> <span class="ot">=</span> y <span class="op">:</span> merge xs yt</span> |
| 142 | +<span id="cb4-5"><a href="#cb4-5"></a></span> |
| 143 | +<span id="cb4-6"><a href="#cb4-6"></a>split (x<span class="op">:</span>y<span class="op">:</span>zs) <span class="ot">=</span> <span class="kw">let</span> (xs,ys) <span class="ot">=</span> split zs <span class="kw">in</span> (x<span class="op">:</span>xs,y<span class="op">:</span>ys)</span> |
| 144 | +<span id="cb4-7"><a href="#cb4-7"></a>split [x] <span class="ot">=</span> ([x],[])</span> |
| 145 | +<span id="cb4-8"><a href="#cb4-8"></a>split [] <span class="ot">=</span> ([],[])</span> |
| 146 | +<span id="cb4-9"><a href="#cb4-9"></a></span> |
| 147 | +<span id="cb4-10"><a href="#cb4-10"></a>mergeSort [] <span class="ot">=</span> []</span> |
| 148 | +<span id="cb4-11"><a href="#cb4-11"></a>mergeSort [x] <span class="ot">=</span> [x]</span> |
| 149 | +<span id="cb4-12"><a href="#cb4-12"></a>mergeSort xs <span class="ot">=</span> <span class="kw">let</span> (as,bs) <span class="ot">=</span> split xs</span> |
| 150 | +<span id="cb4-13"><a href="#cb4-13"></a> <span class="kw">in</span> merge (mergeSort as) (mergeSort bs)</span></code></pre></div> |
152 | 151 | </section> |
153 | 152 | <section id="figures-sections" class="level2"> |
154 | 153 | <h2>Figures & Sections</h2> |
|
0 commit comments