Something went wrong. Try again.
A literate programming tool.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071== Using loom
=== Prepare a safe first project
Prerequisites: Nix, Git, and a checkout of this repository. There is no promisedprebuilt download. From the checkout, build the package once and remember itsexecutable before changing directories:
```bashnix buildexport LOOM="$(pwd)/result/bin/loom"lesson="$(mktemp -d)"mkdir "$lesson/src"cd "$lesson"```
The fresh temporary directory keeps this lesson away from existing work.Create `loom.edn` with this *lesson configuration*, not the repository's realconfiguration:
```edn{:watch ["^src/.+\\.typ$"] :source-roots ["src"] :annotation :naked}```
Create `src/hello.typ` containing the following text. The outer four-backtickfence in this manual quotes a sample document; it is not a live target.
````text= A first literate file
The file is assembled from one named greeting.
```text#| file: out/hello.txt<<lesson-greeting>>```
```text#| id: lesson-greetingHello from Loom.```````
=== Generate, change, and compose
Run the executable remembered above:
```bash"$LOOM" .```
The progress line begins `Writing` and names `out/hello.txt`; its entire contentsare `Hello from Loom.` followed by a newline. Change the greeting to your ownsentence and run the same command again. Inspect the output in your editor.Run once more without editing: progress begins `Unchanged`, and the output'smodification time and permissions are retained.
Now add a second whole-line `<<lesson-greeting>>` to the *sample root* above.Regeneration writes the greeting twice. Indent that second inclusion by twospaces: the second generated greeting gains two spaces. Finally append anothersample block with the same `id: lesson-greeting`; both inclusions now expandboth parts in sorted source-file order and within-file order. This demonstratescomposition, not a relationship between the ID and a filename.
When ready to inspect the mechanism, follow `<<loom-inclusion-syntax>>`, then`<<loom-reference-emission>>`. Unknown or cyclic inclusions fail rather thansilently writing incomplete text. Keep this lesson's outputs separate from thecheckout's generated files.