AtlatestRepositorysigil-doc
1(define-library (practical-sigil book)
2 (import (sigil core) (sigil fs) (sigil doc publication) (sigil doc print)
3 (sigil doc render typst) (practical-sigil theme))
4 (export practical-sigil-publication practical-sigil->typst
5 build-practical-sigil-typst)
6 (begin
7 (define (load-chapter path)
8 (load path)
9 (eval 'document))
10 (define (practical-sigil-publication)
11 (make-print-publication
12 "Practical Sigil"
13 "Craft Useful Things with a Small, Powerful Scheme"
14 '("David Wilson")
15 (list
16 (make-publication-document "useful-first-script"
17 (load-chapter "book/practical-sigil/01-useful-first-script.sgd"))
18 (make-publication-document "change-the-question"
19 (load-chapter "book/practical-sigil/02-change-the-question.sgd")))
20 '()))
21 (define (edition-values edition)
22 (case edition
23 ((current) (list practical-sigil-print-options practical-sigil-theme))
24 ((compact-study) (list compact-study-print-options compact-study-theme))
25 (else (error "practical-sigil->typst: edition must be current or compact-study"))))
26 (define (practical-sigil->typst edition)
27 (let ((values (edition-values edition)))
28 (print-publication->typst (practical-sigil-publication)
29 options: (car values) theme: (cadr values))))
30 (define (build-practical-sigil-typst output-path edition)
31 (if (not (and (string? output-path) (> (string-length output-path) 0)))
32 (error "build-practical-sigil-typst: expected a nonempty output path")
33 (begin
34 (write-file-string output-path (practical-sigil->typst edition))
35 output-path)))))