Guile Blocks: Proof of Concept

Hi! This is an introductory page demonstrating Guile Blocks, an Org-mode-esque implementation of source blocks in Guile Scheme.

You're encouraged to read the project README before or alongside this post. This post primarily exists to demonstrate their real-life usage. The README covers more technical details.

I also encourage checking out the source file for this post. You can find that here.

Blocks are records primarily composed of two fields: arbitrary code (usually a string) and a language.

The syntax for defining code blocks looks like this:

(define-block foo
  #:code     bar
  #:language baz)
Results:
#f

The blocks shown in the following segment were run when the website was built. The results were not prepopulated.

It's easy to support different languages. Here's some Ruby code.

puts "Ahh, General Kenobi. You are a bold one.".upcase
Results:
AHH, GENERAL KENOBI. YOU ARE A BOLD ONE.

And here is some Elixir code. This was actually created by running two separate blocks as a pipeline.

IO.write (1 + 7)
Results:
8

We can have syntax highlighting as well! The provided languages that support syntax highlighting use David Thompson's guile-syntax-highlight. However, any highlighter could be used.

@media screen and (min-width: 720px) {
    pre {
        /* Don't shrink code block font when there's enough width. */
        font-size: 1em;
    }
}
Results:
#f