X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=src%2Fparser.c;h=c8120cd31175f8a1f6b333b25bd33c2297e4c10b;hb=b723e39232abc7632311eb06d7046c214ee05b51;hp=a573106888282a4b060fed5cd4398de3185de418;hpb=b00bb5d470d1afe9790607c2bd8bd961e96553fc;p=smdp.git diff --git a/src/parser.c b/src/parser.c index a573106..c8120cd 100644 --- a/src/parser.c +++ b/src/parser.c @@ -302,11 +302,12 @@ int markdown_analyse(cstring_t *text) { // strip trailing spaces for(eol = text->size; eol > offset && isspace((unsigned char) text->text[eol - 1]); eol--); + // IS_UNORDERED_LIST_# if(text->size >= offset + 2 && (text->text[offset] == '*' || text->text[offset] == '-') && text->text[offset + 1] == ' ') { - for(i = offset; itext[i] != '*' && text->text[i] != '-' && text->text[i] != ' ') { @@ -328,7 +329,7 @@ int markdown_analyse(cstring_t *text) { if(unordered_list_level == 0) { unordered_list_level = 1; unordered_list_level_offset[1] = offset; - } + } switch(unordered_list_level) { case 1: SET_BIT(bits, IS_UNORDERED_LIST_1); break; @@ -339,6 +340,7 @@ int markdown_analyse(cstring_t *text) { break; } + } } if(!CHECK_BIT(bits, IS_UNORDERED_LIST_1) && @@ -347,9 +349,10 @@ int markdown_analyse(cstring_t *text) { unordered_list_level = 0; + // IS_CODE if(offset >= CODE_INDENT) { - // IS_CODE SET_BIT(bits, IS_CODE); + } else { for(i = offset; i < eol; i++) { @@ -498,6 +501,13 @@ int next_nonblank(cstring_t *text, int i) { return i; } +int prev_blank(cstring_t *text, int i) { + while ((i > 0) && !isspace((unsigned char) (text->text)[i])) + i--; + + return i; +} + int next_blank(cstring_t *text, int i) { while ((i < text->size) && !isspace((unsigned char) (text->text)[i])) i++;