int offset;
} line_t;
-typedef struct _page_t {
+typedef struct _slide_t {
line_t *line;
- struct _page_t *prev;
- struct _page_t *next;
-} page_t;
+ struct _slide_t *prev;
+ struct _slide_t *next;
+} slide_t;
-typedef struct _document_t {
+typedef struct _deck_t {
line_t *header;
- page_t *page;
-} document_t;
+ slide_t *slide;
+} deck_t;
line_t *new_line();
line_t *next_line(line_t *prev);
-page_t *new_page();
-page_t *next_page(page_t *prev);
-document_t *new_document();
+slide_t *new_slide();
+slide_t *next_slide(slide_t *prev);
+deck_t *new_deck();
#endif // !defined( MARKDOWN_H )
#include "markdown.h"
-document_t *markdown_load(FILE *input);
+deck_t *markdown_load(FILE *input);
int markdown_analyse(cstring_t *text);
-void markdown_debug(document_t *doc, int debug);
+void markdown_debug(deck_t *deck, int debug);
int is_utf8(char ch);
int length_utf8(char ch);
int next_nonblank(cstring_t *text, int i);
return x;
}
-page_t *new_page() {
- page_t *x = malloc(sizeof(page_t));
+slide_t *new_slide() {
+ slide_t *x = malloc(sizeof(slide_t));
x->line = (void*)0;
x->prev = x->next = (void*)0;
return x;
}
-page_t *next_page(page_t *prev) {
- page_t *x = new_page();
+slide_t *next_slide(slide_t *prev) {
+ slide_t *x = new_slide();
x->prev = prev;
prev->next = x;
return x;
}
-document_t *new_document() {
- document_t *x = malloc(sizeof(document_t));
+deck_t *new_deck() {
+ deck_t *x = malloc(sizeof(deck_t));
x->header = (void*)0;
- x->page = (void*)0;
+ x->slide = (void*)0;
return x;
}
#include "include/parser.h"
-document_t *markdown_load(FILE *input) {
+deck_t *markdown_load(FILE *input) {
int c = 0, i = 0, l = 0, bits = 0;
- document_t *doc;
- page_t *page;
+ deck_t *deck;
+ slide_t *slide;
line_t *line;
cstring_t *text;
- doc = new_document();
- page = new_page();
- doc->page = page;
+ deck = new_deck();
+ slide = new_slide();
+ deck->slide = slide;
text = cstring_init();
while ((c = fgetc(input)) != EOF) {
// reset line length
l = 0;
- // create next page
- page = next_page(page);
+ // create next slide
+ slide = next_slide(slide);
} else {
- // if page ! has line
- if(!page->line) {
+ // if slide ! has line
+ if(!slide->line) {
// create new line
line = new_line();
- page->line = line;
+ slide->line = line;
} else {
}
// detect header
- line = doc->page->line;
+ line = deck->slide->line;
if(line && line->text->size > 0 && line->text->text[0] == '%') {
- // assign header to document
- doc->header = line;
+ // assign header to deck
+ deck->header = line;
// find first non-header line
while(line->text->size > 0 && line->text->text[0] == '%') {
line->prev->next = (void*)0;
line->prev = (void*)0;
- // remove header lines from page
- doc->page->line = line;
+ // remove header lines from slide
+ deck->slide->line = line;
}
// combine underlined H1/H2 in single line
- page = doc->page;
- while(page) {
- line = page->line;
+ slide = deck->slide;
+ while(slide) {
+ line = slide->line;
while(line) {
if((CHECK_BIT(line->bits, IS_H1) ||
CHECK_BIT(line->bits, IS_H2)) &&
}
line = line->next;
}
- page = page->next;
+ slide = slide->next;
}
- return doc;
+ return deck;
}
int markdown_analyse(cstring_t *text) {
return bits;
}
-void markdown_debug(document_t *doc, int debug) {
+void markdown_debug(deck_t *deck, int debug) {
// print header to STDERR
int offset;
line_t *header;
- if(doc->header) {
- header = doc->header;
+ if(deck->header) {
+ header = deck->header;
while(header &&
header->length > 0 &&
header->text->text[0] == '%') {
}
}
- // print page/line count to STDERR
- int cp = 0, cl = 0;
- page_t *page = doc->page;
+ // print slide/line count to STDERR
+ int cs = 0, cl = 0;
+ slide_t *slide = deck->slide;
line_t *line;
- while(page) {
- cp++;
+ while(slide) {
+ cs++;
if(debug > 1) {
- fprintf(stderr, "page %i:\n", cp);
+ fprintf(stderr, "slide %i:\n", cs);
}
- line = page->line;
+ line = slide->line;
cl = 0;
while(line) {
cl++;
line = line->next;
}
if(debug == 1) {
- fprintf(stderr, "page %i: %i lines\n", cp, cl);
+ fprintf(stderr, "slide %i: %i lines\n", cs, cl);
}
- page = page->next;
+ slide = slide->next;
}
}