1 /* markdown_peg.h */ 2 #ifndef MARKDOWN_PEG_H 3 #define MARKDOWN_PEG_H 4 5 #include "markdown_lib.h" 6 #include <glib.h> 7 8 /* Information (label, URL and title) for a link. */ 9 struct Link { 10 struct Element *label; 11 char *url; 12 char *title; 13 }; 14 15 typedef struct Link link; 16 17 /* Union for contents of an Element (string, list, or link). */ 18 union Contents { 19 char *str; 20 struct Link *link; 21 }; 22 23 /* Types of semantic values returned by parsers. */ 24 enum keys { LIST, /* A generic list of values. For ordered and bullet lists, see below. */ 25 RAW, /* Raw markdown to be processed further */ 26 SPACE, 27 LINEBREAK, 28 ELLIPSIS, 29 EMDASH, 30 ENDASH, 31 APOSTROPHE, 32 SINGLEQUOTED, 33 DOUBLEQUOTED, 34 STR, 35 LINK, 36 IMAGE, 37 CODE, 38 HTML, 39 EMPH, 40 STRONG, 41 PLAIN, 42 PARA, 43 LISTITEM, 44 BULLETLIST, 45 ORDEREDLIST, 46 H1, H2, H3, H4, H5, H6, /* Code assumes that these are in order. */ 47 BLOCKQUOTE, 48 VERBATIM, 49 HTMLBLOCK, 50 HRULE, 51 REFERENCE, 52 NOTE 53 }; 54 55 /* Semantic value of a parsing action. */ 56 struct Element { 57 int key; 58 union Contents contents; 59 struct Element *children; 60 struct Element *next; 61 }; 62 63 typedef struct Element element; 64 65 element * parse_references(char *string, int extensions); 66 element * parse_notes(char *string, int extensions, element *reference_list); 67 element * parse_markdown(char *string, int extensions, element *reference_list, element *note_list); 68 void free_element_list(element * elt); 69 void free_element(element *elt); 70 void print_element_list(GString *out, element *elt, int format, int exts); 71 72 #endif 73