X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fparser.c;h=c2ccb0ae667b4ec2938f165219666c0fe350f9f6;hb=b17ed569c4a9c22ef75bd6ffaf4a50a9bb8ec379;hp=d81a2cb259b612b596ba8414cfba5eb6d323c54e;hpb=3e6d7001c4058b93281645e72ad1e223280b8589;p=smdp.git diff --git a/src/parser.c b/src/parser.c index d81a2cb..c2ccb0a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -89,9 +89,11 @@ deck_t *markdown_load(FILE *input) { slide = next_slide(slide); sc++; - } else if(CHECK_BIT(bits, IS_TILDE_CODE) && CHECK_BIT(bits, IS_EMPTY)) { - // remove tilde code markers - (text->reset)(text); + } else if(CHECK_BIT(bits, IS_TILDE_CODE) && + CHECK_BIT(bits, IS_EMPTY)) { + // remove tilde code markers + (text->reset)(text); + } else { // if slide ! has line @@ -338,6 +340,11 @@ int markdown_analyse(cstring_t *text, int prev) { // return IS_EMPTY on null pointers if(!text || !text->value) { SET_BIT(bits, IS_EMPTY); + + // continue fenced code blocks across empty lines + if(num_tilde_characters > 0) + SET_BIT(bits, IS_CODE); + return bits; } @@ -346,23 +353,23 @@ int markdown_analyse(cstring_t *text, int prev) { // IS_TILDE_CODE if (wcsncmp(text->value, L"~~~", 3) == 0) { - int tildes_in_line = next_nontilde(text, 0); - if (tildes_in_line >= num_tilde_characters) { - if (num_tilde_characters > 0) { - num_tilde_characters = 0; - } else { - num_tilde_characters = tildes_in_line; - } - SET_BIT(bits, IS_EMPTY); - SET_BIT(bits, IS_TILDE_CODE); - return bits; - } + int tildes_in_line = next_nontilde(text, 0); + if (tildes_in_line >= num_tilde_characters) { + if (num_tilde_characters > 0) { + num_tilde_characters = 0; + } else { + num_tilde_characters = tildes_in_line; + } + SET_BIT(bits, IS_EMPTY); + SET_BIT(bits, IS_TILDE_CODE); + return bits; + } } if (num_tilde_characters > 0) { - SET_BIT(bits, IS_CODE); - SET_BIT(bits, IS_TILDE_CODE); - return bits; + SET_BIT(bits, IS_CODE); + SET_BIT(bits, IS_TILDE_CODE); + return bits; } // IS_STOP @@ -599,7 +606,7 @@ void markdown_debug(deck_t *deck, int debug) { void adjust_line_length(line_t *line) { int l = 0; const static wchar_t *special = L"\\*_`"; // list of interpreted chars - const wchar_t *c = &line->text->value[line->offset]; + const wchar_t *c = &line->text->value[0]; cstack_t *stack = cstack_init(); // for each char in line @@ -647,7 +654,6 @@ int next_nonblank(cstring_t *text, int i) { return i; } - int prev_blank(cstring_t *text, int i) { while ((i > 0) && !iswspace((text->value)[i])) i--;