html: put a new line after body
[ctxt.git] / ctxt.c
blob6b037d3c9305eeaf140acc9a27d00c7af306dc2b
1 #include <getopt.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 #include "ctxt.h"
7 #include "util.h"
9 static struct fmt_ops *get_ops(char *name)
11 if (!strcmp(name, "latex"))
12 return &latex_ops;
13 if (!strcmp(name, "html"))
14 return &html_ops;
15 return NULL;
18 static char *version =
19 "CTXT 0.1\n"
20 "Copyright (C) 2009 Ali Gholami Rudi\n"
21 "You can redistribute and/or modify ctxt under the terms\n"
22 "of GNU General Public License. For more information, see\n"
23 "COPYING.\n";
25 static char *help =
26 "usage: ctxt [-m mode] <plaintext >formatted\n\n"
27 " -m\t\toutput format: latex or html (default: latex)\n"
28 " -h\t\tshow this screen\n"
29 " -v\t\tshow version\n";
31 int main(int argc, char **argv)
33 struct txt *txt;
34 struct doc *doc;
35 char *mode = "latex";
36 struct fmt_ops *ops;
37 int c;
38 while ((c = getopt(argc, argv, "hvm:")) != -1) {
39 switch (c) {
40 case 'h':
41 puts(help);
42 return 0;
43 case 'v':
44 puts(version);
45 return 0;
46 case 'm':
47 mode = optarg;
48 break;
49 case '?':
50 return 1;
51 default:
52 die("bad command line option\n");
55 if (!(ops = get_ops(mode)))
56 die("unknown output format\n");
57 txt = txt_alloc(STDIN_FILENO);
58 doc = doc_alloc(STDOUT_FILENO);
59 format(doc, txt, ops);
60 doc_free(doc);
61 txt_free(txt);
62 return 0;