AtlatestRepositorysigil-doc

sigil-doc / tree / testbuild-print-customization.sgl

1#!/usr/bin/env sigil
2(import (sigil core) (sigil fs) (sigil shell) (sigil doc) (sigil doc publication)
3 (sigil doc print) (sigil doc render typst))
4
5(define args (script-args))
6(unless (or (= (length args) 1) (= (length args) 2))
7 (error "usage: build-print-customization.sgl OUTPUT.typ [publication-title|chapter-title]"))
8(define header-policy
9 (if (= (length args) 2) (string->symbol (cadr args)) 'publication-title))
11(define loc (make-srcloc "customization-pressure.sgd" 1 1 0 1))
12(define (chapter title authors id)
13 (make-document 'chapter title authors
14 (list (make-section id (list (make-text "A Themed Section" loc))
15 (list
16 (make-paragraph (list (make-text "Copyable UTF-8: καλημέρα." loc)) loc)
17 (make-code-block "sigil"
18 "; custom palette\n(define message \"theme witness\")\n(if #t 7391 0)" loc))
19 loc)) loc))
20(define publication
21 (make-print-publication "Customization Pressure" "A visibly distinct edition"
22 '("David Wilson")
23 (list
24 (make-publication-document "same-author" (chapter "Same Author" '("David Wilson") "same"))
25 (make-publication-document "guest-author" (chapter "Guest Author" '("Grace Hopper") "guest")))
26 '()))
27(define options
28 (make-print-options chapter-numbering: 'roman-upper section-numbering-depth: 1
29 chapter-author-display: 'when-different contents-depth: 2 chapter-start: 'odd
30 chapter-label-style: 'chapter-word running-header: header-policy))
31(define theme
32 (make-typst-theme paper: 'a5
33 margin-x: (make-typst-length 16 'mm) margin-y: (make-typst-length 18 'mm)
34 body-size: (make-typst-length 10 'pt) code-size: (make-typst-length 7.5 'pt)
35 title-size: (make-typst-length 23 'pt) title-weight: 'semibold
36 subtitle-size: (make-typst-length 12 'pt)
37 chapter-size: (make-typst-length 18 'pt) chapter-weight: 'bold
38 section-size: (make-typst-length 12.5 'pt) section-weight: 'semibold
39 heading-color: "2f496e" heading-spacing: (make-typst-length 12 'pt)
40 accent-color: "b44b34" syntax-comment-color: "58715f"
41 syntax-string-color: "a03c62" syntax-keyword-color: "4e55a6"
42 syntax-number-color: "b05f18" syntax-plain-color: "20242b"
43 code-background: "edf1f5" code-padding: (make-typst-length 7 'pt)
44 code-wrap-column: 64 chapter-author-size: (make-typst-length 9 'pt)
45 chapter-author-color: "546171" title-author-size: (make-typst-length 10 'pt)
46 page-number-position: 'right running-header-size: (make-typst-length 7.5 'pt)
47 running-header-color: "546171" running-header-align: 'right))
49(write-file-string (car args)
50 (print-publication->typst publication options: options theme: theme))