-
Notifications
You must be signed in to change notification settings - Fork 0
/
irregex.mistie
48 lines (45 loc) · 1.47 KB
/
irregex.mistie
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
44
45
46
47
;; -*- scheme -*-
(mistie-def-ctl-seq 'item
(lambda ()
(h-make-section 4)))
(mistie-def-ctl-seq 'table
(lambda ()
(h-ignore-spaces)
(let* ((old-escape-char mistie-escape-char)
(c (read-char)))
(mistie-push-frame)
(display "<table>")
(if (not (char=? c #\{))
(error "table body must be wrapped in {...}")
(let ((n 0)
(rows 0))
(set! mistie-escape-char #\\)
(mistie-def-char #\{
(lambda ()
(display #\{)
(set! n (+ n 1))))
(mistie-def-char #\}
(lambda ()
(if (= n 0)
(begin
(display "</table>")
(mistie-pop-frame)
(set! mistie-escape-char old-escape-char))
(begin
(display #\})
(set! n (- n 1))))))
(mistie-def-char #\newline
(lambda ()
(let* ((ws (h-read-whitespace))
(c (peek-char)))
(if (positive? rows)
(display "</td></tr>"))
(newline)
(display ws)
(if (not (eqv? c #\}))
(begin
(display "<tr><td>")
(set! rows (+ rows 1)))))))
(mistie-def-char #\|
(lambda ()
(display "</td><td>"))))))))