| 1 |
;; |
| 2 |
;; Convert plain text COPYING into rtf format, for Wix needs it. |
| 3 |
;; |
| 4 |
|
| 5 |
(use file.filter) |
| 6 |
(use file.util) |
| 7 |
(use srfi.13) |
| 8 |
(use util.match) |
| 9 |
|
| 10 |
(define (main args) |
| 11 |
(match args |
| 12 |
[(_ in out) (file-filter doit :input in :output out)] |
| 13 |
[_ (exit 1 "Usage: ~a <input-file> <output-file>" (car args))]) |
| 14 |
0) |
| 15 |
|
| 16 |
(define (doit in out) |
| 17 |
(display "{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}\r\n" out) |
| 18 |
(display "\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs20 " out) |
| 19 |
(let loop ([prev-line (read-line in)]) |
| 20 |
(unless (eof-object? prev-line) |
| 21 |
(let1 line (read-line in) |
| 22 |
(cond [(and (string? line) (#/^-------------------/ line)) |
| 23 |
(format out "\\ul ~a\\ulnone\\par\r\n" prev-line) |
| 24 |
(loop (read-line in))] |
| 25 |
[(#/-------/ prev-line) |
| 26 |
(format out "\\ul ~a\\ulnone\\par\r\n" |
| 27 |
(string-trim-right prev-line #[-])) |
| 28 |
(loop line)] |
| 29 |
[else |
| 30 |
(format out "~a\\par\r\n" prev-line) |
| 31 |
(loop line)])))) |
| 32 |
(display "}" out)) |