summaryrefslogtreecommitdiff
path: root/skribe-utils.scm
blob: 812085315495c1742ff0efc8df5703ac35554769 (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
(define-module (skribe-utils)
  #:use-module (ice-9 match)
  #:use-module (syntax-highlight)
  #:use-module (syntax-highlight scheme)
  #:use-module (syntax-highlight xml)
  #:use-module (syntax-highlight c)
  #:export (image/caption
            scheme-source
            xml-source
            c-source))

(define (image/caption uri caption)
  `((img (@ (class "centered rounded")
            (src ,uri)
            (alt ,caption)))
    (div (@ (class "caption")) ,caption)))

(define (scheme-source source)
  (highlights->sxml
   (highlight lex-scheme
              (match source
                ((source ...)
                 (string-concatenate source))
                (_ source)))))

(define (xml-source source)
  (highlights->sxml
   (highlight lex-xml
              (match source
                ((source ...)
                 (string-concatenate source))
                (_ source)))))

(define (c-source source)
  (highlights->sxml
   (highlight lex-c
              (match source
                ((source ...)
                 (string-concatenate source))
                (_ source)))))