1 /* 2 * htmlise.h: 3 * Definitions for htmlise. 4 * 5 * Copyright (c) 2003 Chris Lightfoot. All rights reserved. 6 * Email: chris@ex-parrot.com; WWW: http://www.ex-parrot.com/~chris/ 7 * 8 * $Id: htmlise.h,v 1.2 2003/02/06 23:14:01 chris Exp $ 9 * 10 */ 11 12 #ifndef __HTMLISE_H_ /* include guard */ 13 #define __HTMLISE_H_ 14 15 #include <stdio.h> 16 17 /* BULLET_CHARS 18 * Characters we allow to introduce a bulleted list segment. */ 19 #define BULLET_CHARS "-*+." 20 21 /* TABSIZE 22 * Number of characters between tab stops. 8 is traditional. */ 23 #define TABSIZE 8 24 25 /* alloc_struct S P 26 * Make P point to a new struct S, initialised as if in static storage (like 27 * = {0}). */ 28 #define alloc_struct(S, p) do { struct S as__z = {0}; p = malloc(sizeof *p); *p = as__z; } while (0) 29 30 /* struct paragraph 31 * Definition of a paragraph. */ 32 struct paragraph { 33 size_t nlines; 34 char **lines; 35 size_t indent, ldrindent; 36 /* Paragraph type. Either a paragraph is text with a possible numeric or 37 * bulleted leader, or it's a container for some more paragraphs, for 38 * instance a table cell. */ 39 enum { none, bullet, number } type; 40 char *container; 41 int leader; 42 struct paragraph *prev, *next, *contents; 43 }; 44 45 46 /* htmlise.c */ 47 char *get_line(FILE *fp); 48 int is_blank(const char *s); 49 char *expand_tabs(const char *string); 50 void classify_paragraph(struct paragraph *P); 51 struct paragraph *read_paragraph(FILE *fp); 52 int main(int argc, char *argv[]); 53 54 /* tables.c */ 55 void process_tables(struct paragraph *paras); 56 57 /* markup.c */ 58 struct paragraph *create_container(char *type, struct paragraph *first, struct paragraph *last, const int unindent); 59 void process_lists(struct paragraph *paras); 60 void process_block_quotes(struct paragraph *paras); 61 void process_markup(struct paragraph *paras); 62 63 /* inline.c */ 64 void emit_as_html(FILE *fp, const struct paragraph *P); 65 66 #endif /* __HTMLISE_H_ */ 67