diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.html | 25 | ||||
-rw-r--r-- | docs/index.xml | 198 | ||||
-rw-r--r-- | docs/posts/OSC-52/index.html | 119 | ||||
-rw-r--r-- | docs/posts/auto-currying_rust_functions/index.html | 2 | ||||
-rw-r--r-- | docs/posts/bash_harder_with_vim/index.html | 2 | ||||
-rw-r--r-- | docs/posts/call_to_ARMs/index.html | 2 | ||||
-rw-r--r-- | docs/posts/color_conundrum/index.html | 2 | ||||
-rw-r--r-- | docs/posts/font_size_fallacies/index.html | 2 | ||||
-rw-r--r-- | docs/posts/index.html | 59 | ||||
-rw-r--r-- | docs/posts/introducing_tablespoon/index.html | 211 | ||||
-rw-r--r-- | docs/posts/my_setup/index.html | 2 | ||||
-rw-r--r-- | docs/posts/pixel_art_in_GIMP/index.html | 2 | ||||
-rw-r--r-- | docs/posts/plain_text_journaling/index.html | 2 | ||||
-rw-r--r-- | docs/posts/rapid_refactoring_with_vim/index.html | 2 | ||||
-rw-r--r-- | docs/posts/static_sites_with_bash/index.html | 2 | ||||
-rw-r--r-- | docs/posts/termux_tandem/index.html | 2 | ||||
-rw-r--r-- | docs/posts/turing_complete_type_systems/index.html | 2 | ||||
-rw-r--r-- | docs/style.css | 7 |
18 files changed, 605 insertions, 38 deletions
diff --git a/docs/index.html b/docs/index.html index d42ab2b..be84486 100644 --- a/docs/index.html +++ b/docs/index.html | |||
@@ -39,15 +39,15 @@ | |||
39 | <tr> | 39 | <tr> |
40 | <td class=table-post> | 40 | <td class=table-post> |
41 | <div class="date"> | 41 | <div class="date"> |
42 | 29/05 — 2024 | 42 | 28/11 — 2024 |
43 | </div> | 43 | </div> |
44 | <a href="/posts/snip_snap" class="post-link"> | 44 | <a href="/posts/OSC-52" class="post-link"> |
45 | <span class="post-link">Snip Snap</span> | 45 | <span class="post-link">OSC-52</span> |
46 | </a> | 46 | </a> |
47 | </td> | 47 | </td> |
48 | <td class=table-stats> | 48 | <td class=table-stats> |
49 | <span class="stats-number"> | 49 | <span class="stats-number"> |
50 | 2.1 | 50 | 1.9 |
51 | </span> | 51 | </span> |
52 | <span class=stats-unit>min</span> | 52 | <span class=stats-unit>min</span> |
53 | </td> | 53 | </td> |
@@ -56,15 +56,15 @@ | |||
56 | <tr> | 56 | <tr> |
57 | <td class=table-post> | 57 | <td class=table-post> |
58 | <div class="date"> | 58 | <div class="date"> |
59 | 18/06 — 2023 | 59 | 02/08 — 2024 |
60 | </div> | 60 | </div> |
61 | <a href="/posts/plain_text_journaling" class="post-link"> | 61 | <a href="/posts/introducing_tablespoon" class="post-link"> |
62 | <span class="post-link">Plain Text Journaling</span> | 62 | <span class="post-link">Introducing Tablespoon</span> |
63 | </a> | 63 | </a> |
64 | </td> | 64 | </td> |
65 | <td class=table-stats> | 65 | <td class=table-stats> |
66 | <span class="stats-number"> | 66 | <span class="stats-number"> |
67 | 8.9 | 67 | 4.5 |
68 | </span> | 68 | </span> |
69 | <span class=stats-unit>min</span> | 69 | <span class=stats-unit>min</span> |
70 | </td> | 70 | </td> |
@@ -73,15 +73,15 @@ | |||
73 | <tr> | 73 | <tr> |
74 | <td class=table-post> | 74 | <td class=table-post> |
75 | <div class="date"> | 75 | <div class="date"> |
76 | 03/09 — 2022 | 76 | 29/05 — 2024 |
77 | </div> | 77 | </div> |
78 | <a href="/posts/curing_a_case_of_git-UX" class="post-link"> | 78 | <a href="/posts/snip_snap" class="post-link"> |
79 | <span class="post-link">Curing A Case Of Git-UX</span> | 79 | <span class="post-link">Snip Snap</span> |
80 | </a> | 80 | </a> |
81 | </td> | 81 | </td> |
82 | <td class=table-stats> | 82 | <td class=table-stats> |
83 | <span class="stats-number"> | 83 | <span class="stats-number"> |
84 | 9.6 | 84 | 2.1 |
85 | </span> | 85 | </span> |
86 | <span class=stats-unit>min</span> | 86 | <span class=stats-unit>min</span> |
87 | </td> | 87 | </td> |
@@ -110,6 +110,7 @@ | |||
110 | <div class="footer"> | 110 | <div class="footer"> |
111 | <a href="https://git.peppe.rs">Code</a> · | 111 | <a href="https://git.peppe.rs">Code</a> · |
112 | <a rel="me" href="https://merveilles.town/@nerdypepper">Fediverse</a> · | 112 | <a rel="me" href="https://merveilles.town/@nerdypepper">Fediverse</a> · |
113 | <a href="https://bsky.app/profile/oppi.li">Bluesky</a> · | ||
113 | <a href="mailto:[email protected]">Mail</a> | 114 | <a href="mailto:[email protected]">Mail</a> |
114 | <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"> | 115 | <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"> |
115 | <img class="footimgs" src="https://d33wubrfki0l68.cloudfront.net/94387e9d77fbc8b4360db81e72603ecba3df94a7/632bc/static/cc.svg"> | 116 | <img class="footimgs" src="https://d33wubrfki0l68.cloudfront.net/94387e9d77fbc8b4360db81e72603ecba3df94a7/632bc/static/cc.svg"> |
diff --git a/docs/index.xml b/docs/index.xml index 9245aba..f8b2aeb 100644 --- a/docs/index.xml +++ b/docs/index.xml | |||
@@ -12,6 +12,204 @@ | |||
12 | <language>en-us</language> | 12 | <language>en-us</language> |
13 | <copyright>Creative Commons BY-NC-SA 4.0</copyright> | 13 | <copyright>Creative Commons BY-NC-SA 4.0</copyright> |
14 | <item> | 14 | <item> |
15 | <title>OSC-52</title> | ||
16 | <description><p>I use <code>ssh</code> a lot. Copying text from the remote machine to | ||
17 | the host machine always sucked. But OSC-52 makes that easy.</p> | ||
18 | <p>OSC-52 is an ANSI escape sequence to write text to the terminal | ||
19 | emulator. The terminal emulator, if it understands what is going on, | ||
20 | will in turn write this text to the system clipboard.</p> | ||
21 | <p>What this means is some <code>printf</code> magic can send text to | ||
22 | your clipboard. I store this one-liner in a script called | ||
23 | <code>oclip</code>:</p> | ||
24 | <div class="sourceCode" id="cb1"><pre | ||
25 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="bu">printf</span> <span class="st">&quot;\033]52;c;%s\007&quot;</span> <span class="st">&quot;</span><span class="va">$(</span><span class="fu">base64</span> <span class="op">&lt;&amp;</span><span class="dv">0</span><span class="va">)</span><span class="st">&quot;</span></span></code></pre></div> | ||
26 | <p>and I run it with:</p> | ||
27 | <div class="sourceCode" id="cb2"><pre | ||
28 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">remote</span> $ cat some_file.txt <span class="kw">|</span> <span class="ex">oclip</span></span> | ||
29 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span> | ||
30 | <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># some_file.txt&#39;s contents are now the host&#39;s clipboard</span></span></code></pre></div> | ||
31 | <h3 id="the-catch">The catch</h3> | ||
32 | <p>Your terminal emulator must support OSC-52, <code>alacritty</code> | ||
33 | and <code>termux</code> seem to support this out of the box. In | ||
34 | <code>st</code>, OSC-52 works with this change to | ||
35 | <code>config.h</code>:</p> | ||
36 | <pre><code>int allowwindowops = 1;</code></pre> | ||
37 | <p>If you are using <code>tmux</code>, you need to flip this switch | ||
38 | on:</p> | ||
39 | <pre><code>set -s set-clipboard on</code></pre> | ||
40 | <p>If you are inside <code>nvim</code>, it may work as expected as long | ||
41 | as <code>$SSH_TTY</code> is set. I sometimes physically start a session, | ||
42 | and <code>ssh</code> into the same session later from another machine, | ||
43 | and <code>$SSH_TTY</code> remains unset, so I force OSC-52 in | ||
44 | <code>nvim</code> at all times (see <a | ||
45 | href="https://neovim.io/doc/user/provider.html#clipboard-osc52">nvimdoc</a>):</p> | ||
46 | <div class="sourceCode" id="cb5"><pre | ||
47 | class="sourceCode lua"><code class="sourceCode lua"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="va">vim</span><span class="op">.</span><span class="va">g</span><span class="op">.</span><span class="va">clipboard</span> <span class="op">=</span> <span class="op">{</span></span> | ||
48 | <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="va">name</span> <span class="op">=</span> <span class="st">&#39;OSC 52&#39;</span><span class="op">,</span></span> | ||
49 | <span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="va">copy</span> <span class="op">=</span> <span class="op">{</span></span> | ||
50 | <span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">&#39;+&#39;</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">&#39;vim.ui.clipboard.osc52&#39;</span><span class="op">).</span>copy<span class="op">(</span><span class="st">&#39;+&#39;</span><span class="op">),</span></span> | ||
51 | <span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">&#39;*&#39;</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">&#39;vim.ui.clipboard.osc52&#39;</span><span class="op">).</span>copy<span class="op">(</span><span class="st">&#39;*&#39;</span><span class="op">),</span></span> | ||
52 | <span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="op">},</span></span> | ||
53 | <span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="va">paste</span> <span class="op">=</span> <span class="op">{</span></span> | ||
54 | <span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">&#39;+&#39;</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">&#39;vim.ui.clipboard.osc52&#39;</span><span class="op">).</span>paste<span class="op">(</span><span class="st">&#39;+&#39;</span><span class="op">),</span></span> | ||
55 | <span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">&#39;*&#39;</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">&#39;vim.ui.clipboard.osc52&#39;</span><span class="op">).</span>paste<span class="op">(</span><span class="st">&#39;*&#39;</span><span class="op">),</span></span> | ||
56 | <span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="op">},</span></span> | ||
57 | <span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div> | ||
58 | <p>If you are inside <code>nvim</code> inside <code>tmux</code> inside | ||
59 | an <code>ssh</code> session inside <code>st</code>, you neeed all of the | ||
60 | above tweaks. <code>nvim</code> will pass the contents around to | ||
61 | <code>tmux</code>, which in turn will pass the contents to | ||
62 | <code>st</code>, which should pass it to your system clipboard.</p></description> | ||
63 | <link>https://peppe.rs/posts/OSC-52/</link> | ||
64 | <pubDate>Wed, 27 Nov 2024 22:56:00 +0000</pubDate> | ||
65 | <guid>https://peppe.rs/posts/OSC-52/</guid> | ||
66 | </item> | ||
67 | <item> | ||
68 | <title>Introducing Tablespoon</title> | ||
69 | <description><p><a href="https://git.peppe.rs/languages/tbsp">tbsp</a> (tree-based | ||
70 | source-processing language) is an awk-like language that operates on | ||
71 | tree-sitter syntax trees. To motivate the need for such a program, we | ||
72 | could begin by writing a markdown-to-html converter using | ||
73 | <code>tbsp</code> and <a | ||
74 | href="https://github.com/tree-sitter-grammars/tree-sitter-markdown">tree-sitter-md</a>. | ||
75 | We need some markdown to begin with:</p> | ||
76 | <pre><code># 1 heading | ||
77 | |||
78 | content of first paragraph | ||
79 | |||
80 | ## 1.1 heading | ||
81 | |||
82 | content of nested paragraph</code></pre> | ||
83 | <p>For future reference, this markdown is parsed like so by | ||
84 | tree-sitter-md (visualization generated by <a | ||
85 | href="https://git.peppe.rs/cli/tree-viz">tree-viz</a>):</p> | ||
86 | <pre><code>document | ||
87 | | section | ||
88 | | | atx_heading | ||
89 | | | | atx_h1_marker &quot;#&quot; | ||
90 | | | | heading_content inline &quot;1 heading&quot; | ||
91 | | | paragraph | ||
92 | | | | inline &quot;content of first paragraph&quot; | ||
93 | | | section | ||
94 | | | | atx_heading | ||
95 | | | | | atx_h2_marker &quot;##&quot; | ||
96 | | | | | heading_content inline &quot;1.1 heading&quot; | ||
97 | | | | paragraph | ||
98 | | | | | inline &quot;content of nested paragraph&quot;</code></pre> | ||
99 | <p>Onto the converter itself. Every <code>tbsp</code> program is written | ||
100 | as a collection of stanzas. Typically, we start with a stanza like | ||
101 | so:</p> | ||
102 | <pre><code>BEGIN { | ||
103 | int depth = 0; | ||
104 | |||
105 | print(&quot;&lt;html&gt;\n&quot;); | ||
106 | print(&quot;&lt;body&gt;\n&quot;); | ||
107 | }</code></pre> | ||
108 | <p>The stanza begins with a “pattern”, in this case, <code>BEGIN</code>, | ||
109 | and is followed a block of code. This block specifically, is executed | ||
110 | right at the beginning, before traversing the parse tree. In this | ||
111 | stanza, we set a “depth” variable to keep track of nesting of markdown | ||
112 | headers, and begin our html document by printing the | ||
113 | <code>&lt;html&gt;</code> and <code>&lt;body&gt;</code> tags.</p> | ||
114 | <p>We can follow this stanza with an <code>END</code> stanza, that is | ||
115 | executed after the traversal:</p> | ||
116 | <pre><code>END { | ||
117 | print(&quot;&lt;/body&gt;\n&quot;); | ||
118 | print(&quot;&lt;/html&gt;\n&quot;); | ||
119 | }</code></pre> | ||
120 | <p>In this stanza, we close off the tags we opened at the start of the | ||
121 | document. We can move onto the interesting bits of the conversion | ||
122 | now:</p> | ||
123 | <pre><code>enter section { | ||
124 | depth += 1; | ||
125 | } | ||
126 | leave section { | ||
127 | depth -= 1; | ||
128 | }</code></pre> | ||
129 | <p>The above stanzas begin with <code>enter</code> and | ||
130 | <code>leave</code> clauses, followed by the name of a tree-sitter node | ||
131 | kind: <code>section</code>. The <code>section</code> identifier is | ||
132 | visible in the tree-visualization above, it encompasses a | ||
133 | markdown-section, and is created for every markdown header. To | ||
134 | understand how <code>tbsp</code> executes above stanzas:</p> | ||
135 | <pre><code>document ... depth = 0 | ||
136 | | section &lt;-------- enter section (1) ... depth = 1 | ||
137 | | | atx_heading | ||
138 | | | | inline | ||
139 | | | paragraph | ||
140 | | | | inline | ||
141 | | | section &lt;----- enter section (2) ... depth = 2 | ||
142 | | | | atx_heading | ||
143 | | | | | inline | ||
144 | | | | paragraph | ||
145 | | | | | inline | ||
146 | | | | &lt;----------- leave section (2) ... depth = 1 | ||
147 | | | &lt;-------------- leave section (1) ... depth = 0 </code></pre> | ||
148 | <p>The following stanzas should be self-explanatory now:</p> | ||
149 | <pre><code>enter atx_heading { | ||
150 | print(&quot;&lt;h&quot;); | ||
151 | print(depth); | ||
152 | print(&quot;&gt;&quot;); | ||
153 | } | ||
154 | leave atx_heading { | ||
155 | print(&quot;&lt;/h&quot;); | ||
156 | print(depth); | ||
157 | print(&quot;&gt;\n&quot;); | ||
158 | } | ||
159 | |||
160 | enter inline { | ||
161 | print(text(node)); | ||
162 | }</code></pre> | ||
163 | <p>But an explanation is included nonetheless:</p> | ||
164 | <pre><code>document ... depth = 0 | ||
165 | | section &lt;-------- enter section (1) ... depth = 1 | ||
166 | | | atx_heading &lt;- enter atx_heading ... print &quot;&lt;h1&gt;&quot; | ||
167 | | | | inline &lt;--- enter inline ... print .. | ||
168 | | | | &lt;----------- leave atx_heading ... print &quot;&lt;/h1&gt;&quot; | ||
169 | | | paragraph | ||
170 | | | | inline &lt;--- enter inline ... print .. | ||
171 | | | section &lt;----- enter section (2) ... depth = 2 | ||
172 | | | | atx_heading enter atx_heading ... print &quot;&lt;h2&gt;&quot; | ||
173 | | | | | inline &lt;- enter inline ... print .. | ||
174 | | | | | &lt;-------- leave atx_heading ... print &quot;&lt;/h2&gt;&quot; | ||
175 | | | | paragraph | ||
176 | | | | | inline &lt;- enter inline ... print .. | ||
177 | | | | &lt;----------- leave section (2) ... depth = 1 | ||
178 | | | &lt;-------------- leave section (1) ... depth = 0 </code></pre> | ||
179 | <p>The <a | ||
180 | href="https://git.peppe.rs/languages/tbsp/tree/examples">examples</a> | ||
181 | directory contains a complete markdown-to-html converter, along with a | ||
182 | few other motivating examples.</p> | ||
183 | <h3 id="usage">Usage</h3> | ||
184 | <p>The <code>tbsp</code> evaluator is written in rust, use cargo to | ||
185 | build and run:</p> | ||
186 | <pre><code>cargo build --release | ||
187 | ./target/release/tbsp --help</code></pre> | ||
188 | <p><code>tbsp</code> requires three inputs:</p> | ||
189 | <ul> | ||
190 | <li>a <code>tbsp</code> program, referred to as “program file”</li> | ||
191 | <li>a language</li> | ||
192 | <li>an input file or some input text at stdin</li> | ||
193 | </ul> | ||
194 | <p>You can run the interpreter like so (this program prints an overview | ||
195 | of a rust file):</p> | ||
196 | <pre><code>$ ./target/release/tbsp \ | ||
197 | -f./examples/code-overview/overview.tbsp \ | ||
198 | -l rust \ | ||
199 | src/main.rs | ||
200 | module | ||
201 | └╴struct Cli | ||
202 | └╴trait Cli | ||
203 | └╴fn program | ||
204 | └╴fn language | ||
205 | └╴fn file | ||
206 | └╴fn try_consume_stdin | ||
207 | └╴fn main</code></pre></description> | ||
208 | <link>https://peppe.rs/posts/introducing_tablespoon/</link> | ||
209 | <pubDate>Thu, 01 Aug 2024 19:18:00 +0000</pubDate> | ||
210 | <guid>https://peppe.rs/posts/introducing_tablespoon/</guid> | ||
211 | </item> | ||
212 | <item> | ||
15 | <title>Snip Snap</title> | 213 | <title>Snip Snap</title> |
16 | <description><p>I regularly switch between exactly two things while working, a | 214 | <description><p>I regularly switch between exactly two things while working, a |
17 | “current” and an “alternate” item; a lot of tools I use seem to support | 215 | “current” and an “alternate” item; a lot of tools I use seem to support |
diff --git a/docs/posts/OSC-52/index.html b/docs/posts/OSC-52/index.html new file mode 100644 index 0000000..6c87fef --- /dev/null +++ b/docs/posts/OSC-52/index.html | |||
@@ -0,0 +1,119 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html lang="en"> | ||
3 | <head> | ||
4 | <link rel="stylesheet" href="/style.css"> | ||
5 | <link rel="stylesheet" href="/syntax.css"> | ||
6 | <meta charset="UTF-8"> | ||
7 | <meta name="viewport" content="initial-scale=1"> | ||
8 | <meta content="#ffffff" name="theme-color"> | ||
9 | <meta name="HandheldFriendly" content="true"> | ||
10 | <meta property="og:title" content="OSC-52"> | ||
11 | <meta property="og:type" content="website"> | ||
12 | <meta property="og:description" content="a static site {for, by, about} me "> | ||
13 | <meta property="og:url" content="https://peppe.rs"> | ||
14 | <link rel="icon" type="image/x-icon" href="/favicon.png"> | ||
15 | <title>OSC-52 · peppe.rs</title> | ||
16 | <body> | ||
17 | <div class="posts"> | ||
18 | <div class="post"> | ||
19 | <a href="/" class="post-end-link">Home</a> | ||
20 | <span>/</span> | ||
21 | <a href="/posts" class="post-end-link">Posts</a> | ||
22 | <span>/</span> | ||
23 | <a class="post-end-link">OSC-52</a> | ||
24 | <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/OSC-52.md | ||
25 | ">View Raw</a> | ||
26 | <div class="separator"></div> | ||
27 | <div class="date"> | ||
28 | 28/11 — 2024 | ||
29 | <div class="stats"> | ||
30 | <span class="stats-number"> | ||
31 | 26.37 | ||
32 | </span> | ||
33 | <span class="stats-unit">cm</span> | ||
34 |   | ||
35 | <span class="stats-number"> | ||
36 | 1.9 | ||
37 | </span> | ||
38 | <span class="stats-unit">min</span> | ||
39 | </div> | ||
40 | </div> | ||
41 | <h1> | ||
42 | OSC-52 | ||
43 | </h1> | ||
44 | <div class="post-text"> | ||
45 | <p>I use <code>ssh</code> a lot. Copying text from the remote machine to | ||
46 | the host machine always sucked. But OSC-52 makes that easy.</p> | ||
47 | <p>OSC-52 is an ANSI escape sequence to write text to the terminal | ||
48 | emulator. The terminal emulator, if it understands what is going on, | ||
49 | will in turn write this text to the system clipboard.</p> | ||
50 | <p>What this means is some <code>printf</code> magic can send text to | ||
51 | your clipboard. I store this one-liner in a script called | ||
52 | <code>oclip</code>:</p> | ||
53 | <div class="sourceCode" id="cb1"><pre | ||
54 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="bu">printf</span> <span class="st">"\033]52;c;%s\007"</span> <span class="st">"</span><span class="va">$(</span><span class="fu">base64</span> <span class="op"><&</span><span class="dv">0</span><span class="va">)</span><span class="st">"</span></span></code></pre></div> | ||
55 | <p>and I run it with:</p> | ||
56 | <div class="sourceCode" id="cb2"><pre | ||
57 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">remote</span> $ cat some_file.txt <span class="kw">|</span> <span class="ex">oclip</span></span> | ||
58 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a></span> | ||
59 | <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="co"># some_file.txt's contents are now the host's clipboard</span></span></code></pre></div> | ||
60 | <h3 id="the-catch">The catch</h3> | ||
61 | <p>Your terminal emulator must support OSC-52, <code>alacritty</code> | ||
62 | and <code>termux</code> seem to support this out of the box. In | ||
63 | <code>st</code>, OSC-52 works with this change to | ||
64 | <code>config.h</code>:</p> | ||
65 | <pre><code>int allowwindowops = 1;</code></pre> | ||
66 | <p>If you are using <code>tmux</code>, you need to flip this switch | ||
67 | on:</p> | ||
68 | <pre><code>set -s set-clipboard on</code></pre> | ||
69 | <p>If you are inside <code>nvim</code>, it may work as expected as long | ||
70 | as <code>$SSH_TTY</code> is set. I sometimes physically start a session, | ||
71 | and <code>ssh</code> into the same session later from another machine, | ||
72 | and <code>$SSH_TTY</code> remains unset, so I force OSC-52 in | ||
73 | <code>nvim</code> at all times (see <a | ||
74 | href="https://neovim.io/doc/user/provider.html#clipboard-osc52">nvimdoc</a>):</p> | ||
75 | <div class="sourceCode" id="cb5"><pre | ||
76 | class="sourceCode lua"><code class="sourceCode lua"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="va">vim</span><span class="op">.</span><span class="va">g</span><span class="op">.</span><span class="va">clipboard</span> <span class="op">=</span> <span class="op">{</span></span> | ||
77 | <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="va">name</span> <span class="op">=</span> <span class="st">'OSC 52'</span><span class="op">,</span></span> | ||
78 | <span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="va">copy</span> <span class="op">=</span> <span class="op">{</span></span> | ||
79 | <span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">'+'</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">'vim.ui.clipboard.osc52'</span><span class="op">).</span>copy<span class="op">(</span><span class="st">'+'</span><span class="op">),</span></span> | ||
80 | <span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">'*'</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">'vim.ui.clipboard.osc52'</span><span class="op">).</span>copy<span class="op">(</span><span class="st">'*'</span><span class="op">),</span></span> | ||
81 | <span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="op">},</span></span> | ||
82 | <span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> <span class="va">paste</span> <span class="op">=</span> <span class="op">{</span></span> | ||
83 | <span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">'+'</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">'vim.ui.clipboard.osc52'</span><span class="op">).</span>paste<span class="op">(</span><span class="st">'+'</span><span class="op">),</span></span> | ||
84 | <span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a> <span class="op">[</span><span class="st">'*'</span><span class="op">]</span> <span class="op">=</span> <span class="fu">require</span><span class="op">(</span><span class="st">'vim.ui.clipboard.osc52'</span><span class="op">).</span>paste<span class="op">(</span><span class="st">'*'</span><span class="op">),</span></span> | ||
85 | <span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a> <span class="op">},</span></span> | ||
86 | <span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div> | ||
87 | <p>If you are inside <code>nvim</code> inside <code>tmux</code> inside | ||
88 | an <code>ssh</code> session inside <code>st</code>, you neeed all of the | ||
89 | above tweaks. <code>nvim</code> will pass the contents around to | ||
90 | <code>tmux</code>, which in turn will pass the contents to | ||
91 | <code>st</code>, which should pass it to your system clipboard.</p> | ||
92 | |||
93 | </div> | ||
94 | |||
95 | <div class="intro"> | ||
96 | Hi. | ||
97 | <div class="hot-links"> | ||
98 | <a href="/index.xml" class="feed-button">Subscribe</a> | ||
99 | </div> | ||
100 | <p>I'm Akshay, programmer and pixel-artist. | ||
101 | I write <a href="https://git.peppe.rs">open-source stuff</a>. | ||
102 | I also design fonts: | ||
103 | <a href="https://git.peppe.rs/fonts/scientifica/about">scientifica</a>, | ||
104 | <a href="https://git.peppe.rs/fonts/curie/about">curie</a>. | ||
105 | </p> | ||
106 | <p>Reach out at [email protected].</p> | ||
107 | </div> | ||
108 | |||
109 | <a href="/" class="post-end-link">Home</a> | ||
110 | <span>/</span> | ||
111 | <a href="/posts" class="post-end-link">Posts</a> | ||
112 | <span>/</span> | ||
113 | <a class="post-end-link">OSC-52</a> | ||
114 | <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/OSC-52.md | ||
115 | ">View Raw</a> | ||
116 | </div> | ||
117 | </div> | ||
118 | </body> | ||
119 | </html> | ||
diff --git a/docs/posts/auto-currying_rust_functions/index.html b/docs/posts/auto-currying_rust_functions/index.html index c06b13f..9ea7246 100644 --- a/docs/posts/auto-currying_rust_functions/index.html +++ b/docs/posts/auto-currying_rust_functions/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 08/05 — 2020 | 28 | 09/05 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 356.44 | 31 | 356.44 |
diff --git a/docs/posts/bash_harder_with_vim/index.html b/docs/posts/bash_harder_with_vim/index.html index 6104163..7d3c869 100644 --- a/docs/posts/bash_harder_with_vim/index.html +++ b/docs/posts/bash_harder_with_vim/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 30/07 — 2019 | 28 | 31/07 — 2019 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 24.38 | 31 | 24.38 |
diff --git a/docs/posts/call_to_ARMs/index.html b/docs/posts/call_to_ARMs/index.html index 71b5397..f5b92f7 100644 --- a/docs/posts/call_to_ARMs/index.html +++ b/docs/posts/call_to_ARMs/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 07/02 — 2020 | 28 | 08/02 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 33.57 | 31 | 33.57 |
diff --git a/docs/posts/color_conundrum/index.html b/docs/posts/color_conundrum/index.html index 87bc495..a98741a 100644 --- a/docs/posts/color_conundrum/index.html +++ b/docs/posts/color_conundrum/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 30/12 — 2019 | 28 | 31/12 — 2019 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 14.39 | 31 | 14.39 |
diff --git a/docs/posts/font_size_fallacies/index.html b/docs/posts/font_size_fallacies/index.html index 871a536..5cf8485 100644 --- a/docs/posts/font_size_fallacies/index.html +++ b/docs/posts/font_size_fallacies/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 16/03 — 2020 | 28 | 17/03 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 32.37 | 31 | 32.37 |
diff --git a/docs/posts/index.html b/docs/posts/index.html index ca9a3ac..9f1aac7 100644 --- a/docs/posts/index.html +++ b/docs/posts/index.html | |||
@@ -27,6 +27,40 @@ | |||
27 | <tr> | 27 | <tr> |
28 | <td class=table-post> | 28 | <td class=table-post> |
29 | <div class="date"> | 29 | <div class="date"> |
30 | 28/11 — 2024 | ||
31 | </div> | ||
32 | <a href="/posts/OSC-52" class="post-link"> | ||
33 | <span class="post-link">OSC-52</span> | ||
34 | </a> | ||
35 | </td> | ||
36 | <td class=table-stats> | ||
37 | <span class="stats-number"> | ||
38 | 1.9 | ||
39 | </span> | ||
40 | <span class=stats-unit>min</span> | ||
41 | </td> | ||
42 | </tr> | ||
43 | |||
44 | <tr> | ||
45 | <td class=table-post> | ||
46 | <div class="date"> | ||
47 | 02/08 — 2024 | ||
48 | </div> | ||
49 | <a href="/posts/introducing_tablespoon" class="post-link"> | ||
50 | <span class="post-link">Introducing Tablespoon</span> | ||
51 | </a> | ||
52 | </td> | ||
53 | <td class=table-stats> | ||
54 | <span class="stats-number"> | ||
55 | 4.5 | ||
56 | </span> | ||
57 | <span class=stats-unit>min</span> | ||
58 | </td> | ||
59 | </tr> | ||
60 | |||
61 | <tr> | ||
62 | <td class=table-post> | ||
63 | <div class="date"> | ||
30 | 29/05 — 2024 | 64 | 29/05 — 2024 |
31 | </div> | 65 | </div> |
32 | <a href="/posts/snip_snap" class="post-link"> | 66 | <a href="/posts/snip_snap" class="post-link"> |
@@ -44,7 +78,7 @@ | |||
44 | <tr> | 78 | <tr> |
45 | <td class=table-post> | 79 | <td class=table-post> |
46 | <div class="date"> | 80 | <div class="date"> |
47 | 18/06 — 2023 | 81 | 19/06 — 2023 |
48 | </div> | 82 | </div> |
49 | <a href="/posts/plain_text_journaling" class="post-link"> | 83 | <a href="/posts/plain_text_journaling" class="post-link"> |
50 | <span class="post-link">Plain Text Journaling</span> | 84 | <span class="post-link">Plain Text Journaling</span> |
@@ -231,7 +265,7 @@ | |||
231 | <tr> | 265 | <tr> |
232 | <td class=table-post> | 266 | <td class=table-post> |
233 | <div class="date"> | 267 | <div class="date"> |
234 | 17/06 — 2020 | 268 | 18/06 — 2020 |
235 | </div> | 269 | </div> |
236 | <a href="/posts/turing_complete_type_systems" class="post-link"> | 270 | <a href="/posts/turing_complete_type_systems" class="post-link"> |
237 | <span class="post-link">Turing Complete Type Systems</span> | 271 | <span class="post-link">Turing Complete Type Systems</span> |
@@ -248,7 +282,7 @@ | |||
248 | <tr> | 282 | <tr> |
249 | <td class=table-post> | 283 | <td class=table-post> |
250 | <div class="date"> | 284 | <div class="date"> |
251 | 08/05 — 2020 | 285 | 09/05 — 2020 |
252 | </div> | 286 | </div> |
253 | <a href="/posts/auto-currying_rust_functions" class="post-link"> | 287 | <a href="/posts/auto-currying_rust_functions" class="post-link"> |
254 | <span class="post-link">Auto-currying Rust Functions</span> | 288 | <span class="post-link">Auto-currying Rust Functions</span> |
@@ -265,7 +299,7 @@ | |||
265 | <tr> | 299 | <tr> |
266 | <td class=table-post> | 300 | <td class=table-post> |
267 | <div class="date"> | 301 | <div class="date"> |
268 | 08/04 — 2020 | 302 | 09/04 — 2020 |
269 | </div> | 303 | </div> |
270 | <a href="/posts/pixel_art_in_GIMP" class="post-link"> | 304 | <a href="/posts/pixel_art_in_GIMP" class="post-link"> |
271 | <span class="post-link">Pixel Art In GIMP</span> | 305 | <span class="post-link">Pixel Art In GIMP</span> |
@@ -282,7 +316,7 @@ | |||
282 | <tr> | 316 | <tr> |
283 | <td class=table-post> | 317 | <td class=table-post> |
284 | <div class="date"> | 318 | <div class="date"> |
285 | 31/03 — 2020 | 319 | 01/04 — 2020 |
286 | </div> | 320 | </div> |
287 | <a href="/posts/rapid_refactoring_with_vim" class="post-link"> | 321 | <a href="/posts/rapid_refactoring_with_vim" class="post-link"> |
288 | <span class="post-link">Rapid Refactoring With Vim</span> | 322 | <span class="post-link">Rapid Refactoring With Vim</span> |
@@ -299,7 +333,7 @@ | |||
299 | <tr> | 333 | <tr> |
300 | <td class=table-post> | 334 | <td class=table-post> |
301 | <div class="date"> | 335 | <div class="date"> |
302 | 16/03 — 2020 | 336 | 17/03 — 2020 |
303 | </div> | 337 | </div> |
304 | <a href="/posts/font_size_fallacies" class="post-link"> | 338 | <a href="/posts/font_size_fallacies" class="post-link"> |
305 | <span class="post-link">Font Size Fallacies</span> | 339 | <span class="post-link">Font Size Fallacies</span> |
@@ -316,7 +350,7 @@ | |||
316 | <tr> | 350 | <tr> |
317 | <td class=table-post> | 351 | <td class=table-post> |
318 | <div class="date"> | 352 | <div class="date"> |
319 | 07/03 — 2020 | 353 | 08/03 — 2020 |
320 | </div> | 354 | </div> |
321 | <a href="/posts/termux_tandem" class="post-link"> | 355 | <a href="/posts/termux_tandem" class="post-link"> |
322 | <span class="post-link">Termux Tandem</span> | 356 | <span class="post-link">Termux Tandem</span> |
@@ -333,7 +367,7 @@ | |||
333 | <tr> | 367 | <tr> |
334 | <td class=table-post> | 368 | <td class=table-post> |
335 | <div class="date"> | 369 | <div class="date"> |
336 | 07/02 — 2020 | 370 | 08/02 — 2020 |
337 | </div> | 371 | </div> |
338 | <a href="/posts/call_to_ARMs" class="post-link"> | 372 | <a href="/posts/call_to_ARMs" class="post-link"> |
339 | <span class="post-link">Call To ARMs</span> | 373 | <span class="post-link">Call To ARMs</span> |
@@ -350,7 +384,7 @@ | |||
350 | <tr> | 384 | <tr> |
351 | <td class=table-post> | 385 | <td class=table-post> |
352 | <div class="date"> | 386 | <div class="date"> |
353 | 30/12 — 2019 | 387 | 31/12 — 2019 |
354 | </div> | 388 | </div> |
355 | <a href="/posts/color_conundrum" class="post-link"> | 389 | <a href="/posts/color_conundrum" class="post-link"> |
356 | <span class="post-link">Color Conundrum</span> | 390 | <span class="post-link">Color Conundrum</span> |
@@ -367,7 +401,7 @@ | |||
367 | <tr> | 401 | <tr> |
368 | <td class=table-post> | 402 | <td class=table-post> |
369 | <div class="date"> | 403 | <div class="date"> |
370 | 22/11 — 2019 | 404 | 23/11 — 2019 |
371 | </div> | 405 | </div> |
372 | <a href="/posts/static_sites_with_bash" class="post-link"> | 406 | <a href="/posts/static_sites_with_bash" class="post-link"> |
373 | <span class="post-link">Static Sites With Bash</span> | 407 | <span class="post-link">Static Sites With Bash</span> |
@@ -384,7 +418,7 @@ | |||
384 | <tr> | 418 | <tr> |
385 | <td class=table-post> | 419 | <td class=table-post> |
386 | <div class="date"> | 420 | <div class="date"> |
387 | 06/11 — 2019 | 421 | 07/11 — 2019 |
388 | </div> | 422 | </div> |
389 | <a href="/posts/my_setup" class="post-link"> | 423 | <a href="/posts/my_setup" class="post-link"> |
390 | <span class="post-link">My Setup</span> | 424 | <span class="post-link">My Setup</span> |
@@ -452,7 +486,7 @@ | |||
452 | <tr> | 486 | <tr> |
453 | <td class=table-post> | 487 | <td class=table-post> |
454 | <div class="date"> | 488 | <div class="date"> |
455 | 30/07 — 2019 | 489 | 31/07 — 2019 |
456 | </div> | 490 | </div> |
457 | <a href="/posts/bash_harder_with_vim" class="post-link"> | 491 | <a href="/posts/bash_harder_with_vim" class="post-link"> |
458 | <span class="post-link">Bash Harder With Vim</span> | 492 | <span class="post-link">Bash Harder With Vim</span> |
@@ -504,6 +538,7 @@ | |||
504 | <div class="footer"> | 538 | <div class="footer"> |
505 | <a href="https://git.peppe.rs">Code</a> · | 539 | <a href="https://git.peppe.rs">Code</a> · |
506 | <a rel="me" href="https://merveilles.town/@nerdypepper">Fediverse</a> · | 540 | <a rel="me" href="https://merveilles.town/@nerdypepper">Fediverse</a> · |
541 | <a href="https://bsky.app/profile/oppi.li">Bluesky</a> · | ||
507 | <a href="mailto:[email protected]">Mail</a> | 542 | <a href="mailto:[email protected]">Mail</a> |
508 | <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"> | 543 | <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"> |
509 | <img class="footimgs" src="https://d33wubrfki0l68.cloudfront.net/94387e9d77fbc8b4360db81e72603ecba3df94a7/632bc/static/cc.svg"> | 544 | <img class="footimgs" src="https://d33wubrfki0l68.cloudfront.net/94387e9d77fbc8b4360db81e72603ecba3df94a7/632bc/static/cc.svg"> |
diff --git a/docs/posts/introducing_tablespoon/index.html b/docs/posts/introducing_tablespoon/index.html new file mode 100644 index 0000000..c097cfa --- /dev/null +++ b/docs/posts/introducing_tablespoon/index.html | |||
@@ -0,0 +1,211 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html lang="en"> | ||
3 | <head> | ||
4 | <link rel="stylesheet" href="/style.css"> | ||
5 | <link rel="stylesheet" href="/syntax.css"> | ||
6 | <meta charset="UTF-8"> | ||
7 | <meta name="viewport" content="initial-scale=1"> | ||
8 | <meta content="#ffffff" name="theme-color"> | ||
9 | <meta name="HandheldFriendly" content="true"> | ||
10 | <meta property="og:title" content="Introducing Tablespoon"> | ||
11 | <meta property="og:type" content="website"> | ||
12 | <meta property="og:description" content="a static site {for, by, about} me "> | ||
13 | <meta property="og:url" content="https://peppe.rs"> | ||
14 | <link rel="icon" type="image/x-icon" href="/favicon.png"> | ||
15 | <title>Introducing Tablespoon · peppe.rs</title> | ||
16 | <body> | ||
17 | <div class="posts"> | ||
18 | <div class="post"> | ||
19 | <a href="/" class="post-end-link">Home</a> | ||
20 | <span>/</span> | ||
21 | <a href="/posts" class="post-end-link">Posts</a> | ||
22 | <span>/</span> | ||
23 | <a class="post-end-link">Introducing Tablespoon</a> | ||
24 | <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/introducing_tablespoon.md | ||
25 | ">View Raw</a> | ||
26 | <div class="separator"></div> | ||
27 | <div class="date"> | ||
28 | 02/08 — 2024 | ||
29 | <div class="stats"> | ||
30 | <span class="stats-number"> | ||
31 | 72.33 | ||
32 | </span> | ||
33 | <span class="stats-unit">cm</span> | ||
34 |   | ||
35 | <span class="stats-number"> | ||
36 | 4.5 | ||
37 | </span> | ||
38 | <span class="stats-unit">min</span> | ||
39 | </div> | ||
40 | </div> | ||
41 | <h1> | ||
42 | Introducing Tablespoon | ||
43 | </h1> | ||
44 | <div class="post-text"> | ||
45 | <p><a href="https://git.peppe.rs/languages/tbsp">tbsp</a> (tree-based | ||
46 | source-processing language) is an awk-like language that operates on | ||
47 | tree-sitter syntax trees. To motivate the need for such a program, we | ||
48 | could begin by writing a markdown-to-html converter using | ||
49 | <code>tbsp</code> and <a | ||
50 | href="https://github.com/tree-sitter-grammars/tree-sitter-markdown">tree-sitter-md</a>. | ||
51 | We need some markdown to begin with:</p> | ||
52 | <pre><code># 1 heading | ||
53 | |||
54 | content of first paragraph | ||
55 | |||
56 | ## 1.1 heading | ||
57 | |||
58 | content of nested paragraph</code></pre> | ||
59 | <p>For future reference, this markdown is parsed like so by | ||
60 | tree-sitter-md (visualization generated by <a | ||
61 | href="https://git.peppe.rs/cli/tree-viz">tree-viz</a>):</p> | ||
62 | <pre><code>document | ||
63 | | section | ||
64 | | | atx_heading | ||
65 | | | | atx_h1_marker "#" | ||
66 | | | | heading_content inline "1 heading" | ||
67 | | | paragraph | ||
68 | | | | inline "content of first paragraph" | ||
69 | | | section | ||
70 | | | | atx_heading | ||
71 | | | | | atx_h2_marker "##" | ||
72 | | | | | heading_content inline "1.1 heading" | ||
73 | | | | paragraph | ||
74 | | | | | inline "content of nested paragraph"</code></pre> | ||
75 | <p>Onto the converter itself. Every <code>tbsp</code> program is written | ||
76 | as a collection of stanzas. Typically, we start with a stanza like | ||
77 | so:</p> | ||
78 | <pre><code>BEGIN { | ||
79 | int depth = 0; | ||
80 | |||
81 | print("<html>\n"); | ||
82 | print("<body>\n"); | ||
83 | }</code></pre> | ||
84 | <p>The stanza begins with a “pattern”, in this case, <code>BEGIN</code>, | ||
85 | and is followed a block of code. This block specifically, is executed | ||
86 | right at the beginning, before traversing the parse tree. In this | ||
87 | stanza, we set a “depth” variable to keep track of nesting of markdown | ||
88 | headers, and begin our html document by printing the | ||
89 | <code><html></code> and <code><body></code> tags.</p> | ||
90 | <p>We can follow this stanza with an <code>END</code> stanza, that is | ||
91 | executed after the traversal:</p> | ||
92 | <pre><code>END { | ||
93 | print("</body>\n"); | ||
94 | print("</html>\n"); | ||
95 | }</code></pre> | ||
96 | <p>In this stanza, we close off the tags we opened at the start of the | ||
97 | document. We can move onto the interesting bits of the conversion | ||
98 | now:</p> | ||
99 | <pre><code>enter section { | ||
100 | depth += 1; | ||
101 | } | ||
102 | leave section { | ||
103 | depth -= 1; | ||
104 | }</code></pre> | ||
105 | <p>The above stanzas begin with <code>enter</code> and | ||
106 | <code>leave</code> clauses, followed by the name of a tree-sitter node | ||
107 | kind: <code>section</code>. The <code>section</code> identifier is | ||
108 | visible in the tree-visualization above, it encompasses a | ||
109 | markdown-section, and is created for every markdown header. To | ||
110 | understand how <code>tbsp</code> executes above stanzas:</p> | ||
111 | <pre><code>document ... depth = 0 | ||
112 | | section <-------- enter section (1) ... depth = 1 | ||
113 | | | atx_heading | ||
114 | | | | inline | ||
115 | | | paragraph | ||
116 | | | | inline | ||
117 | | | section <----- enter section (2) ... depth = 2 | ||
118 | | | | atx_heading | ||
119 | | | | | inline | ||
120 | | | | paragraph | ||
121 | | | | | inline | ||
122 | | | | <----------- leave section (2) ... depth = 1 | ||
123 | | | <-------------- leave section (1) ... depth = 0 </code></pre> | ||
124 | <p>The following stanzas should be self-explanatory now:</p> | ||
125 | <pre><code>enter atx_heading { | ||
126 | print("<h"); | ||
127 | print(depth); | ||
128 | print(">"); | ||
129 | } | ||
130 | leave atx_heading { | ||
131 | print("</h"); | ||
132 | print(depth); | ||
133 | print(">\n"); | ||
134 | } | ||
135 | |||
136 | enter inline { | ||
137 | print(text(node)); | ||
138 | }</code></pre> | ||
139 | <p>But an explanation is included nonetheless:</p> | ||
140 | <pre><code>document ... depth = 0 | ||
141 | | section <-------- enter section (1) ... depth = 1 | ||
142 | | | atx_heading <- enter atx_heading ... print "<h1>" | ||
143 | | | | inline <--- enter inline ... print .. | ||
144 | | | | <----------- leave atx_heading ... print "</h1>" | ||
145 | | | paragraph | ||
146 | | | | inline <--- enter inline ... print .. | ||
147 | | | section <----- enter section (2) ... depth = 2 | ||
148 | | | | atx_heading enter atx_heading ... print "<h2>" | ||
149 | | | | | inline <- enter inline ... print .. | ||
150 | | | | | <-------- leave atx_heading ... print "</h2>" | ||
151 | | | | paragraph | ||
152 | | | | | inline <- enter inline ... print .. | ||
153 | | | | <----------- leave section (2) ... depth = 1 | ||
154 | | | <-------------- leave section (1) ... depth = 0 </code></pre> | ||
155 | <p>The <a | ||
156 | href="https://git.peppe.rs/languages/tbsp/tree/examples">examples</a> | ||
157 | directory contains a complete markdown-to-html converter, along with a | ||
158 | few other motivating examples.</p> | ||
159 | <h3 id="usage">Usage</h3> | ||
160 | <p>The <code>tbsp</code> evaluator is written in rust, use cargo to | ||
161 | build and run:</p> | ||
162 | <pre><code>cargo build --release | ||
163 | ./target/release/tbsp --help</code></pre> | ||
164 | <p><code>tbsp</code> requires three inputs:</p> | ||
165 | <ul> | ||
166 | <li>a <code>tbsp</code> program, referred to as “program file”</li> | ||
167 | <li>a language</li> | ||
168 | <li>an input file or some input text at stdin</li> | ||
169 | </ul> | ||
170 | <p>You can run the interpreter like so (this program prints an overview | ||
171 | of a rust file):</p> | ||
172 | <pre><code>$ ./target/release/tbsp \ | ||
173 | -f./examples/code-overview/overview.tbsp \ | ||
174 | -l rust \ | ||
175 | src/main.rs | ||
176 | module | ||
177 | └╴struct Cli | ||
178 | └╴trait Cli | ||
179 | └╴fn program | ||
180 | └╴fn language | ||
181 | └╴fn file | ||
182 | └╴fn try_consume_stdin | ||
183 | └╴fn main</code></pre> | ||
184 | |||
185 | </div> | ||
186 | |||
187 | <div class="intro"> | ||
188 | Hi. | ||
189 | <div class="hot-links"> | ||
190 | <a href="/index.xml" class="feed-button">Subscribe</a> | ||
191 | </div> | ||
192 | <p>I'm Akshay, programmer and pixel-artist. | ||
193 | I write <a href="https://git.peppe.rs">open-source stuff</a>. | ||
194 | I also design fonts: | ||
195 | <a href="https://git.peppe.rs/fonts/scientifica/about">scientifica</a>, | ||
196 | <a href="https://git.peppe.rs/fonts/curie/about">curie</a>. | ||
197 | </p> | ||
198 | <p>Reach out at [email protected].</p> | ||
199 | </div> | ||
200 | |||
201 | <a href="/" class="post-end-link">Home</a> | ||
202 | <span>/</span> | ||
203 | <a href="/posts" class="post-end-link">Posts</a> | ||
204 | <span>/</span> | ||
205 | <a class="post-end-link">Introducing Tablespoon</a> | ||
206 | <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/introducing_tablespoon.md | ||
207 | ">View Raw</a> | ||
208 | </div> | ||
209 | </div> | ||
210 | </body> | ||
211 | </html> | ||
diff --git a/docs/posts/my_setup/index.html b/docs/posts/my_setup/index.html index 9844d52..a5cdef5 100644 --- a/docs/posts/my_setup/index.html +++ b/docs/posts/my_setup/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 06/11 — 2019 | 28 | 07/11 — 2019 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 10.39 | 31 | 10.39 |
diff --git a/docs/posts/pixel_art_in_GIMP/index.html b/docs/posts/pixel_art_in_GIMP/index.html index 25db0ca..122fd35 100644 --- a/docs/posts/pixel_art_in_GIMP/index.html +++ b/docs/posts/pixel_art_in_GIMP/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 08/04 — 2020 | 28 | 09/04 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 55.54 | 31 | 55.54 |
diff --git a/docs/posts/plain_text_journaling/index.html b/docs/posts/plain_text_journaling/index.html index b4b4c54..ae47471 100644 --- a/docs/posts/plain_text_journaling/index.html +++ b/docs/posts/plain_text_journaling/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 18/06 — 2023 | 28 | 19/06 — 2023 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 138.66 | 31 | 138.66 |
diff --git a/docs/posts/rapid_refactoring_with_vim/index.html b/docs/posts/rapid_refactoring_with_vim/index.html index cd10d02..622243d 100644 --- a/docs/posts/rapid_refactoring_with_vim/index.html +++ b/docs/posts/rapid_refactoring_with_vim/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 31/03 — 2020 | 28 | 01/04 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 79.12 | 31 | 79.12 |
diff --git a/docs/posts/static_sites_with_bash/index.html b/docs/posts/static_sites_with_bash/index.html index 8e6441a..293fa62 100644 --- a/docs/posts/static_sites_with_bash/index.html +++ b/docs/posts/static_sites_with_bash/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 22/11 — 2019 | 28 | 23/11 — 2019 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 21.18 | 31 | 21.18 |
diff --git a/docs/posts/termux_tandem/index.html b/docs/posts/termux_tandem/index.html index 15eb01f..cf7fb77 100644 --- a/docs/posts/termux_tandem/index.html +++ b/docs/posts/termux_tandem/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 07/03 — 2020 | 28 | 08/03 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 19.18 | 31 | 19.18 |
diff --git a/docs/posts/turing_complete_type_systems/index.html b/docs/posts/turing_complete_type_systems/index.html index 214e7ff..5a87edf 100644 --- a/docs/posts/turing_complete_type_systems/index.html +++ b/docs/posts/turing_complete_type_systems/index.html | |||
@@ -25,7 +25,7 @@ | |||
25 | ">View Raw</a> | 25 | ">View Raw</a> |
26 | <div class="separator"></div> | 26 | <div class="separator"></div> |
27 | <div class="date"> | 27 | <div class="date"> |
28 | 17/06 — 2020 | 28 | 18/06 — 2020 |
29 | <div class="stats"> | 29 | <div class="stats"> |
30 | <span class="stats-number"> | 30 | <span class="stats-number"> |
31 | 9.19 | 31 | 9.19 |
diff --git a/docs/style.css b/docs/style.css index d4a8391..04f78a8 100644 --- a/docs/style.css +++ b/docs/style.css | |||
@@ -52,10 +52,13 @@ div.hot-links { | |||
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | body { font-family: 'Inter', sans-serif; } | 55 | body { |
56 | font-family: 'Inter', sans-serif; | ||
57 | font-feature-settings: 'liga' 1, 'calt' 1; /* fix for Chrome */ | ||
58 | } | ||
56 | @supports (font-variation-settings: normal) { | 59 | @supports (font-variation-settings: normal) { |
57 | body { | 60 | body { |
58 | font-family: 'Inter var', sans-serif; | 61 | font-family: 'InterVariable', sans-serif; |
59 | font-feature-settings: 'ss01' 1, 'kern' 1, 'liga' 1, 'cv05' 1, 'tnum' 1; | 62 | font-feature-settings: 'ss01' 1, 'kern' 1, 'liga' 1, 'cv05' 1, 'tnum' 1; |
60 | } | 63 | } |
61 | } | 64 | } |