From: FreeBirdLjj Date: Sat, 27 Sep 2014 00:21:05 +0000 (+0800) Subject: Bugfix: for bug mistake HR as unordered list. X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=b00bb5d470d1afe9790607c2bd8bd961e96553fc;p=smdp.git Bugfix: for bug mistake HR as unordered list. --- diff --git a/src/parser.c b/src/parser.c index ef7c697..a573106 100644 --- a/src/parser.c +++ b/src/parser.c @@ -305,33 +305,46 @@ int markdown_analyse(cstring_t *text) { if(text->size >= offset + 2 && (text->text[offset] == '*' || text->text[offset] == '-') && text->text[offset + 1] == ' ') { - if(offset > unordered_list_offset + CODE_INDENT) { - SET_BIT(bits, IS_CODE); - } else if(offset != unordered_list_offset) { - for(i = unordered_list_level; i >= 0; i--) { - if(unordered_list_level_offset[i] == offset) { - unordered_list_level = i; - break; + + for(i = offset; itext[i] != '*' && + text->text[i] != '-' && + text->text[i] != ' ') { + if(offset > unordered_list_offset + CODE_INDENT) { + SET_BIT(bits, IS_CODE); + } else if(offset != unordered_list_offset) { + for(i = unordered_list_level; i >= 0; i--) { + if(unordered_list_level_offset[i] == offset) { + unordered_list_level = i; + break; + } + } + if(i != unordered_list_level) { + unordered_list_level = MIN(unordered_list_level + 1, UNORDERED_LIST_MAX_LEVEL); + unordered_list_level_offset[unordered_list_level] = offset; + } } - } - if(i != unordered_list_level) { - unordered_list_level = MIN(unordered_list_level + 1, UNORDERED_LIST_MAX_LEVEL); - unordered_list_level_offset[unordered_list_level] = offset; - } - } - if(unordered_list_level == 0) { - unordered_list_level = 1; - unordered_list_level_offset[1] = offset; - } + 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; + case 2: SET_BIT(bits, IS_UNORDERED_LIST_2); break; + case 3: SET_BIT(bits, IS_UNORDERED_LIST_3); break; + default: break; + } + + break; + } + } + + if(!CHECK_BIT(bits, IS_UNORDERED_LIST_1) && + !CHECK_BIT(bits, IS_UNORDERED_LIST_2) && + !CHECK_BIT(bits, IS_UNORDERED_LIST_3)) { - switch(unordered_list_level) { - case 1: SET_BIT(bits, IS_UNORDERED_LIST_1); break; - case 2: SET_BIT(bits, IS_UNORDERED_LIST_2); break; - case 3: SET_BIT(bits, IS_UNORDERED_LIST_3); break; - default: break; - } - } else { unordered_list_level = 0; if(offset >= CODE_INDENT) {