https://github.com/kflu/literify
racket literate programming in scribble to enable simultaneously display and evaluate code chunks
https://github.com/kflu/literify
documentation literate-programming racket scribble
Last synced: 2 months ago
JSON representation
racket literate programming in scribble to enable simultaneously display and evaluate code chunks
- Host: GitHub
- URL: https://github.com/kflu/literify
- Owner: kflu
- License: other
- Created: 2017-06-18T05:23:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-18T05:57:50.000Z (almost 9 years ago)
- Last Synced: 2026-02-06T15:18:56.434Z (3 months ago)
- Topics: documentation, literate-programming, racket, scribble
- Language: Racket
- Size: 375 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# literify
```racket
(require literify) package: literify
```
Default Scribble or scribble/lp2 doesn’t allow you to have some code
both displayed and executed at the same time. This library provides
several forms to enable this functionality.
For example, putting the below lines in your scribble document not only
displays it, but also executes it. Displaying and executing code is done
by `code/eval`:
```racket
@code/eval[
(define name "Mike")
(define age 12)]
```
Then later in the document, you can display the code and its output by
using `code/print`, `code/display`, or `code/write`:
```racket
@code/print[
(string-append "hello " name)]
```
```racket
(code/eval expr ...)
```
Displays `expr ...` and also evaluates them in the current context. If
the expressions returns a value, the value will attempted to be rendered
in the document. If it cannot be rendered, e.g., if it’s not a string or
pictures, the document will fail to be generated.
This form is usually used to defining valuables, functions, structs,
etc. It can also be used to display pictures.
If you want to display the result of some expression, use `code/format`
and its derivatives.
```racket
(code/format formatter expr ...)
formatter : (any -> string?)
```
Displays `expr ...` and also evaluates them. The output of the
expressions will be formatted by `formatter` and displayed.
The below forms are derived from `code/format` and use `~a`, `~v`, and
`~s` as the `formatter` respectively.
```racket
(code/display expr ...)
```
```racket
(code/print expr ...)
```
```racket
(code/write expr ...)
```