version bump
[smdp.git] / include / markdown.h
1 #if !defined( MARKDOWN_H )
2 #define MARKDOWN_H
3
4 /*
5  * An implementation of markdown objects.
6  * Copyright (C) 2018 Michael Goehler
7  *
8  * This file is part of mdp.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  *
24  * enum: line_bitmask which enumerates markdown formating bits
25  *
26  * struct: deck_t the root object representing a deck of slides
27  * struct: slide_t a linked list element of type slide contained in a deck
28  * struct: line_t a linked list element of type line contained in a slide
29  *
30  * function: new_deck to initialize a new deck
31  * function: new_slide to initialize a new linked list of type slide
32  * function: next_slide to extend a linked list of type slide by one element
33  * function: new_line to initialize a new linked list of type line
34  * function: next_line to extend a linked list of type line by one element
35  * function: free_line to free a line elements memory
36  * function: free_deck to free a deck's memory
37  *
38  */
39
40 #include "cstring.h"
41 #include "bitops.h"
42
43 enum line_bitmask {
44     IS_H1,
45     IS_H1_ATX,
46     IS_H2,
47     IS_H2_ATX,
48     IS_QUOTE,
49     IS_CODE,
50     IS_TILDE_CODE,
51     IS_GFM_CODE,
52     IS_HR,
53     IS_UNORDERED_LIST_1,
54     IS_UNORDERED_LIST_2,
55     IS_UNORDERED_LIST_3,
56     IS_UNORDERED_LIST_EXT,
57     IS_CENTER,
58     IS_STOP,
59     IS_EMPTY
60 };
61
62 typedef struct _line_t {
63     cstring_t *text;
64     struct _line_t *prev;
65     struct _line_t *next;
66     int bits;
67     int length;
68     int offset;
69 } line_t;
70
71 typedef struct _slide_t {
72     line_t *line;
73     struct _slide_t *prev;
74     struct _slide_t *next;
75     int lines;
76     int stop;
77 } slide_t;
78
79 typedef struct _deck_t {
80     line_t *header;
81     slide_t *slide;
82     int slides;
83     int headers;
84 } deck_t;
85
86 line_t *new_line();
87 line_t *next_line(line_t *prev);
88 slide_t *new_slide();
89 slide_t *next_slide(slide_t *prev);
90 deck_t *new_deck();
91 void free_line(line_t *l);
92 void free_deck(deck_t *);
93
94 #endif // !defined( MARKDOWN_H )