X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fparser.c;h=f5ab7fff3c0f246d7384480794092821dab6776b;hb=c8f46dfa8f411b643907bc4c372bf788140f26f3;hp=59b6b529c83dd83b25d3ea8bdc81fed2f94d3021;hpb=faaa6a40adb643fa62ab355b3ab617af1e454fed;p=smdp.git diff --git a/src/parser.c b/src/parser.c index 59b6b52..f5ab7ff 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2,7 +2,7 @@ * Functions necessary to parse a file and transform its content into * a deck of slides containing lines. All based on markdown formating * rules. - * Copyright (C) 2014 Michael Goehler + * Copyright (C) 2015 Michael Goehler * * This file is part of mdp. * @@ -68,6 +68,14 @@ deck_t *markdown_load(FILE *input) { // clear text (text->reset)(text); + } else if(line && CHECK_BIT(bits, IS_STOP)) { + + // set stop bit on last line + SET_BIT(line->bits, IS_STOP); + + // clear text + (text->reset)(text); + // if text is markdown hr } else if(CHECK_BIT(bits, IS_HR) && CHECK_BIT(line->bits, IS_EMPTY)) { @@ -308,6 +316,15 @@ int markdown_analyse(cstring_t *text, int prev) { // count leading spaces offset = next_nonblank(text, 0); + // IS_STOP + if((offset < CODE_INDENT || !CHECK_BIT(prev, IS_CODE)) && + (!wcsncmp(&text->value[offset], L"
", 4) || + !wcsncmp(&text->value[offset], L"
", 4) || + !wcsncmp(&text->value[offset], L"^", 1))) { + SET_BIT(bits, IS_STOP); + return bits; + } + // strip trailing spaces for(eol = text->size; eol > offset && iswspace(text->value[eol - 1]); eol--); @@ -381,7 +398,8 @@ int markdown_analyse(cstring_t *text, int prev) { // IS_CODE if(offset >= CODE_INDENT && (CHECK_BIT(prev, IS_EMPTY) || - CHECK_BIT(prev, IS_CODE))) { + CHECK_BIT(prev, IS_CODE) || + CHECK_BIT(prev, IS_STOP))) { SET_BIT(bits, IS_CODE); } else {