477342deb3cda4f20ca4162a9be0dee41399875e
[smdp.git] / include / parser.h
1 #if !defined( PARSER_H )
2 #define PARSER_H
3
4 /*
5  * Functions necessary to parse a file and transform its content into
6  * a deck of slides containing lines. All based on markdown formating
7  * rules.
8  * Copyright (C) 2014 Michael Goehler
9  *
10  * This file is part of mdp.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  *
26  * function: markdown_load is the main function which reads a file handle,
27  *           and initializes deck, slides and lines
28  * function: markdown_analyse which is used to identify line wide formating
29  *           rules in given line
30  * function: markdown_debug to print a report of the generated data structure
31  * function: adjust_line_length to calculate line length excluding markup
32  * function: is_utf8 detects multi-byte char
33  * function: length_utf8 calculates the amount of bytes used for a multi-byte
34  *           char
35  * function: next_nonblank, next_blank, next_word to calculate string offset's
36  *
37  */
38
39 #include "common.h"
40 #include "markdown.h"
41 #include "cstack.h"
42
43 #define EXPAND_TABS 4
44 #define CODE_INDENT 4
45 #define UNORDERED_LIST_MAX_LEVEL 3
46
47 deck_t *markdown_load(FILE *input);
48 int markdown_analyse(cstring_t *text, int prev);
49 void markdown_debug(deck_t *deck, int debug);
50 void adjust_line_length(line_t *line);
51 bool is_utf8(char ch);
52 int length_utf8(char ch);
53 int next_nonblank(cstring_t *text, int i);
54 int prev_blank(cstring_t *text, int i);
55 int next_blank(cstring_t *text, int i);
56 int next_word(cstring_t *text, int i);
57
58 #endif // !defined( PARSER_H )