2 * ctxt - a simple and fast plain text formatter
4 * Copyright (C) 2009-2012 Ali Gholami Rudi
6 * This program is released under the modified BSD license.
14 extern struct fmt_ops troff_ops
;
15 extern struct fmt_ops latex_ops
;
16 extern struct fmt_ops html_ops
;
18 static struct fmt_ops
*get_ops(char *name
)
20 if (!strcmp(name
, "troff"))
22 if (!strcmp(name
, "latex"))
24 if (!strcmp(name
, "html"))
31 write(2, msg
, strlen(msg
));
35 void *xmalloc(int size
)
37 void *value
= malloc(size
);
39 die("Out of memory!\n");
44 "usage: ctxt [-m mode] [-e esc] <plaintext >formatted\n\n"
45 " mode: latex, html or troff (default: troff)\n";
47 int main(int argc
, char **argv
)
55 for (i
= 1; i
< argc
; i
++) {
56 if (argv
[i
][0] == '-' && argv
[i
][1] == 'm') {
57 mode
= argv
[i
][2] ? argv
[i
] + 2 : argv
[++i
];
60 if (argv
[i
][0] == '-' && argv
[i
][1] == 'e') {
61 esc
= argv
[i
][2] ? argv
[i
][2] : argv
[++i
][0];
66 if (!(ops
= get_ops(mode
)))
67 die("unknown output format\n");
70 format(doc
, txt
, ops
, esc
);