X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fparser.c;h=b4006109bd847194052b70cabb3cf9111e9da64a;hb=7b546f2a11460bed09b61116c8be38f8decf0440;hp=c85af8c212df7ef8325d3cb5d6f32e90921e7fbe;hpb=7fc5d3a79deb7bc3ac8faffb6d295c6c3a9154d2;p=smdp.git diff --git a/src/parser.c b/src/parser.c index c85af8c..b400610 100644 --- a/src/parser.c +++ b/src/parser.c @@ -161,7 +161,7 @@ deck_t *markdown_load(FILE *input) { } } } - cstring_delete(text); + (text->delete)(text); slide->lines = lc; deck->slides = sc; @@ -174,21 +174,29 @@ deck_t *markdown_load(FILE *input) { deck->header = line; // find first non-header line - while(line->text->size > 0 && line->text->text[0] == '%') { + while(line && line->text->size > 0 && line->text->text[0] == '%') { hc++; line = line->next; } - // split linked list - line->prev->next = NULL; - line->prev = NULL; + // only split header if any non-header line is found + if(line) { - // remove header lines from slide - deck->slide->line = line; + // split linked list + line->prev->next = NULL; + line->prev = NULL; - // adjust counts - deck->headers += hc; - deck->slide->lines -= hc; + // remove header lines from slide + deck->slide->line = line; + + // adjust counts + deck->headers += hc; + deck->slide->lines -= hc; + } else { + + // remove header from deck + deck->header = NULL; + } } slide = deck->slide;