summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/blocks.c b/src/blocks.c
index 936ba6a..5554a17 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -633,7 +633,7 @@ static bool S_parse_block_quote(cmark_parser *parser,
if (c == ' ' || c == '\t')
S_advance_offset(parser, input, 1, true);
-
+
res = true;
}
return res;
@@ -803,6 +803,9 @@ static void try_new_container_starts(cmark_parser *parser,
bufsize_t matched = 0;
int lev = 0;
char c;
+ bool save_partially_consumed_tab;
+ int save_offset;
+ int save_column;
while (cont_type != CMARK_NODE_CODE_BLOCK &&
cont_type != CMARK_NODE_HTML_BLOCK) {
@@ -894,19 +897,27 @@ static void try_new_container_starts(cmark_parser *parser,
parser->first_nonspace + matched - parser->offset,
false);
- // TODO handle tabs
- while (i <= 5 && (c = peek_at(input, parser->offset + i)) && c == ' ')
- i++;
+ save_partially_consumed_tab = parser->partially_consumed_tab;
+ save_offset = parser->offset;
+ save_column = parser->column;
- // i = number of spaces after marker, up to 5
- if (i >= 5 || i < 1 ||
- S_is_line_end_char(peek_at(input, parser->offset))) {
+ while (parser->column - save_column <= 5 &&
+ (c = peek_at(input, parser->offset)) &&
+ (c == ' ' || c == '\t')) {
+ S_advance_offset(parser, input, 1, true);
+ }
+
+ i = parser->column - save_column;
+ if (i >= 5 || i < 1) {
data->padding = matched + 1;
- if (i > 0)
- S_advance_offset(parser, input, 1, false);
+ parser->offset = save_offset;
+ parser->column = save_column;
+ parser->partially_consumed_tab = save_partially_consumed_tab;
+ if (i > 0) {
+ S_advance_offset(parser, input, 1, true);
+ }
} else {
data->padding = matched + i;
- S_advance_offset(parser, input, i, true);
}
// check container; if it's a list, see if this list item