fmt: start a paragraph only after a blank line
[ctxt.git] / ctxt.h
blob125741089f0d8db1cb3ce107560e91dfb9b73326
1 struct doc {
2 int fd;
3 int len;
4 int size;
5 char *buf;
6 };
8 struct doc *doc_alloc(int fd);
9 void doc_write(struct doc *doc, char *s);
10 void doc_memcat(struct doc *doc, char *s, int n);
11 void doc_free(struct doc *doc);
13 struct fmt_ops {
14 void (*doc_beg)(struct doc *doc);
15 void (*doc_end)(struct doc *doc);
16 void (*head_beg)(struct doc *doc, int level);
17 void (*head_end)(struct doc *doc, int level);
18 void (*par_beg)(struct doc *doc);
19 void (*par_end)(struct doc *doc);
20 void (*put)(struct doc *doc, char *s);
21 void (*put_txt)(struct doc *doc, char *s, char *marker);
22 void (*list_beg)(struct doc *doc, int mark);
23 void (*list_end)(struct doc *doc);
24 void (*item_beg)(struct doc *doc, char *mark);
25 void (*item_end)(struct doc *doc);
26 void (*table_beg)(struct doc *doc, int columns);
27 void (*table_end)(struct doc *doc);
28 void (*row_beg)(struct doc *doc);
29 void (*row_end)(struct doc *doc);
30 void (*entry_beg)(struct doc *doc);
31 void (*entry_end)(struct doc *doc);
32 void (*block_beg)(struct doc *doc, char *beg);
33 void (*block_end)(struct doc *doc, char *end);
36 struct txt {
37 char *txt;
38 char **lines;
39 int n;
42 struct txt *txt_alloc(int fd);
43 char *txt_line(struct txt *txt, int line);
44 void txt_free(struct txt *txt);
46 void format(struct doc *doc, struct txt *txt, struct fmt_ops *ops);
48 void die(char *msg);
49 void *xmalloc(int size);