summaryrefslogtreecommitdiff
path: root/elenqdoc
blob: aa4ed2f4b5a0b02bfea59bc0b16a88443a1ad806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env guile
!#

(use-modules (ice-9 match))
;; Remove the alias and make it better!
;; alias pandoc-xelatex="pandoc $@ --pdf-engine=xelatex --to latex -N"
;; alias elenqdoc-article="pandoc-xelatex $@ --standalone --template elenq-article --metadata=documentclass:article --resource-path=~/.pandoc:."
;; alias elenqdoc-book="pandoc-xelatex $@  --standalone --template elenq-book --metadata=documentclass:book --top-level-division=chapter --resource-path=~/.pandoc:."


(define (pandoc-xelatex args)
  ;; If I don't want numbered sections: mark them as unnumbered or try to
  ;; `--number-sections=false` on top
  `("pandoc" "--pdf-engine=xelatex" "--to=latex" "-N"
    ,(string-append "--data-dir=" (getenv "ELENQDOC_DATADIR"))
    ,@args))

(define (invoke . args)
  (display "Calling: ")
  (display (string-join args " "))
  (newline)
  (apply system* args))

(define (help)
  (format #t "Wrong command~%Use `book` or `article`.~%")
  (exit 1))

(define (main name command . args)
  (match command
    ("article"
     (apply invoke
       (pandoc-xelatex (cons* "--template=elenq-article"
                              "--metadata=documentclass:article"
                              args))))
    ("book"
     (apply invoke
       (pandoc-xelatex (cons* "--template=elenq-book"
                              "--metadata=documentclass:book"
                              "--top-level-division=chapter"
                              args))))
    (else (help))))

(apply main (command-line))