@@ 0,0 1,51 @@
+#!/usr/bin/env retro
+
+Begin by opening the input and output files, and setting up a
+couple of variables.
+
+~~~
+'ilo.blocks.txt file:W file:open 'OUT const
+'ilo.blocks file:R file:open 'IN const
+
+'Block var
+'Line var
+~~~
+
+Draw the horizontal rule. This is intended to match that used in
+the retro/ilo block editor, with the addition of the block
+number at the end.
+
+~~~
+:rule '___ s:put #6 [ '+----5---- s:put ] times '+--- s:put ;
+:id @Block $: c:put n:put nl ;
+~~~
+
+Displaying the block is a matter of reading in 16 lines of 64
+characters, outputting the line number, and then the text.
+The output is setup to match that in `block_export.py` to keep
+compatibility.
+
+~~~
+:n:put/padded dup #9 lteq? [ sp ] if n:put sp ;
+:display @Line n:put/padded s:trim-right s:put nl &Line v:inc ;
+:next s:empty dup buffer:set ;
+:read-line #64 [ IN file:read buffer:add ] times ;
+:read-block #0 !Line #16 [ next read-line display ] times ;
+~~~
+
+The top level loop just iterates over the blocks, displaying the
+rules and then the block contents. This overrides `c:put` to
+write the output to file.
+
+~~~
+[ OUT file:write ] &c:put set-hook
+#4096 [ rule id read-block &Block v:inc ] times rule id ;
+&c:put unhook
+~~~
+
+Final cleanup is just closing the input and output files.
+
+~~~
+IN file:close
+OUT file:close
+~~~