Previous: Creating and Running Individual Blocks, Up: Tutorial [Contents]
Blocks can be printed to various output formats, such as strings or SXML.
(use-modules (blocks)
(blocks language c)
(blocks printer sxml))
(define my-block (make-block*
#:language c
#:code "
#include <stdio.h>
int main(void) {
printf(\"Hello world!\");
}"
#:run? #t))
(block->sxml my-block)
;; => $1 = (div ...)
;; An SXML tree structure suitable for HTML insertion.
The code and result keyword arguments can be used to restrict or
modify how the corresponding block fields are printed.
(block->sxml my-block
#:code 'none)
;; => $1 = (div ...)
;; An SXML tree that does not contain C code, only the block result.