aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/index.html25
-rw-r--r--docs/index.xml198
-rw-r--r--docs/posts/OSC-52/index.html119
-rw-r--r--docs/posts/auto-currying_rust_functions/index.html2
-rw-r--r--docs/posts/bash_harder_with_vim/index.html2
-rw-r--r--docs/posts/call_to_ARMs/index.html2
-rw-r--r--docs/posts/color_conundrum/index.html2
-rw-r--r--docs/posts/font_size_fallacies/index.html2
-rw-r--r--docs/posts/index.html59
-rw-r--r--docs/posts/introducing_tablespoon/index.html211
-rw-r--r--docs/posts/my_setup/index.html2
-rw-r--r--docs/posts/pixel_art_in_GIMP/index.html2
-rw-r--r--docs/posts/plain_text_journaling/index.html2
-rw-r--r--docs/posts/rapid_refactoring_with_vim/index.html2
-rw-r--r--docs/posts/static_sites_with_bash/index.html2
-rw-r--r--docs/posts/termux_tandem/index.html2
-rw-r--r--docs/posts/turing_complete_type_systems/index.html2
-rw-r--r--docs/style.css7
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>&lt;p&gt;I use &lt;code&gt;ssh&lt;/code&gt; a lot. Copying text from the remote machine to
17the host machine always sucked. But OSC-52 makes that easy.&lt;/p&gt;
18&lt;p&gt;OSC-52 is an ANSI escape sequence to write text to the terminal
19emulator. The terminal emulator, if it understands what is going on,
20will in turn write this text to the system clipboard.&lt;/p&gt;
21&lt;p&gt;What this means is some &lt;code&gt;printf&lt;/code&gt; magic can send text to
22your clipboard. I store this one-liner in a script called
23&lt;code&gt;oclip&lt;/code&gt;:&lt;/p&gt;
24&lt;div class="sourceCode" id="cb1"&gt;&lt;pre
25class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;printf&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;\033]52;c;%s\007&amp;quot;&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;$(&lt;/span&gt;&lt;span class="fu"&gt;base64&lt;/span&gt; &lt;span class="op"&gt;&amp;lt;&amp;amp;&lt;/span&gt;&lt;span class="dv"&gt;0&lt;/span&gt;&lt;span class="va"&gt;)&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
26&lt;p&gt;and I run it with:&lt;/p&gt;
27&lt;div class="sourceCode" id="cb2"&gt;&lt;pre
28class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;remote&lt;/span&gt; $ cat some_file.txt &lt;span class="kw"&gt;|&lt;/span&gt; &lt;span class="ex"&gt;oclip&lt;/span&gt;&lt;/span&gt;
29&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
30&lt;span id="cb2-3"&gt;&lt;a href="#cb2-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# some_file.txt&amp;#39;s contents are now the host&amp;#39;s clipboard&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
31&lt;h3 id="the-catch"&gt;The catch&lt;/h3&gt;
32&lt;p&gt;Your terminal emulator must support OSC-52, &lt;code&gt;alacritty&lt;/code&gt;
33and &lt;code&gt;termux&lt;/code&gt; seem to support this out of the box. In
34&lt;code&gt;st&lt;/code&gt;, OSC-52 works with this change to
35&lt;code&gt;config.h&lt;/code&gt;:&lt;/p&gt;
36&lt;pre&gt;&lt;code&gt;int allowwindowops = 1;&lt;/code&gt;&lt;/pre&gt;
37&lt;p&gt;If you are using &lt;code&gt;tmux&lt;/code&gt;, you need to flip this switch
38on:&lt;/p&gt;
39&lt;pre&gt;&lt;code&gt;set -s set-clipboard on&lt;/code&gt;&lt;/pre&gt;
40&lt;p&gt;If you are inside &lt;code&gt;nvim&lt;/code&gt;, it may work as expected as long
41as &lt;code&gt;$SSH_TTY&lt;/code&gt; is set. I sometimes physically start a session,
42and &lt;code&gt;ssh&lt;/code&gt; into the same session later from another machine,
43and &lt;code&gt;$SSH_TTY&lt;/code&gt; remains unset, so I force OSC-52 in
44&lt;code&gt;nvim&lt;/code&gt; at all times (see &lt;a
45href="https://neovim.io/doc/user/provider.html#clipboard-osc52"&gt;nvimdoc&lt;/a&gt;):&lt;/p&gt;
46&lt;div class="sourceCode" id="cb5"&gt;&lt;pre
47class="sourceCode lua"&gt;&lt;code class="sourceCode lua"&gt;&lt;span id="cb5-1"&gt;&lt;a href="#cb5-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="va"&gt;vim&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;&lt;span class="va"&gt;g&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;&lt;span class="va"&gt;clipboard&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
48&lt;span id="cb5-2"&gt;&lt;a href="#cb5-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;name&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="st"&gt;&amp;#39;OSC 52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;,&lt;/span&gt;&lt;/span&gt;
49&lt;span id="cb5-3"&gt;&lt;a href="#cb5-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;copy&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
50&lt;span id="cb5-4"&gt;&lt;a href="#cb5-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;copy&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
51&lt;span id="cb5-5"&gt;&lt;a href="#cb5-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;copy&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
52&lt;span id="cb5-6"&gt;&lt;a href="#cb5-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;},&lt;/span&gt;&lt;/span&gt;
53&lt;span id="cb5-7"&gt;&lt;a href="#cb5-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;paste&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
54&lt;span id="cb5-8"&gt;&lt;a href="#cb5-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;paste&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
55&lt;span id="cb5-9"&gt;&lt;a href="#cb5-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;paste&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
56&lt;span id="cb5-10"&gt;&lt;a href="#cb5-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;},&lt;/span&gt;&lt;/span&gt;
57&lt;span id="cb5-11"&gt;&lt;a href="#cb5-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
58&lt;p&gt;If you are inside &lt;code&gt;nvim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; inside
59an &lt;code&gt;ssh&lt;/code&gt; session inside &lt;code&gt;st&lt;/code&gt;, you neeed all of the
60above tweaks. &lt;code&gt;nvim&lt;/code&gt; will pass the contents around to
61&lt;code&gt;tmux&lt;/code&gt;, which in turn will pass the contents to
62&lt;code&gt;st&lt;/code&gt;, which should pass it to your system clipboard.&lt;/p&gt;</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>&lt;p&gt;&lt;a href="https://git.peppe.rs/languages/tbsp"&gt;tbsp&lt;/a&gt; (tree-based
70source-processing language) is an awk-like language that operates on
71tree-sitter syntax trees. To motivate the need for such a program, we
72could begin by writing a markdown-to-html converter using
73&lt;code&gt;tbsp&lt;/code&gt; and &lt;a
74href="https://github.com/tree-sitter-grammars/tree-sitter-markdown"&gt;tree-sitter-md&lt;/a&gt;.
75We need some markdown to begin with:&lt;/p&gt;
76&lt;pre&gt;&lt;code&gt;# 1 heading
77
78content of first paragraph
79
80## 1.1 heading
81
82content of nested paragraph&lt;/code&gt;&lt;/pre&gt;
83&lt;p&gt;For future reference, this markdown is parsed like so by
84tree-sitter-md (visualization generated by &lt;a
85href="https://git.peppe.rs/cli/tree-viz"&gt;tree-viz&lt;/a&gt;):&lt;/p&gt;
86&lt;pre&gt;&lt;code&gt;document
87| section
88| | atx_heading
89| | | atx_h1_marker &amp;quot;#&amp;quot;
90| | | heading_content inline &amp;quot;1 heading&amp;quot;
91| | paragraph
92| | | inline &amp;quot;content of first paragraph&amp;quot;
93| | section
94| | | atx_heading
95| | | | atx_h2_marker &amp;quot;##&amp;quot;
96| | | | heading_content inline &amp;quot;1.1 heading&amp;quot;
97| | | paragraph
98| | | | inline &amp;quot;content of nested paragraph&amp;quot;&lt;/code&gt;&lt;/pre&gt;
99&lt;p&gt;Onto the converter itself. Every &lt;code&gt;tbsp&lt;/code&gt; program is written
100as a collection of stanzas. Typically, we start with a stanza like
101so:&lt;/p&gt;
102&lt;pre&gt;&lt;code&gt;BEGIN {
103 int depth = 0;
104
105 print(&amp;quot;&amp;lt;html&amp;gt;\n&amp;quot;);
106 print(&amp;quot;&amp;lt;body&amp;gt;\n&amp;quot;);
107}&lt;/code&gt;&lt;/pre&gt;
108&lt;p&gt;The stanza begins with a “pattern”, in this case, &lt;code&gt;BEGIN&lt;/code&gt;,
109and is followed a block of code. This block specifically, is executed
110right at the beginning, before traversing the parse tree. In this
111stanza, we set a “depth” variable to keep track of nesting of markdown
112headers, and begin our html document by printing the
113&lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
114&lt;p&gt;We can follow this stanza with an &lt;code&gt;END&lt;/code&gt; stanza, that is
115executed after the traversal:&lt;/p&gt;
116&lt;pre&gt;&lt;code&gt;END {
117 print(&amp;quot;&amp;lt;/body&amp;gt;\n&amp;quot;);
118 print(&amp;quot;&amp;lt;/html&amp;gt;\n&amp;quot;);
119}&lt;/code&gt;&lt;/pre&gt;
120&lt;p&gt;In this stanza, we close off the tags we opened at the start of the
121document. We can move onto the interesting bits of the conversion
122now:&lt;/p&gt;
123&lt;pre&gt;&lt;code&gt;enter section {
124 depth += 1;
125}
126leave section {
127 depth -= 1;
128}&lt;/code&gt;&lt;/pre&gt;
129&lt;p&gt;The above stanzas begin with &lt;code&gt;enter&lt;/code&gt; and
130&lt;code&gt;leave&lt;/code&gt; clauses, followed by the name of a tree-sitter node
131kind: &lt;code&gt;section&lt;/code&gt;. The &lt;code&gt;section&lt;/code&gt; identifier is
132visible in the tree-visualization above, it encompasses a
133markdown-section, and is created for every markdown header. To
134understand how &lt;code&gt;tbsp&lt;/code&gt; executes above stanzas:&lt;/p&gt;
135&lt;pre&gt;&lt;code&gt;document ... depth = 0
136| section &amp;lt;-------- enter section (1) ... depth = 1
137| | atx_heading
138| | | inline
139| | paragraph
140| | | inline
141| | section &amp;lt;----- enter section (2) ... depth = 2
142| | | atx_heading
143| | | | inline
144| | | paragraph
145| | | | inline
146| | | &amp;lt;----------- leave section (2) ... depth = 1
147| | &amp;lt;-------------- leave section (1) ... depth = 0 &lt;/code&gt;&lt;/pre&gt;
148&lt;p&gt;The following stanzas should be self-explanatory now:&lt;/p&gt;
149&lt;pre&gt;&lt;code&gt;enter atx_heading {
150 print(&amp;quot;&amp;lt;h&amp;quot;);
151 print(depth);
152 print(&amp;quot;&amp;gt;&amp;quot;);
153}
154leave atx_heading {
155 print(&amp;quot;&amp;lt;/h&amp;quot;);
156 print(depth);
157 print(&amp;quot;&amp;gt;\n&amp;quot;);
158}
159
160enter inline {
161 print(text(node));
162}&lt;/code&gt;&lt;/pre&gt;
163&lt;p&gt;But an explanation is included nonetheless:&lt;/p&gt;
164&lt;pre&gt;&lt;code&gt;document ... depth = 0
165| section &amp;lt;-------- enter section (1) ... depth = 1
166| | atx_heading &amp;lt;- enter atx_heading ... print &amp;quot;&amp;lt;h1&amp;gt;&amp;quot;
167| | | inline &amp;lt;--- enter inline ... print ..
168| | | &amp;lt;----------- leave atx_heading ... print &amp;quot;&amp;lt;/h1&amp;gt;&amp;quot;
169| | paragraph
170| | | inline &amp;lt;--- enter inline ... print ..
171| | section &amp;lt;----- enter section (2) ... depth = 2
172| | | atx_heading enter atx_heading ... print &amp;quot;&amp;lt;h2&amp;gt;&amp;quot;
173| | | | inline &amp;lt;- enter inline ... print ..
174| | | | &amp;lt;-------- leave atx_heading ... print &amp;quot;&amp;lt;/h2&amp;gt;&amp;quot;
175| | | paragraph
176| | | | inline &amp;lt;- enter inline ... print ..
177| | | &amp;lt;----------- leave section (2) ... depth = 1
178| | &amp;lt;-------------- leave section (1) ... depth = 0 &lt;/code&gt;&lt;/pre&gt;
179&lt;p&gt;The &lt;a
180href="https://git.peppe.rs/languages/tbsp/tree/examples"&gt;examples&lt;/a&gt;
181directory contains a complete markdown-to-html converter, along with a
182few other motivating examples.&lt;/p&gt;
183&lt;h3 id="usage"&gt;Usage&lt;/h3&gt;
184&lt;p&gt;The &lt;code&gt;tbsp&lt;/code&gt; evaluator is written in rust, use cargo to
185build and run:&lt;/p&gt;
186&lt;pre&gt;&lt;code&gt;cargo build --release
187./target/release/tbsp --help&lt;/code&gt;&lt;/pre&gt;
188&lt;p&gt;&lt;code&gt;tbsp&lt;/code&gt; requires three inputs:&lt;/p&gt;
189&lt;ul&gt;
190&lt;li&gt;a &lt;code&gt;tbsp&lt;/code&gt; program, referred to as “program file”&lt;/li&gt;
191&lt;li&gt;a language&lt;/li&gt;
192&lt;li&gt;an input file or some input text at stdin&lt;/li&gt;
193&lt;/ul&gt;
194&lt;p&gt;You can run the interpreter like so (this program prints an overview
195of a rust file):&lt;/p&gt;
196&lt;pre&gt;&lt;code&gt;$ ./target/release/tbsp \
197 -f./examples/code-overview/overview.tbsp \
198 -l rust \
199 src/main.rs
200module
201 └╴struct Cli
202 └╴trait Cli
203 └╴fn program
204 └╴fn language
205 └╴fn file
206 └╴fn try_consume_stdin
207 └╴fn main&lt;/code&gt;&lt;/pre&gt;</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>&lt;p&gt;I regularly switch between exactly two things while working, a 214<description>&lt;p&gt;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 &nbsp
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
46the 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
48emulator. The terminal emulator, if it understands what is going on,
49will 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
51your clipboard. I store this one-liner in a script called
52<code>oclip</code>:</p>
53<div class="sourceCode" id="cb1"><pre
54class="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>
55<p>and I run it with:</p>
56<div class="sourceCode" id="cb2"><pre
57class="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&#39;s contents are now the host&#39;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>
62and <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
67on:</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
70as <code>$SSH_TTY</code> is set. I sometimes physically start a session,
71and <code>ssh</code> into the same session later from another machine,
72and <code>$SSH_TTY</code> remains unset, so I force OSC-52 in
73<code>nvim</code> at all times (see <a
74href="https://neovim.io/doc/user/provider.html#clipboard-osc52">nvimdoc</a>):</p>
75<div class="sourceCode" id="cb5"><pre
76class="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">&#39;OSC 52&#39;</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">&#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>
80<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>
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">&#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>
84<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>
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
88an <code>ssh</code> session inside <code>st</code>, you neeed all of the
89above 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 &nbsp
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
46source-processing language) is an awk-like language that operates on
47tree-sitter syntax trees. To motivate the need for such a program, we
48could begin by writing a markdown-to-html converter using
49<code>tbsp</code> and <a
50href="https://github.com/tree-sitter-grammars/tree-sitter-markdown">tree-sitter-md</a>.
51We need some markdown to begin with:</p>
52<pre><code># 1 heading
53
54content of first paragraph
55
56## 1.1 heading
57
58content of nested paragraph</code></pre>
59<p>For future reference, this markdown is parsed like so by
60tree-sitter-md (visualization generated by <a
61href="https://git.peppe.rs/cli/tree-viz">tree-viz</a>):</p>
62<pre><code>document
63| section
64| | atx_heading
65| | | atx_h1_marker &quot;#&quot;
66| | | heading_content inline &quot;1 heading&quot;
67| | paragraph
68| | | inline &quot;content of first paragraph&quot;
69| | section
70| | | atx_heading
71| | | | atx_h2_marker &quot;##&quot;
72| | | | heading_content inline &quot;1.1 heading&quot;
73| | | paragraph
74| | | | inline &quot;content of nested paragraph&quot;</code></pre>
75<p>Onto the converter itself. Every <code>tbsp</code> program is written
76as a collection of stanzas. Typically, we start with a stanza like
77so:</p>
78<pre><code>BEGIN {
79 int depth = 0;
80
81 print(&quot;&lt;html&gt;\n&quot;);
82 print(&quot;&lt;body&gt;\n&quot;);
83}</code></pre>
84<p>The stanza begins with a “pattern”, in this case, <code>BEGIN</code>,
85and is followed a block of code. This block specifically, is executed
86right at the beginning, before traversing the parse tree. In this
87stanza, we set a “depth” variable to keep track of nesting of markdown
88headers, and begin our html document by printing the
89<code>&lt;html&gt;</code> and <code>&lt;body&gt;</code> tags.</p>
90<p>We can follow this stanza with an <code>END</code> stanza, that is
91executed after the traversal:</p>
92<pre><code>END {
93 print(&quot;&lt;/body&gt;\n&quot;);
94 print(&quot;&lt;/html&gt;\n&quot;);
95}</code></pre>
96<p>In this stanza, we close off the tags we opened at the start of the
97document. We can move onto the interesting bits of the conversion
98now:</p>
99<pre><code>enter section {
100 depth += 1;
101}
102leave 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
107kind: <code>section</code>. The <code>section</code> identifier is
108visible in the tree-visualization above, it encompasses a
109markdown-section, and is created for every markdown header. To
110understand how <code>tbsp</code> executes above stanzas:</p>
111<pre><code>document ... depth = 0
112| section &lt;-------- enter section (1) ... depth = 1
113| | atx_heading
114| | | inline
115| | paragraph
116| | | inline
117| | section &lt;----- enter section (2) ... depth = 2
118| | | atx_heading
119| | | | inline
120| | | paragraph
121| | | | inline
122| | | &lt;----------- leave section (2) ... depth = 1
123| | &lt;-------------- 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(&quot;&lt;h&quot;);
127 print(depth);
128 print(&quot;&gt;&quot;);
129}
130leave atx_heading {
131 print(&quot;&lt;/h&quot;);
132 print(depth);
133 print(&quot;&gt;\n&quot;);
134}
135
136enter 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 &lt;-------- enter section (1) ... depth = 1
142| | atx_heading &lt;- enter atx_heading ... print &quot;&lt;h1&gt;&quot;
143| | | inline &lt;--- enter inline ... print ..
144| | | &lt;----------- leave atx_heading ... print &quot;&lt;/h1&gt;&quot;
145| | paragraph
146| | | inline &lt;--- enter inline ... print ..
147| | section &lt;----- enter section (2) ... depth = 2
148| | | atx_heading enter atx_heading ... print &quot;&lt;h2&gt;&quot;
149| | | | inline &lt;- enter inline ... print ..
150| | | | &lt;-------- leave atx_heading ... print &quot;&lt;/h2&gt;&quot;
151| | | paragraph
152| | | | inline &lt;- enter inline ... print ..
153| | | &lt;----------- leave section (2) ... depth = 1
154| | &lt;-------------- leave section (1) ... depth = 0 </code></pre>
155<p>The <a
156href="https://git.peppe.rs/languages/tbsp/tree/examples">examples</a>
157directory contains a complete markdown-to-html converter, along with a
158few other motivating examples.</p>
159<h3 id="usage">Usage</h3>
160<p>The <code>tbsp</code> evaluator is written in rust, use cargo to
161build 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
171of a rust file):</p>
172<pre><code>$ ./target/release/tbsp \
173 -f./examples/code-overview/overview.tbsp \
174 -l rust \
175 src/main.rs
176module
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
55body { font-family: 'Inter', sans-serif; } 55body {
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}